1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Distributed under the MIT/X11 software license, see the accompanying
3 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
9 ARCH:=$(system lscpu | head -n 1 | awk '{print $2}')
11 DEFS=-DBOOST_SPIRIT_THREADSAFE
13 DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
14 LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
25 # for boost 1.37, add -mt to the boost libraries
28 -l boost_system$(BOOST_LIB_SUFFIX) \
29 -l boost_filesystem$(BOOST_LIB_SUFFIX) \
30 -l boost_program_options$(BOOST_LIB_SUFFIX) \
31 -l boost_thread$(BOOST_LIB_SUFFIX) \
32 -l db_cxx$(BDB_LIB_SUFFIX) \
39 ifneq (${USE_UPNP}, -)
41 DEFS += -DUSE_UPNP=$(USE_UPNP)
44 ifneq (${USE_IPV6}, -)
45 DEFS += -DUSE_IPV6=$(USE_IPV6)
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 LDHARDENING+=-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.
83 # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
84 # the source such overflowing a statically defined buffer.
85 HARDENING+=-D_FORTIFY_SOURCE=2
97 # CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only
98 # adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.
99 xCXXFLAGS=-O2 $(EXT_OPTIONS) -pthread -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter \
100 $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
102 # LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only
103 # adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work.
104 xLDFLAGS=$(LDHARDENING) $(LDFLAGS)
127 obj/rpcblockchain.o \
128 obj/rpcrawtransaction.o \
138 obj/zerocoin/Accumulator.o \
139 obj/zerocoin/AccumulatorProofOfKnowledge.o \
140 obj/zerocoin/Coin.o \
141 obj/zerocoin/CoinSpend.o \
142 obj/zerocoin/Commitment.o \
143 obj/zerocoin/ParamGeneration.o \
144 obj/zerocoin/Params.o \
145 obj/zerocoin/SerialNumberSignatureOfKnowledge.o \
146 obj/zerocoin/SpendMetaData.o \
147 obj/zerocoin/ZeroTest.o
154 ifeq (${USE_LEVELDB}, 1)
155 LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
156 DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) -DUSE_LEVELDB
157 DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
158 OBJS += obj/txdb-leveldb.o
159 leveldb/libleveldb.a:
160 @echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd ..;
161 obj/txdb-leveldb.o: leveldb/libleveldb.a
163 ifneq (${USE_LEVELDB}, 1)
164 OBJS += obj/txdb-bdb.o
168 OBJS += obj/scrypt-arm.o obj/scrypt-x86.o obj/scrypt-x86_64.o
170 obj/scrypt-x86.o: scrypt-x86.S
171 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
173 obj/scrypt-x86_64.o: scrypt-x86_64.S
174 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
176 obj/scrypt-arm.o: scrypt-arm.S
177 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
179 ifneq (${USE_ASM}, 1)
180 OBJS += obj/scrypt-generic.o
182 obj/scrypt-generic.o: scrypt-generic.c
183 $(CC) -c $(xCXXFLAGS) -MMD -o $@ $<
186 # auto-generated dependencies:
190 /bin/sh ../share/genbuild.sh obj/build.h
191 version.cpp: obj/build.h
192 DEFS += -DHAVE_BUILD_INFO
196 $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
197 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
198 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
199 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
202 obj/zerocoin/%.o: zerocoin/%.cpp
203 $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
204 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
205 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
206 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
209 novacoind: $(OBJS:obj/%=obj/%)
210 $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)
215 -rm -f obj/zerocoin/*.o
217 -rm -f obj/zerocoin/*.P