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.
12 ARCH:=$(shell uname -m)
14 DEFS=-DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
16 DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH) $(CURDIR)/additional/stage/usr/include)
17 LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH) $(CURDIR)/additional/stage/usr/lib)
28 # for boost 1.37, add -mt to the boost libraries
31 -l boost_system$(BOOST_LIB_SUFFIX) \
32 -l boost_filesystem$(BOOST_LIB_SUFFIX) \
33 -l boost_program_options$(BOOST_LIB_SUFFIX) \
34 -l boost_thread$(BOOST_LIB_SUFFIX) \
35 -l db_cxx$(BDB_LIB_SUFFIX) \
40 ifneq (${USE_IPV6}, -)
41 DEFS += -DUSE_IPV6=$(USE_IPV6)
52 # Make some classes of vulnerabilities unexploitable in case one is discovered.
54 # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
55 # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
56 # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
57 HARDENING=-fno-stack-protector
60 # Put numbers at the beginning of each stack frame and check that they are the same.
61 # If a stack buffer if overflowed, it writes over the canary number and then on return
62 # when that number is checked, it won't be the same and the program will exit with
63 # a "Stack smashing detected" error instead of being exploited.
64 HARDENING+=-fstack-protector-all -Wstack-protector
66 # Make some important things such as the global offset table read only as soon as
67 # the dynamic linker is finished building it. This will prevent overwriting of addresses
68 # which would later be jumped to.
69 LDHARDENING+=-Wl,-z,relro -Wl,-z,now
71 # Build position independent code to take advantage of Address Space Layout Randomization
72 # offered by some kernels.
73 # 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
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=$(xOPT_LEVEL) $(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)
131 obj/rpcblockchain.o \
132 obj/rpcrawtransaction.o \
140 obj/kernel_worker.o \
150 ifeq (${USE_LEVELDB}, 1)
151 LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
152 DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) -DUSE_LEVELDB
153 DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
154 OBJS += obj/txdb-leveldb.o
155 leveldb/libleveldb.a:
156 @echo "Building LevelDB ..."; cd leveldb; CC=$(CC) CXX=$(CXX) make libleveldb.a libmemenv.a; cd ..;
157 obj/txdb-leveldb.o: leveldb/libleveldb.a
159 ifneq (${USE_LEVELDB}, 1)
160 OBJS += obj/txdb-bdb.o
164 # Assembler implementation
165 OBJS += crypto/scrypt/asm/obj/scrypt-arm.o crypto/scrypt/asm/obj/scrypt-x86.o crypto/scrypt/asm/obj/scrypt-x86_64.o crypto/scrypt/asm/obj/asm-wrapper.o
167 crypto/scrypt/asm/obj/scrypt-x86.o: crypto/scrypt/asm/scrypt-x86.S
168 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
170 crypto/scrypt/asm/obj/scrypt-x86_64.o: crypto/scrypt/asm/scrypt-x86_64.S
171 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
173 crypto/scrypt/asm/obj/scrypt-arm.o: crypto/scrypt/asm/scrypt-arm.S
174 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
176 crypto/scrypt/asm/obj/asm-wrapper.o: crypto/scrypt/asm/asm-wrapper.cpp
177 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
182 ifeq (${USE_SSE2}, 1)
183 # Intrinsic implementation
185 OBJS += crypto/scrypt/intrin/obj/scrypt-sse2.o
187 crypto/scrypt/intrin/obj/scrypt-sse2.o: crypto/scrypt/intrin/scrypt-sse2.cpp
188 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
190 # Generic implementation
191 OBJS += crypto/scrypt/generic/obj/scrypt-generic.o
193 crypto/scrypt/generic/obj/scrypt-generic.o: crypto/scrypt/generic/scrypt-generic.cpp
194 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
199 # auto-generated dependencies:
203 /bin/sh ../share/genbuild.sh obj/build.h
204 version.cpp: obj/build.h
205 DEFS += -DHAVE_BUILD_INFO
209 $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
210 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
211 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
212 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
215 novacoind: $(OBJS:obj/%=obj/%)
216 $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)
223 -rm -f crypto/scrypt/asm/obj/*.o
224 -rm -f crypto/scrypt/asm/obj/*.P
225 -rm -f crypto/scrypt/asm/obj/*.d
226 -rm -f crypto/scrypt/intrin/obj/*.o
227 -rm -f crypto/scrypt/intrin/obj/*.P
228 -rm -f crypto/scrypt/intrin/obj/*.d
229 -rm -f crypto/scrypt/generic/obj/*.o
230 -rm -f crypto/scrypt/generic/obj/*.P
231 -rm -f crypto/scrypt/generic/obj/*.d