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