You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

makefile.unix 4.4KB

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