raw
genesis                 1 # Copyright (c) 2009-2010 Satoshi Nakamoto
genesis 2 # Distributed under the MIT/X11 software license, see the accompanying
genesis 3 # file license.txt or http://www.opensource.org/licenses/mit-license.php.
genesis 4
genesis 5 DEFS=-DNOPCH
genesis 6
genesis 7 DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
genesis 8 LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
genesis 9
genesis 10 LMODE = dynamic
genesis 11 LMODE2 = dynamic
genesis 12 ifdef STATIC
genesis 13 LMODE = static
genesis 14 ifeq (${STATIC}, all)
genesis 15 LMODE2 = static
genesis 16 endif
genesis 17 else
genesis 18 TESTDEFS += -DBOOST_TEST_DYN_LINK
genesis 19 endif
genesis 20
genesis 21 # for boost 1.37, add -mt to the boost libraries
genesis 22 LIBS += \
genesis 23 -Wl,-B$(LMODE) \
genesis 24 -l boost_system$(BOOST_LIB_SUFFIX) \
genesis 25 -l boost_filesystem$(BOOST_LIB_SUFFIX) \
genesis 26 -l boost_program_options$(BOOST_LIB_SUFFIX) \
genesis 27 -l boost_thread$(BOOST_LIB_SUFFIX) \
genesis 28 -l db_cxx$(BDB_LIB_SUFFIX) \
genesis 29 -l ssl \
bitcoin-v0_5_3_1-... 30 -l crypto \
bitcoin-v0_5_3_1-... 31 -static-libgcc
genesis 32
genesis 33 LIBS+= \
genesis 34 -Wl,-B$(LMODE2) \
genesis 35 -l pthread
genesis 36
genesis 37
genesis 38 # Hardening
genesis 39 # Make some classes of vulnerabilities unexploitable in case one is discovered.
genesis 40 #
genesis 41 # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
genesis 42 # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
genesis 43 # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
genesis 44 HARDENING=-fno-stack-protector
genesis 45
genesis 46 # Stack Canaries
genesis 47 # Put numbers at the beginning of each stack frame and check that they are the same.
genesis 48 # If a stack buffer if overflowed, it writes over the canary number and then on return
genesis 49 # when that number is checked, it won't be the same and the program will exit with
genesis 50 # a "Stack smashing detected" error instead of being exploited.
genesis 51 HARDENING+=-fstack-protector-all -Wstack-protector
genesis 52
genesis 53 # Make some important things such as the global offset table read only as soon as
genesis 54 # the dynamic linker is finished building it. This will prevent overwriting of addresses
genesis 55 # which would later be jumped to.
genesis 56 HARDENING+=-Wl,-z,relro -Wl,-z,now
genesis 57
genesis 58 # Build position independent code to take advantage of Address Space Layout Randomization
genesis 59 # offered by some kernels.
genesis 60 # see doc/build-unix.txt for more information.
genesis 61 ifdef PIE
genesis 62 HARDENING+=-fPIE -pie
genesis 63 endif
genesis 64
genesis 65 # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
genesis 66 # the source such overflowing a statically defined buffer.
genesis 67 HARDENING+=-D_FORTIFY_SOURCE=2
genesis 68 #
genesis 69
genesis 70
genesis 71 DEBUGFLAGS=-g
genesis 72 CXXFLAGS=-O2
genesis 73 xCXXFLAGS=-pthread -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
genesis 74 HEADERS = \
genesis 75 base58.h \
genesis 76 bignum.h \
genesis 77 checkpoints.h \
genesis 78 crypter.h \
genesis 79 db.h \
genesis 80 headers.h \
genesis 81 init.h \
genesis 82 key.h \
genesis 83 keystore.h \
programmable-vers... 84 knobs.h \
genesis 85 main.h \
genesis 86 net.h \
genesis 87 noui.h \
genesis 88 protocol.h \
genesis 89 bitcoinrpc.h \
genesis 90 script.h \
genesis 91 serialize.h \
genesis 92 strlcpy.h \
genesis 93 uint256.h \
genesis 94 util.h \
genesis 95 wallet.h
genesis 96
genesis 97 OBJS= \
genesis 98 obj/checkpoints.o \
genesis 99 obj/crypter.o \
genesis 100 obj/db.o \
genesis 101 obj/init.o \
genesis 102 obj/keystore.o \
genesis 103 obj/main.o \
genesis 104 obj/net.o \
genesis 105 obj/protocol.o \
genesis 106 obj/bitcoinrpc.o \
genesis 107 obj/script.o \
genesis 108 obj/util.o \
genesis 109 obj/wallet.o
genesis 110
genesis 111
genesis 112 all: bitcoind
genesis 113
genesis 114 # auto-generated dependencies:
genesis 115 -include obj/nogui/*.P
genesis 116 -include obj-test/*.P
genesis 117
genesis 118 obj/nogui/%.o: %.cpp
genesis 119 $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
genesis 120 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
genesis 121 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
genesis 122 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
genesis 123 rm -f $(@:%.o=%.d)
genesis 124
genesis 125 bitcoind: $(OBJS:obj/%=obj/nogui/%)
genesis 126 $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
genesis 127
genesis 128 obj-test/%.o: test/%.cpp
genesis 129 $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $<
genesis 130 @cp $(@:%.o=%.d) $(@:%.o=%.P); \
genesis 131 sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
genesis 132 -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
genesis 133 rm -f $(@:%.o=%.d)
genesis 134
genesis 135 test_bitcoin: obj-test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
genesis 136 $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
genesis 137
genesis 138 clean:
genesis 139 -rm -f bitcoind test_bitcoin
genesis 140 -rm -f obj/*.o
genesis 141 -rm -f obj/nogui/*.o
genesis 142 -rm -f obj-test/*.o
genesis 143 -rm -f obj/*.P
genesis 144 -rm -f obj/nogui/*.P
genesis 145 -rm -f obj-test/*.P