diff --git a/Makefile b/Makefile index 8d76a3c..0a42915 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ LIBS := $(addprefix $(OUT)/, $(LIBS)) JARS := dcurljni-$(VERSION).jar JARS := $(addprefix $(OUT)/, $(JARS)) -PREQ := config $(TESTS) $(LIBS) +PREQ := $(SUBS) config $(TESTS) $(LIBS) ifeq ("$(BUILD_JNI)","1") PREQ += $(JARS) endif @@ -162,19 +162,19 @@ endif OBJS := $(addprefix $(OUT)/, $(OBJS)) -$(OUT)/test-%.o: tests/test-%.c $(LIBTUV_PATH)/include +$(OUT)/test-%.o: tests/test-%.c $(VECHO) " CC\t$@\n" - $(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) $(LIBTUV_INCLUDE) -c -MMD -MF $@.d $< + $(Q)$(CC) -o $@ $(CFLAGS) -I $(SRC) $(SUB_INCLUDE) -c -MMD -MF $@.d $< -$(OUT)/%.o: $(SRC)/%.c $(LIBTUV_PATH)/include $(LIBRABBITMQ_PATH)/build/include +$(OUT)/%.o: $(SRC)/%.c $(SUB_OBJS) $(VECHO) " CC\t$@\n" - $(Q)$(CC) -o $@ $(CFLAGS) $(LIBTUV_INCLUDE) $(LIBRABBITMQ_INCLUDE) -c -MMD -MF $@.d $< + $(Q)$(CC) -o $@ $(CFLAGS) $(SUB_INCLUDE) -c -MMD -MF $@.d $< -$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS) +$(OUT)/test-%: $(OUT)/test-%.o $(OBJS) $(SUB_OBJS) $(VECHO) " LD\t$@\n" $(Q)$(CC) -o $@ $^ $(LDFLAGS) -$(OUT)/libdcurl.so: $(OBJS) $(LIBTUV_OBJS) $(LIBRABBITMQ_OBJS) +$(OUT)/libdcurl.so: $(OBJS) $(SUB_OBJS) $(VECHO) " LD\t$@\n" $(Q)$(CC) -shared -o $@ $^ $(LDFLAGS) diff --git a/mk/submodule.mk b/mk/submodule.mk index 25b4c40..9976236 100644 --- a/mk/submodule.mk +++ b/mk/submodule.mk @@ -21,7 +21,7 @@ LIBTUV_BOARD := $(BOARD) # PIC (Position-Independent-Code) object file LIBTUV_OBJS := $(LIBTUV_PATH)/build/$(LIBTUV_PLATFORM)/release/lib/libtuv.o -$(LIBTUV_PATH)/include: +$(LIBTUV_PATH)/.git: git submodule update --init $(LIBTUV_PATH) $(LIBTUV_OBJS): @@ -36,9 +36,11 @@ ifeq ($(UNAME_S),darwin) LDFLAGS += -L$(OPENSSL_PATH)/lib -lcrypto -lssl endif -$(LIBRABBITMQ_PATH)/build/include: +$(LIBRABBITMQ_PATH)/.git: git submodule update --init $(LIBRABBITMQ_PATH) - mkdir $(LIBRABBITMQ_PATH)/build + mkdir -p $(LIBRABBITMQ_PATH)/build + +$(LIBRABBITMQ_OBJS): ifeq ($(UNAME_S),darwin) # macOS cd $(LIBRABBITMQ_PATH)/build && \ @@ -49,7 +51,21 @@ else cmake -DCMAKE_INSTALL_PREFIX=. .. && \ cmake --build . --target install endif - -$(LIBRABBITMQ_OBJS): cd $(LIBRABBITMQ_PATH)/build && \ cmake --build . + +# Submodules +SUBS := $(LIBTUV_PATH)/.git +ifeq ($(BUILD_REMOTE),1) + SUBS += $(LIBRABBITMQ_PATH)/.git +endif +# Submodule related objects +SUB_OBJS := $(LIBTUV_OBJS) +ifeq ($(BUILD_REMOTE),1) + SUB_OBJS += $(LIBRABBITMQ_OBJS) +endif +# Submodule C flags for including header files +SUB_INCLUDE := $(LIBTUV_INCLUDE) +ifeq ($(BUILD_REMOTE),1) + SUB_INCLUDE += $(LIBRABBITMQ_INCLUDE) +endif