Skip to content

Commit ccefdf6

Browse files
author
Ognjen Sobajic
committed
Makefiles with autodiscovered .h files dependencies.
1 parent 6f339a8 commit ccefdf6

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

Release/src/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ PCH = ./pch/stdafx.h
6666

6767
PRECOMPILED_HEADERS = $(addsuffix .gch, $(PCH))
6868
OBJECTS = $(addsuffix .$(MODE).o, $(basename $(SOURCES)))
69+
CPP_DEPENDENCIES = $(addsuffix .d, $(basename $(SOURCES)))
6970

7071
# flags for the C++ compiler
7172

@@ -90,9 +91,11 @@ all: $(LIBRARY_DST)
9091
@echo "Building precompiled header $(@)"
9192
@$(CXX) -x c++-header $(CXXFLAGS) -c $< -o $@
9293

94+
-include $(CPP_DEPENDENCIES)
95+
9396
%.$(MODE).o: %.cpp
9497
@echo "Compiling $< -> $@"
95-
@$(CXX) $(CXXFLAGS) -c $< -o $@
98+
@$(CXX) -MMD -MF $*.d $(CXXFLAGS) -c $< -o $@
9699

97100
$(PRECOMPILED_HEADERS): $(HEADERS)
98101

Release/tests/Functional/http/client/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ $(OUTPUT_DIR)/httpclient_test.so: $(OBJECTS)
3737
@echo "Building library $@"
3838
@$(CXX) -fPIC -shared $(CXXFLAGS) $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) $^ $(LDLIBS) -o $@
3939

40+
-include *.$(MODE).d
41+
4042
$(OBJECTS): %.$(MODE).o: %.cpp
4143
@echo "Compiling $< -> $@"
42-
@$(CXX) -fPIC $(CXXFLAGS) -c $< -o $@
44+
@$(CXX) -fPIC $(CXXFLAGS) -MMD -MF $*.$(MODE).d -c $< -o $@

Release/tests/Functional/http/listener/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ $(OUTPUT_DIR)/httplistener_test.so: $(OBJECTS)
2727
@echo "Building library $@"
2828
@$(CXX) -fPIC -shared $(CXXFLAGS) $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) $^ $(LDLIBS) -o $@
2929

30+
-include *.$(MODE).d
31+
3032
$(OBJECTS): %.$(MODE).o: %.cpp
3133
@echo "Compiling $< -> $@"
32-
@$(CXX) -fPIC $(CXXFLAGS) -c $< -o $@
34+
@$(CXX) -fPIC $(CXXFLAGS) -MMD -MF $*.$(MODE).d -c $< -o $@

Release/tests/Functional/http/utilities/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ LDLIBS=-lcasablanca -lunittestpp -lboost_system -lboost_thread -lboost_locale -l
44

55
OUTPUT_DIR?=./$(MODE)
66

7-
$(OUTPUT_DIR)/libhttptest_utilities.so: \
7+
FILENAME = $(OUTPUT_DIR)/libhttptest_utilities
8+
9+
$(FILENAME).so: \
810
http_asserts.cpp \
911
test_http_client.cpp \
1012
test_http_server.cpp \
1113
test_server_utilities.cpp
12-
$(CXX) $(CXXFLAGS) -fPIC -shared $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) $^ $(LDLIBS) -o $@
14+
$(CXX) $(CXXFLAGS) -fPIC -shared $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) -MMD -MF $(FILENAME).d $(filter %.cpp, $^) $(LDLIBS) -o $@

Release/tests/Functional/json/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ LDLIBS=-lcasablanca -lunittestpp -lboost_system -lboost_thread -lpthread -lstdc+
44

55
OUTPUT_DIR?=./$(MODE)
66

7-
$(OUTPUT_DIR)/json_test.so: construction_tests.cpp negative_parsing_tests.cpp parsing_tests.cpp to_as_and_operators_tests.cpp
8-
$(CXX) -fPIC -shared $(CXXFLAGS) $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) $^ $(LDLIBS) -o $@
7+
FILENAME = $(OUTPUT_DIR)/json_test
8+
9+
$(FILENAME).so: \
10+
construction_tests.cpp \
11+
negative_parsing_tests.cpp \
12+
parsing_tests.cpp \
13+
to_as_and_operators_tests.cpp
14+
$(CXX) -fPIC -shared $(CXXFLAGS) $(shell pkg-config libxml++-2.6 --cflags) $(LDFLAGS) -MMD -MF $(FILENAME).d $(filter %.cpp, $^) $(LDLIBS) -o $@
915

1016

0 commit comments

Comments
 (0)