From ccefdf6a655adf4965cfef1070b93e0434fa8528 Mon Sep 17 00:00:00 2001 From: Ognjen Sobajic Date: Thu, 24 Oct 2013 14:35:36 -0700 Subject: [PATCH 1/2] Makefiles with autodiscovered .h files dependencies. --- Release/src/Makefile | 5 ++++- Release/tests/Functional/http/client/Makefile | 4 +++- Release/tests/Functional/http/listener/Makefile | 4 +++- Release/tests/Functional/http/utilities/Makefile | 6 ++++-- Release/tests/Functional/json/Makefile | 10 ++++++++-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Release/src/Makefile b/Release/src/Makefile index be5dc5797a..c12c670321 100644 --- a/Release/src/Makefile +++ b/Release/src/Makefile @@ -66,6 +66,7 @@ PCH = ./pch/stdafx.h PRECOMPILED_HEADERS = $(addsuffix .gch, $(PCH)) OBJECTS = $(addsuffix .$(MODE).o, $(basename $(SOURCES))) +CPP_DEPENDENCIES = $(addsuffix .d, $(basename $(SOURCES))) # flags for the C++ compiler @@ -90,9 +91,11 @@ all: $(LIBRARY_DST) @echo "Building precompiled header $(@)" @$(CXX) -x c++-header $(CXXFLAGS) -c $< -o $@ +-include $(CPP_DEPENDENCIES) + %.$(MODE).o: %.cpp @echo "Compiling $< -> $@" - @$(CXX) $(CXXFLAGS) -c $< -o $@ + @$(CXX) -MMD -MF $*.d $(CXXFLAGS) -c $< -o $@ $(PRECOMPILED_HEADERS): $(HEADERS) diff --git a/Release/tests/Functional/http/client/Makefile b/Release/tests/Functional/http/client/Makefile index 480535ee01..d823fca4e1 100644 --- a/Release/tests/Functional/http/client/Makefile +++ b/Release/tests/Functional/http/client/Makefile @@ -37,6 +37,8 @@ $(OUTPUT_DIR)/httpclient_test.so: $(OBJECTS) @echo "Building library $@" @$(CXX) -fPIC -shared $(CXXFLAGS) $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) $^ $(LDLIBS) -o $@ +-include *.$(MODE).d + $(OBJECTS): %.$(MODE).o: %.cpp @echo "Compiling $< -> $@" - @$(CXX) -fPIC $(CXXFLAGS) -c $< -o $@ \ No newline at end of file + @$(CXX) -fPIC $(CXXFLAGS) -MMD -MF $*.$(MODE).d -c $< -o $@ \ No newline at end of file diff --git a/Release/tests/Functional/http/listener/Makefile b/Release/tests/Functional/http/listener/Makefile index 6250fa7167..f9f30b9b62 100644 --- a/Release/tests/Functional/http/listener/Makefile +++ b/Release/tests/Functional/http/listener/Makefile @@ -27,6 +27,8 @@ $(OUTPUT_DIR)/httplistener_test.so: $(OBJECTS) @echo "Building library $@" @$(CXX) -fPIC -shared $(CXXFLAGS) $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) $^ $(LDLIBS) -o $@ +-include *.$(MODE).d + $(OBJECTS): %.$(MODE).o: %.cpp @echo "Compiling $< -> $@" - @$(CXX) -fPIC $(CXXFLAGS) -c $< -o $@ \ No newline at end of file + @$(CXX) -fPIC $(CXXFLAGS) -MMD -MF $*.$(MODE).d -c $< -o $@ \ No newline at end of file diff --git a/Release/tests/Functional/http/utilities/Makefile b/Release/tests/Functional/http/utilities/Makefile index b1bc55c508..9661c4afbd 100644 --- a/Release/tests/Functional/http/utilities/Makefile +++ b/Release/tests/Functional/http/utilities/Makefile @@ -4,9 +4,11 @@ LDLIBS=-lcasablanca -lunittestpp -lboost_system -lboost_thread -lboost_locale -l OUTPUT_DIR?=./$(MODE) -$(OUTPUT_DIR)/libhttptest_utilities.so: \ +FILENAME = $(OUTPUT_DIR)/libhttptest_utilities + +$(FILENAME).so: \ http_asserts.cpp \ test_http_client.cpp \ test_http_server.cpp \ test_server_utilities.cpp - $(CXX) $(CXXFLAGS) -fPIC -shared $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) $^ $(LDLIBS) -o $@ + $(CXX) $(CXXFLAGS) -fPIC -shared $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) -MMD -MF $(FILENAME).d $(filter %.cpp, $^) $(LDLIBS) -o $@ \ No newline at end of file diff --git a/Release/tests/Functional/json/Makefile b/Release/tests/Functional/json/Makefile index 4f35333c48..2d1e2e4de9 100644 --- a/Release/tests/Functional/json/Makefile +++ b/Release/tests/Functional/json/Makefile @@ -4,7 +4,13 @@ LDLIBS=-lcasablanca -lunittestpp -lboost_system -lboost_thread -lpthread -lstdc+ OUTPUT_DIR?=./$(MODE) -$(OUTPUT_DIR)/json_test.so: construction_tests.cpp negative_parsing_tests.cpp parsing_tests.cpp to_as_and_operators_tests.cpp - $(CXX) -fPIC -shared $(CXXFLAGS) $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) $^ $(LDLIBS) -o $@ +FILENAME = $(OUTPUT_DIR)/json_test + +$(FILENAME).so: \ + construction_tests.cpp \ + negative_parsing_tests.cpp \ + parsing_tests.cpp \ + to_as_and_operators_tests.cpp + $(CXX) -fPIC -shared $(CXXFLAGS) $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) -MMD -MF $(FILENAME).d $(filter %.cpp, $^) $(LDLIBS) -o $@ From c21e4497f7386283ec8e43f98382a597be6d1a70 Mon Sep 17 00:00:00 2001 From: Ognjen Sobajic Date: Thu, 24 Oct 2013 17:32:26 -0700 Subject: [PATCH 2/2] Correcting two makefiles: include dependencies in .d files which have been generated in the previous compilation. --- Release/tests/Functional/http/utilities/Makefile | 2 ++ Release/tests/Functional/json/Makefile | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Release/tests/Functional/http/utilities/Makefile b/Release/tests/Functional/http/utilities/Makefile index 9661c4afbd..6fa79de005 100644 --- a/Release/tests/Functional/http/utilities/Makefile +++ b/Release/tests/Functional/http/utilities/Makefile @@ -6,6 +6,8 @@ OUTPUT_DIR?=./$(MODE) FILENAME = $(OUTPUT_DIR)/libhttptest_utilities +-include $(FILENAME).d + $(FILENAME).so: \ http_asserts.cpp \ test_http_client.cpp \ diff --git a/Release/tests/Functional/json/Makefile b/Release/tests/Functional/json/Makefile index 2d1e2e4de9..33199ebcb6 100644 --- a/Release/tests/Functional/json/Makefile +++ b/Release/tests/Functional/json/Makefile @@ -6,6 +6,8 @@ OUTPUT_DIR?=./$(MODE) FILENAME = $(OUTPUT_DIR)/json_test +-include $(FILENAME).d + $(FILENAME).so: \ construction_tests.cpp \ negative_parsing_tests.cpp \