Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.
  4. # :=0 --> UPnP support turned off by default at runtime
  5. # :=1 --> UPnP support turned on by default at runtime
  6. # :=- --> No UPnP support - miniupnp not required
  7. USE_UPNP:=0
  8. # :=1 --> Enable IPv6 support
  9. # :=0 --> Disable IPv6 support
  10. USE_IPV6:=1
  11. LINK:=$(CXX)
  12. DEFS=-DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64
  13. DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
  14. LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
  15. TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
  16. LMODE = dynamic
  17. LMODE2 = dynamic
  18. ifdef STATIC
  19. LMODE = static
  20. ifeq (${STATIC}, all)
  21. LMODE2 = static
  22. endif
  23. else
  24. TESTDEFS += -DBOOST_TEST_DYN_LINK
  25. endif
  26. # for boost 1.37, add -mt to the boost libraries
  27. LIBS += \
  28. -Wl,-B$(LMODE) \
  29. -l boost_system$(BOOST_LIB_SUFFIX) \
  30. -l boost_filesystem$(BOOST_LIB_SUFFIX) \
  31. -l boost_program_options$(BOOST_LIB_SUFFIX) \
  32. -l boost_thread$(BOOST_LIB_SUFFIX) \
  33. -l db_cxx$(BDB_LIB_SUFFIX) \
  34. -l ssl \
  35. -l crypto
  36. TESTLIBS += \
  37. -Wl,-B$(LMODE) \
  38. -l boost_unit_test_framework$(BOOST_LIB_SUFFIX)
  39. ifndef USE_UPNP
  40. override USE_UPNP = -
  41. endif
  42. ifneq (${USE_UPNP}, -)
  43. LIBS += -l miniupnpc
  44. DEFS += -DUSE_UPNP=$(USE_UPNP)
  45. endif
  46. ifneq (${USE_IPV6}, -)
  47. DEFS += -DUSE_IPV6=$(USE_IPV6)
  48. endif
  49. LIBS+= \
  50. -Wl,-B$(LMODE2) \
  51. -l z \
  52. -l dl \
  53. -l pthread
  54. # Hardening
  55. # Make some classes of vulnerabilities unexploitable in case one is discovered.
  56. #
  57. # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
  58. # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
  59. # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
  60. HARDENING=-fno-stack-protector
  61. # Stack Canaries
  62. # Put numbers at the beginning of each stack frame and check that they are the same.
  63. # If a stack buffer if overflowed, it writes over the canary number and then on return
  64. # when that number is checked, it won't be the same and the program will exit with
  65. # a "Stack smashing detected" error instead of being exploited.
  66. HARDENING+=-fstack-protector-all -Wstack-protector
  67. # Make some important things such as the global offset table read only as soon as
  68. # the dynamic linker is finished building it. This will prevent overwriting of addresses
  69. # which would later be jumped to.
  70. 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.
  74. ifdef PIE
  75. HARDENING+=-fPIE
  76. LDHARDENING+=-pie
  77. endif
  78. # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
  79. # the source such overflowing a statically defined buffer.
  80. HARDENING+=-D_FORTIFY_SOURCE=2
  81. #
  82. DEBUGFLAGS=-g
  83. # CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only
  84. # adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.
  85. xCXXFLAGS=-O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
  86. $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
  87. # LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only
  88. # adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work.
  89. xLDFLAGS=$(LDHARDENING) $(LDFLAGS)
  90. OBJS= \
  91. leveldb/libleveldb.a \
  92. obj/alert.o \
  93. obj/version.o \
  94. obj/checkpoints.o \
  95. obj/netbase.o \
  96. obj/addrman.o \
  97. obj/crypter.o \
  98. obj/key.o \
  99. obj/db.o \
  100. obj/init.o \
  101. obj/bitcoind.o \
  102. obj/keystore.o \
  103. obj/core.o \
  104. obj/main.o \
  105. obj/net.o \
  106. obj/protocol.o \
  107. obj/bitcoinrpc.o \
  108. obj/rpcdump.o \
  109. obj/rpcnet.o \
  110. obj/rpcmining.o \
  111. obj/rpcwallet.o \
  112. obj/rpcblockchain.o \
  113. obj/rpcrawtransaction.o \
  114. obj/script.o \
  115. obj/sync.o \
  116. obj/util.o \
  117. obj/wallet.o \
  118. obj/walletdb.o \
  119. obj/hash.o \
  120. obj/bloom.o \
  121. obj/noui.o \
  122. obj/leveldb.o \
  123. obj/txdb.o \
  124. obj/chainparams.o
  125. all: bitcoind
  126. test check: test_bitcoin FORCE
  127. ./test_bitcoin
  128. #
  129. # LevelDB support
  130. #
  131. MAKEOVERRIDES =
  132. LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
  133. DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
  134. DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
  135. leveldb/libleveldb.a:
  136. @echo "Building LevelDB ..." && cd leveldb && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" libleveldb.a libmemenv.a && cd ..
  137. # auto-generated dependencies:
  138. -include obj/*.P
  139. -include obj-test/*.P
  140. obj/build.h: FORCE
  141. /bin/sh ../share/genbuild.sh obj/build.h
  142. version.cpp: obj/build.h
  143. DEFS += -DHAVE_BUILD_INFO
  144. obj/%.o: %.cpp
  145. $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
  146. @cp $(@:%.o=%.d) $(@:%.o=%.P); \
  147. sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
  148. -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
  149. rm -f $(@:%.o=%.d)
  150. bitcoind: $(OBJS:obj/%=obj/%)
  151. $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)
  152. TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
  153. obj-test/%.o: test/%.cpp
  154. $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
  155. @cp $(@:%.o=%.d) $(@:%.o=%.P); \
  156. sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
  157. -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
  158. rm -f $(@:%.o=%.d)
  159. test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o obj/bitcoind.o,$(OBJS:obj/%=obj/%))
  160. $(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ $(TESTLIBS) $(xLDFLAGS) $(LIBS)
  161. clean:
  162. -rm -f bitcoind test_bitcoin
  163. -rm -f obj/*.o
  164. -rm -f obj-test/*.o
  165. -rm -f obj/*.P
  166. -rm -f obj-test/*.P
  167. -rm -f obj/build.h
  168. -cd leveldb && $(MAKE) clean || true
  169. FORCE: