1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Copyright (c) 2011-2012 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
9 BOOST_INCLUDE_PATH=/usr/local/include
10 BDB_INCLUDE_PATH=/usr/local/include/db48
11 BOOST_LIB_PATH=/usr/local/lib
12 BDB_LIB_PATH=/usr/local/lib/db48
14 DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
15 LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
17 TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
27 TESTDEFS += -DBOOST_TEST_DYN_LINK
30 # for boost 1.37, add -mt to the boost libraries
33 -l boost_system$(BOOST_LIB_SUFFIX) \
34 -l boost_filesystem$(BOOST_LIB_SUFFIX) \
35 -l boost_program_options$(BOOST_LIB_SUFFIX) \
36 -l boost_thread$(BOOST_LIB_SUFFIX) \
37 -l db_cxx$(BDB_LIB_SUFFIX) \
44 ifneq (${USE_UPNP}, -)
46 DEFS += -DUSE_UPNP=$(USE_UPNP)
56 # Make some classes of vulnerabilities unexploitable in case one is discovered.
58 # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
59 # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
60 # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
61 HARDENING=-fno-stack-protector
64 # Put numbers at the beginning of each stack frame and check that they are the same.
65 # If a stack buffer if overflowed, it writes over the canary number and then on return
66 # when that number is checked, it won't be the same and the program will exit with
67 # a "Stack smashing detected" error instead of being exploited.
68 HARDENING+=-fstack-protector-all -Wstack-protector
70 # Make some important things such as the global offset table read only as soon as
71 # the dynamic linker is finished building it. This will prevent overwriting of addresses
72 # which would later be jumped to.
73 HARDENING+=-Wl,-z,relro -Wl,-z,now
75 # Build position independent code to take advantage of Address Space Layout Randomization
76 # offered by some kernels.
77 # see doc/build-unix.txt for more information.
82 # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
83 # the source such overflowing a statically defined buffer.
84 HARDENING+=-D_FORTIFY_SOURCE=2
90 xCXXFLAGS=-pthread -Wall -Wextra -Wno-sign-compare -Wno-invalid-offsetof -Wno-unused-parameter -Wformat -Wformat-security \
91 $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
122 # auto-generated dependencies:
124 -include obj-test/*.P
127 /bin/sh ../share/genbuild.sh obj/build.h
128 version.cpp: obj/build.h
129 DEFS += -DHAVE_BUILD_INFO
132 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
133 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
134 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
135 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
138 obj/scrypt-x86.o: scrypt-x86.S
139 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
141 obj/scrypt-x86_64.o: scrypt-x86_64.S
142 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
144 novacoind: $(OBJS:obj/%=obj/%)
145 $(CXX) $(xCXXFLAGS) -rdynamic -o $@ $^ $(LDFLAGS) $(LIBS)
147 TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
149 obj-test/%.o: test/%.cpp
150 $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $<
151 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
152 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
153 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
156 test_novacoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
157 $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
160 -rm -f novacoind test_novacoin