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