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