[build] support separate build directories

This commit is contained in:
Joe Thornber 2018-06-13 09:33:25 +01:00
parent 1311447a94
commit 80e046a7df
2 changed files with 8 additions and 0 deletions

View File

@ -202,6 +202,7 @@ endif
%.o: %.cc %.o: %.cc
@echo " [CXX] $<" @echo " [CXX] $<"
@mkdir -p $(dir $@)
$(V) $(CXX) -c $(INCLUDES) $(CXXFLAGS) -o $@ $< $(V) $(CXX) -c $(INCLUDES) $(CXXFLAGS) -o $@ $<
@echo " [DEP] $<" @echo " [DEP] $<"
$(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CXXFLAGS) $< > $*.$$$$; \ $(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CXXFLAGS) $< > $*.$$$$; \
@ -210,6 +211,7 @@ endif
%.o: %.c %.o: %.c
@echo " [CXX] $<" @echo " [CXX] $<"
@mkdir -p $(dir $@)
$(V) $(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $< $(V) $(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $<
@echo " [DEP] $<" @echo " [DEP] $<"
$(V) $(CC) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CFLAGS) $< > $*.$$$$; \ $(V) $(CC) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CFLAGS) $< > $*.$$$$; \
@ -218,16 +220,19 @@ endif
%.8: %.txt bin/txt2man %.8: %.txt bin/txt2man
@echo " [txt2man] $<" @echo " [txt2man] $<"
@mkdir -p $(dir $@)
$(V) bin/txt2man -p -t $(basename $(notdir $<)) $< > $@ $(V) bin/txt2man -p -t $(basename $(notdir $<)) $< > $@
#---------------------------------------------------------------- #----------------------------------------------------------------
lib/libpdata.a: $(OBJECTS) $(EMITTERS) lib/libpdata.a: $(OBJECTS) $(EMITTERS)
@echo " [AR] $<" @echo " [AR] $<"
@mkdir -p $(dir $@)
$(V)ar -rv $@ $(OBJECTS) $(EMITTERS) > /dev/null 2>&1 $(V)ar -rv $@ $(OBJECTS) $(EMITTERS) > /dev/null 2>&1
bin/pdata_tools: $(OBJECTS) $(EMITTERS) bin/pdata_tools: $(OBJECTS) $(EMITTERS)
@echo " [LD] $@" @echo " [LD] $@"
@mkdir -p $(dir $@)
$(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(CXXLIB) $(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(CXXLIB)
#---------------------------------------------------------------- #----------------------------------------------------------------

View File

@ -35,6 +35,7 @@ GMOCK_DEPS=\
lib/libgmock.a: $(GMOCK_DEPS) lib/libgmock.a: $(GMOCK_DEPS)
@echo " [CXX] gtest" @echo " [CXX] gtest"
@mkdir -p lib
$(V)g++ $(GMOCK_INCLUDES) -I$(GMOCK_DIR)/googletest -c $(GMOCK_DIR)/googletest/src/gtest-all.cc $(V)g++ $(GMOCK_INCLUDES) -I$(GMOCK_DIR)/googletest -c $(GMOCK_DIR)/googletest/src/gtest-all.cc
@echo " [CXX] gmock" @echo " [CXX] gmock"
$(V)g++ $(GMOCK_INCLUDES) -I$(GMOCK_DIR)/googlemock -c $(GMOCK_DIR)/googlemock/src/gmock-all.cc $(V)g++ $(GMOCK_INCLUDES) -I$(GMOCK_DIR)/googlemock -c $(GMOCK_DIR)/googlemock/src/gmock-all.cc
@ -78,6 +79,7 @@ TEST_OBJECTS=$(subst .cc,.gmo,$(TEST_SOURCE))
%.gmo: %.cc %.gmo: %.cc
@echo " [CXX] $<" @echo " [CXX] $<"
@mkdir -p $(dir $@)
$(V) $(CXX) -c $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) -o $@ $< $(V) $(CXX) -c $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) -o $@ $<
@echo " [DEP] $<" @echo " [DEP] $<"
$(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) $< > $*.$$$$; \ $(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) $< > $*.$$$$; \
@ -86,6 +88,7 @@ TEST_OBJECTS=$(subst .cc,.gmo,$(TEST_SOURCE))
unit-tests/unit_tests: $(TEST_OBJECTS) lib/libgmock.a lib/libpdata.a unit-tests/unit_tests: $(TEST_OBJECTS) lib/libgmock.a lib/libpdata.a
@echo " [LD] $<" @echo " [LD] $<"
@mkdir -p $(dir $@)
$(V)g++ $(CXXFLAGS) $(LDFLAGS) -o $@ $(TEST_OBJECTS) $(LIBS) $(GMOCK_LIBS) $(LIBEXPAT) $(V)g++ $(CXXFLAGS) $(LDFLAGS) -o $@ $(TEST_OBJECTS) $(LIBS) $(GMOCK_LIBS) $(LIBEXPAT)
.PHONY: unit-test .PHONY: unit-test