From c1e6adc72c86ba566e6117b61bc7e6581c4518f1 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 13 Jun 2018 09:33:25 +0100 Subject: [PATCH] [build] support separate build directories --- Makefile.in | 5 +++++ unit-tests/Makefile.in | 3 +++ 2 files changed, 8 insertions(+) diff --git a/Makefile.in b/Makefile.in index 34b7fe4..c0b990a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -202,6 +202,7 @@ endif %.o: %.cc @echo " [CXX] $<" + @mkdir -p $(dir $@) $(V) $(CXX) -c $(INCLUDES) $(CXXFLAGS) -o $@ $< @echo " [DEP] $<" $(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CXXFLAGS) $< > $*.$$$$; \ @@ -210,6 +211,7 @@ endif %.o: %.c @echo " [CXX] $<" + @mkdir -p $(dir $@) $(V) $(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $< @echo " [DEP] $<" $(V) $(CC) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CFLAGS) $< > $*.$$$$; \ @@ -218,16 +220,19 @@ endif %.8: %.txt bin/txt2man @echo " [txt2man] $<" + @mkdir -p $(dir $@) $(V) bin/txt2man -p -t $(basename $(notdir $<)) $< > $@ #---------------------------------------------------------------- lib/libpdata.a: $(OBJECTS) $(EMITTERS) @echo " [AR] $<" + @mkdir -p $(dir $@) $(V)ar -rv $@ $(OBJECTS) $(EMITTERS) > /dev/null 2>&1 bin/pdata_tools: $(OBJECTS) $(EMITTERS) @echo " [LD] $@" + @mkdir -p $(dir $@) $(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(CXXLIB) #---------------------------------------------------------------- diff --git a/unit-tests/Makefile.in b/unit-tests/Makefile.in index f09294e..46bc347 100644 --- a/unit-tests/Makefile.in +++ b/unit-tests/Makefile.in @@ -35,6 +35,7 @@ GMOCK_DEPS=\ lib/libgmock.a: $(GMOCK_DEPS) @echo " [CXX] gtest" + @mkdir -p lib $(V)g++ $(GMOCK_INCLUDES) -I$(GMOCK_DIR)/googletest -c $(GMOCK_DIR)/googletest/src/gtest-all.cc @echo " [CXX] gmock" $(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 @echo " [CXX] $<" + @mkdir -p $(dir $@) $(V) $(CXX) -c $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) -o $@ $< @echo " [DEP] $<" $(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 @echo " [LD] $<" + @mkdir -p $(dir $@) $(V)g++ $(CXXFLAGS) $(LDFLAGS) -o $@ $(TEST_OBJECTS) $(LIBS) $(GMOCK_LIBS) $(LIBEXPAT) .PHONY: unit-test