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 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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=-DNOPCH
  6. DEFS += $(addprefix -I,$(CURDIR) $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
  7. LIBS += $(addprefix -l,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
  8. LMODE = dynamic
  9. LMODE2 = dynamic
  10. ifdef STATIC
  11. LMODE = static
  12. ifeq (${STATIC}, all)
  13. LMODE2 = static
  14. endif
  15. endif
  16. # for boost 1.37, add -mt to the boost libraries
  17. LIBS= \
  18. -Wl,-B$(LMODE) \
  19. -l boost_system$(BOOST_LIB_SUFFIX) \
  20. -l boost_filesystem$(BOOST_LIB_SUFFIX) \
  21. -l boost_program_options$(BOOST_LIB_SUFFIX) \
  22. -l boost_thread$(BOOST_LIB_SUFFIX) \
  23. -l db_cxx$(BDB_LIB_SUFFIX) \
  24. -l ssl \
  25. -l crypto
  26. ifndef USE_UPNP
  27. override USE_UPNP = -
  28. endif
  29. ifneq (${USE_UPNP}, -)
  30. LIBS += -l miniupnpc
  31. DEFS += -DUSE_UPNP=$(USE_UPNP)
  32. endif
  33. ifneq (${USE_SSL}, 0)
  34. DEFS += -DUSE_SSL
  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=-O2
  70. xCXXFLAGS=-pthread -Wextra -Wno-sign-compare -Wno-char-subscripts -Wno-invalid-offsetof -Wformat-security \
  71. $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
  72. OBJS= \
  73. obj/checkpoints.o \
  74. obj/netbase.o \
  75. obj/crypter.o \
  76. obj/key.o \
  77. obj/db.o \
  78. obj/init.o \
  79. obj/irc.o \
  80. obj/keystore.o \
  81. obj/main.o \
  82. obj/net.o \
  83. obj/protocol.o \
  84. obj/bitcoinrpc.o \
  85. obj/rpcdump.o \
  86. obj/script.o \
  87. obj/util.o \
  88. obj/wallet.o
  89. all: bitcoind
  90. # auto-generated dependencies:
  91. -include obj/*.P
  92. -include obj/test/*.P
  93. obj/%.o: %.cpp
  94. $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
  95. @cp $(@:%.o=%.d) $(@:%.o=%.P); \
  96. sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
  97. -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
  98. rm -f $(@:%.o=%.d)
  99. bitcoind: $(OBJS:obj/%=obj/%)
  100. $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
  101. TESTOBJS := $(patsubst test/%.cpp,obj/test/%.o,$(wildcard test/*.cpp))
  102. obj/test/%.o: test/%.cpp
  103. $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
  104. @cp $(@:%.o=%.d) $(@:%.o=%.P); \
  105. sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
  106. -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
  107. rm -f $(@:%.o=%.d)
  108. test_bitcoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
  109. $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
  110. clean:
  111. -rm -f bitcoind test_bitcoin
  112. -rm -f obj/*.o
  113. -rm -f obj/test/*.o
  114. -rm -f obj/*.P
  115. -rm -f obj/test/*.P