1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Copyright (c) 2011 The PPCoin developers
3 # Distributed under the MIT/X11 software license, see the accompanying
4 # file license.txt or http://www.opensource.org/licenses/mit-license.php.
8 DEFS=-DBOOST_SPIRIT_THREADSAFE
10 DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
11 LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
13 TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
23 TESTDEFS += -DBOOST_TEST_DYN_LINK
26 # for boost 1.37, add -mt to the boost libraries
29 -l boost_system$(BOOST_LIB_SUFFIX) \
30 -l boost_filesystem$(BOOST_LIB_SUFFIX) \
31 -l boost_program_options$(BOOST_LIB_SUFFIX) \
32 -l boost_thread$(BOOST_LIB_SUFFIX) \
33 -l db_cxx$(BDB_LIB_SUFFIX) \
40 ifneq (${USE_UPNP}, -)
42 DEFS += -DUSE_UPNP=$(USE_UPNP)
53 # Make some classes of vulnerabilities unexploitable in case one is discovered.
55 # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
56 # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
57 # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
58 HARDENING=-fno-stack-protector
61 # Put numbers at the beginning of each stack frame and check that they are the same.
62 # If a stack buffer if overflowed, it writes over the canary number and then on return
63 # when that number is checked, it won't be the same and the program will exit with
64 # a "Stack smashing detected" error instead of being exploited.
65 HARDENING+=-fstack-protector-all -Wstack-protector
67 # Make some important things such as the global offset table read only as soon as
68 # the dynamic linker is finished building it. This will prevent overwriting of addresses
69 # which would later be jumped to.
70 HARDENING+=-Wl,-z,relro -Wl,-z,now
72 # Build position independent code to take advantage of Address Space Layout Randomization
73 # offered by some kernels.
74 # see doc/build-unix.txt for more information.
79 # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
80 # the source such overflowing a statically defined buffer.
81 HARDENING+=-D_FORTIFY_SOURCE=2
87 xCXXFLAGS=-pthread -Wall -Wextra -Wno-sign-compare -Wno-invalid-offsetof -Wno-unused-parameter -Wformat -Wformat-security \
88 $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
115 # auto-generated dependencies:
117 -include obj-test/*.P
120 /bin/sh ../share/genbuild.sh obj/build.h
121 version.cpp: obj/build.h
122 DEFS += -DHAVE_BUILD_INFO
125 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
126 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
127 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
128 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
131 ppcoind: $(OBJS:obj/%=obj/%)
132 $(CXX) $(xCXXFLAGS) -rdynamic -o $@ $^ $(LDFLAGS) $(LIBS)
134 TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
136 obj-test/%.o: test/%.cpp
137 $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -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_ppcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
144 $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
147 -rm -f ppcoind test_ppcoin genesis
155 ppcoin/obj/genesis.o: ppcoin/genesis.cpp
156 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
157 $(CXX) -c $(xCXXFLAGS) -MMD -DPPCOIN_GENESIS -o obj/nogui/init.o init.cpp
159 genesis: ppcoin/obj/genesis.o $(OBJS:obj/%=obj/nogui/%)
160 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
162 -rm -f ppcoin/obj/genesis.*