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 DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
12 LIBS += $(addprefix -l,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
23 # for boost 1.37, add -mt to the boost libraries
26 -l boost_system$(BOOST_LIB_SUFFIX) \
27 -l boost_filesystem$(BOOST_LIB_SUFFIX) \
28 -l boost_program_options$(BOOST_LIB_SUFFIX) \
29 -l boost_thread$(BOOST_LIB_SUFFIX) \
30 -l db_cxx$(BDB_LIB_SUFFIX) \
37 ifneq (${USE_UPNP}, -)
39 DEFS += -DUSE_UPNP=$(USE_UPNP)
54 # Make some classes of vulnerabilities unexploitable in case one is discovered.
57 # Put numbers at the beginning of each stack frame and check that they are the same.
58 # If a stack buffer if overflowed, it writes over the canary number and then on return
59 # when that number is checked, it won't be the same and the program will exit with
60 # a "Stack smashing detected" error instead of being exploited.
61 HARDENING=-fstack-protector-all -Wstack-protector
63 # Make some important things such as the global offset table read only as soon as
64 # the dynamic linker is finished building it. This will prevent overwriting of addresses
65 # which would later be jumped to.
66 HARDENING+=-Wl,-z,relro -Wl,-z,now
68 # Build position independent code to take advantage of Address Space Layout Randomization
69 # offered by some kernels.
70 # see doc/build-unix.txt for more information.
75 # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
76 # the source such overflowing a statically defined buffer.
77 HARDENING+=-D_FORTIFY_SOURCE=2
82 CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING)
122 # auto-generated dependencies:
123 -include obj/nogui/*.P
124 -include obj/test/*.P
127 $(CXX) -c $(CXXFLAGS) -MMD -o $@ $<
128 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
129 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
130 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
133 bitcoind: $(OBJS:obj/%=obj/nogui/%)
134 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
136 obj/test/%.o: test/%.cpp
137 $(CXX) -c $(CXXFLAGS) -MMD -o $@ $<
138 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
139 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
140 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
143 test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
144 $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LIBS)
147 -rm -f bitcoind test_bitcoin