1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Distributed under the MIT/X11 software license, see the accompanying
3 # file license.txt or http://www.opensource.org/licenses/mit-license.php.
11 # for boost 1.37, add -mt to the boost libraries
16 -l boost_program_options \
24 DEFS += -DUSE_UPNP=$(USE_UPNP)
36 # Make some classes of vulnerabilities unexploitable in case one is discovered.
39 # Put numbers at the beginning of each stack frame and check that they are the same.
40 # If a stack buffer if overflowed, it writes over the canary number and then on return
41 # when that number is checked, it won't be the same and the program will exit with
42 # a "Stack smashing detected" error instead of being exploited.
43 HARDENING=-fstack-protector-all -Wstack-protector
45 # Make some important things such as the global offset table read only as soon as
46 # the dynamic linker is finished building it. This will prevent overwriting of addresses
47 # which would later be jumped to.
48 HARDENING+=-Wl,-z,relro -Wl,-z,now
50 # Build position independent code to take advantage of Address Space Layout Randomization
51 # offered by some kernels.
52 # see doc/build-unix.txt for more information.
57 # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
58 # the source such overflowing a statically defined buffer.
59 HARDENING+=-D_FORTIFY_SOURCE=2
64 CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING)
104 # auto-generated dependencies:
105 -include obj/nogui/*.P
106 -include obj/test/*.P
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); \
115 bitcoind: $(OBJS:obj/%=obj/nogui/%)
116 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
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); \
125 test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
126 $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LIBS)
129 -rm -f bitcoind test_bitcoin