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 \
140 obj/scrypt-x86_64.o \
141 obj/zerocoin/Accumulator.o \
142 obj/zerocoin/AccumulatorProofOfKnowledge.o \
143 obj/zerocoin/Coin.o \
144 obj/zerocoin/CoinSpend.o \
145 obj/zerocoin/Commitment.o \
146 obj/zerocoin/ParamGeneration.o \
147 obj/zerocoin/Params.o \
148 obj/zerocoin/SerialNumberSignatureOfKnowledge.o \
149 obj/zerocoin/SpendMetaData.o \
150 obj/zerocoin/ZeroTest.o
154 LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
155 DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
156 DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
157 OBJS += obj/txdb-leveldb.o
158 leveldb/libleveldb.a:
159 @echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd ..;
160 obj/txdb-leveldb.o: leveldb/libleveldb.a
162 # auto-generated dependencies:
166 /bin/sh ../share/genbuild.sh obj/build.h
167 version.cpp: obj/build.h
168 DEFS += -DHAVE_BUILD_INFO
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 $@ $<
180 $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
181 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
182 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
183 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
186 obj/zerocoin/%.o: zerocoin/%.cpp
187 $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
188 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
189 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
190 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
193 novacoind: $(OBJS:obj/%=obj/%)
194 $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)
199 -rm -f obj/zerocoin/*.o
201 -rm -f obj/zerocoin/*.P