Skip to content

Commit 4ffbdcc

Browse files
committed
Auto-build dependencies
1 parent e9e7bb9 commit 4ffbdcc

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/makefile.unix

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,26 @@ OBJS= \
101101

102102
all: bitcoind
103103

104+
# auto-generated dependencies:
105+
-include obj/nogui/*.P
106+
-include obj/test/*.P
104107

105-
obj/nogui/%.o: %.cpp $(HEADERS)
106-
$(CXX) -c $(CXXFLAGS) -o $@ $<
108+
obj/nogui/%.o: %.cpp
109+
$(CXX) -c $(CXXFLAGS) -MMD -o $@ $<
110+
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
111+
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
112+
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
113+
rm -f $(@:%.o=%.d)
107114

108115
bitcoind: $(OBJS:obj/%=obj/nogui/%)
109116
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
110117

111-
obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS)
112-
$(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp
118+
obj/test/%.o: test/%.cpp
119+
$(CXX) -c $(CXXFLAGS) -MMD -o $@ $<
120+
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
121+
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
122+
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
123+
rm -f $(@:%.o=%.d)
113124

114125
test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
115126
$(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LIBS)
@@ -119,4 +130,6 @@ clean:
119130
-rm -f obj/*.o
120131
-rm -f obj/nogui/*.o
121132
-rm -f obj/test/*.o
122-
-rm -f headers.h.gch
133+
-rm -f obj/*.P
134+
-rm -f obj/nogui/*.P
135+
-rm -f obj/test/*.P

0 commit comments

Comments
 (0)