Skip to content

Commit 4fd7e06

Browse files
committed
add automatic dependency generation
1 parent 8b4956b commit 4fd7e06

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ SRC = src/colord
44

55
ifeq ($(UNAME_S),Darwin)
66
CXX = /usr/local/bin/g++-10
7-
CFLAGS = -Wall -O3 -std=c++17 -static-libgcc -static-libstdc++ -pthread
7+
CFLAGS = -Wall -O3 -std=c++17 -MP -MMD -static-libgcc -static-libstdc++ -pthread
88
CLINK = -Wall -O3 -std=c++17 -static-libgcc -static-libstdc++ -lpthread
99

1010
CFLAGS_KMC = -Wall -O3 -m64 -static-libgcc -static-libstdc++ -fopenmp -pthread -std=c++11
1111
CLINK_KMC = -lm -fopenmp -static-libgcc -static-libstdc++ -O3 -pthread -std=c++11
1212

1313
else
14-
CFLAGS = -Wall -O3 -std=c++17 -static -Wl,--whole-archive -lstdc++fs -lpthread -Wl,--no-whole-archive
14+
CFLAGS = -Wall -O3 -std=c++17 -MP -MMD -static -Wl,--whole-archive -lstdc++fs -lpthread -Wl,--no-whole-archive
1515
CLINK = -Wall -O3 -std=c++17 -static -Wl,--whole-archive -lstdc++fs -lpthread -Wl,--no-whole-archive
1616

1717
CFLAGS_KMC = -Wall -O3 -m64 -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -std=c++11
@@ -104,6 +104,12 @@ $(SRC)/../API_example/api_example.o: $(SRC)/../API_example/api_example.cpp
104104
$(SRC)/../API/colord_api.o: $(SRC)/../API/colord_api.cpp
105105
$(CXX) $(CFLAGS) -I $(SRC)/../colord -c $< -o $@
106106

107+
# ====================================================================
108+
# automatically generated dependency files for CoLoRd and KMC objects
109+
OBJS_TO_GEN_DEPS = $(OBJS) $(OBJS_COMMON) $(COBJS) $(SRC)/../API_example/api_example.o $(SRC)/../API/colord_api.o
110+
DEPENDENCY_FILES = $(subst .o,.d,$(OBJS_TO_GEN_DEPS))
111+
-include $(DEPENDENCY_FILES)
112+
107113
$(BIN_DIR)/api_example: $(SRC)/../API_example/api_example.o $(BIN_DIR)/libcolord_api.a
108114
-mkdir -p $(BIN_DIR)
109115
$(CXX) $(CLINK) -o $@ $^ $(LIB_ZLIB)
@@ -170,6 +176,7 @@ clean:
170176
-rm -f $(LIB_FILTERING_KMC)
171177
-rm -f $(SRC)/../API/colord_api.o $(SRC)/../API_example/api_example.o
172178
-rm -f $(COBJS)
179+
-rm -f $(DEPENDENCY_FILES)
173180
-rm -rf bin
174181
-rm -rf include
175182

0 commit comments

Comments
 (0)