diff --git a/src/Makefile b/src/Makefile index 15617d2..0985a70 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,7 @@ -include build.conf.deploy_macos -TARGET=fvflash +TARGET_EXE=fvflash +TARGET_LIB=libch341eeprom.a # default config SYS_PREFIX?=/opt/local @@ -13,10 +14,16 @@ CFLAGS+=-std=c99 -MMD -MP -Wno-format-extra-args -Wno-deprecated-declarations CFLAGS+=-isystem$(SYS_INC_PATH) -fvisibility=hidden LDFLAGS+=-DMACOSX_DEPLOYMENT_TARGET=11.00 -framework Foundation -framework IOKit -framework Security +STATIC_LINK_LIBS=$(SYS_LIB_PATH)/libusb-1.0.a -SRC=$(wildcard *.c) -OBJ=$(subst .c,.o,$(SRC)) -DEPENDS=$(subst .c,.d,$(SRC)) +SRC_ALL=$(wildcard *.c) +SRC_EXE=fvflash.c +SRC_LIB=$(filter-out $(SRC_EXE), $(SRC_ALL)) + +#OBJ_EXE=$(subst .c,.o,$(SRC_EXE)) +OBJ_LIB=$(subst .c,.o,$(SRC_LIB)) + +DEPENDS=$(subst .c,.d,$(SRC_ALL)) ifneq ($(MAKECMDGOALS),clean) -include $(DEPENDS) @@ -25,12 +32,17 @@ endif .PHONY: all clean uninstall install .DEFAULT_GOAL := all -all: $(TARGET) +all: $(TARGET_EXE) + +lib: $(TARGET_LIB) + +$(TARGET_EXE): $(SRC_EXE) $(TARGET_LIB) + $(CXX) $(LDFLAGS) $(TARGET_LIB) $(STATIC_LINK_LIBS) $(SRC_EXE) -o $@ -$(TARGET): $(OBJ) - $(CXX) $(LDFLAGS) $(SYS_LIB_PATH)/libusb-1.0.a $(OBJ) -o "$@" +$(TARGET_LIB): $(OBJ_LIB) + $(AR) -cr $@ $^ clean: - rm $(OBJ) $(TARGET) $(DEPENDS) + rm $(OBJ_LIB) $(TARGET_LIB) $(TARGET_EXE) $(DEPENDS)