makefile.bsd 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. # ECOin - Copyright (c) - 2014/2022 - GPLv3 - epsylon@riseup.net (https://03c8.net)
  2. USE_UPNP:=0
  3. USE_IPV6:=1
  4. LINK:=$(CXX)
  5. DEFS=-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. 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_chrono$(BOOST_LIB_SUFFIX) \
  23. -l boost_thread$(BOOST_LIB_SUFFIX) \
  24. -l db_cxx$(BDB_LIB_SUFFIX) \
  25. -l ssl \
  26. -l crypto \
  27. -l execinfo
  28. ifndef USE_UPNP
  29. override USE_UPNP = -
  30. endif
  31. ifneq (${USE_UPNP}, -)
  32. LIBS += -l miniupnpc
  33. DEFS += -DUSE_UPNP=$(USE_UPNP)
  34. endif
  35. ifneq (${USE_IPV6}, -)
  36. DEFS += -DUSE_IPV6=$(USE_IPV6)
  37. endif
  38. LIBS+= \
  39. -Wl,-B$(LMODE2) \
  40. -l z \
  41. -l dl \
  42. -l pthread
  43. # Hardening
  44. # Make some classes of vulnerabilities unexploitable in case one is discovered.
  45. #
  46. # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
  47. # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
  48. # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
  49. HARDENING=-fno-stack-protector
  50. # Stack Canaries
  51. # Put numbers at the beginning of each stack frame and check that they are the same.
  52. # If a stack buffer if overflowed, it writes over the canary number and then on return
  53. # when that number is checked, it won't be the same and the program will exit with
  54. # a "Stack smashing detected" error instead of being exploited.
  55. HARDENING+=-fstack-protector-all -Wstack-protector
  56. # Make some important things such as the global offset table read only as soon as
  57. # the dynamic linker is finished building it. This will prevent overwriting of addresses
  58. # which would later be jumped to.
  59. LDHARDENING+=-Wl,-z,relro -Wl,-z,now
  60. # Build position independent code to take advantage of Address Space Layout Randomization
  61. # offered by some kernels.
  62. # see doc/build-unix.txt for more information.
  63. ifdef PIE
  64. HARDENING+=-fPIE
  65. LDHARDENING+=-pie
  66. endif
  67. # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
  68. # the source such overflowing a statically defined buffer.
  69. HARDENING+=-D_FORTIFY_SOURCE=2
  70. #
  71. DEBUGFLAGS=-g
  72. # CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only
  73. # adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work.
  74. xCXXFLAGS=-O0 -msse2 -pthread -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter \
  75. $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
  76. # LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only
  77. # adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work.
  78. xLDFLAGS=$(LDHARDENING) $(LDFLAGS)
  79. OBJS= \
  80. obj/alert.o \
  81. obj/version.o \
  82. obj/checkpoints.o \
  83. obj/netbase.o \
  84. obj/addrman.o \
  85. obj/crypter.o \
  86. obj/key.o \
  87. obj/db.o \
  88. obj/init.o \
  89. obj/irc.o \
  90. obj/keystore.o \
  91. obj/main.o \
  92. obj/miner.o \
  93. obj/net.o \
  94. obj/protocol.o \
  95. obj/ecoinrpc.o \
  96. obj/rpcdump.o \
  97. obj/rpcnet.o \
  98. obj/rpcmining.o \
  99. obj/rpcwallet.o \
  100. obj/rpcblockchain.o \
  101. obj/rpcrawtransaction.o \
  102. obj/script.o \
  103. obj/sync.o \
  104. obj/util.o \
  105. obj/wallet.o \
  106. obj/walletdb.o \
  107. obj/noui.o \
  108. obj/kernel.o \
  109. obj/pbkdf2.o \
  110. obj/scrypt.o \
  111. obj/scrypt-arm.o \
  112. obj/scrypt-x86.o \
  113. obj/scrypt-x86_64.o \
  114. obj/zerocoin/Accumulator.o \
  115. obj/zerocoin/AccumulatorProofOfKnowledge.o \
  116. obj/zerocoin/Coin.o \
  117. obj/zerocoin/CoinSpend.o \
  118. obj/zerocoin/Commitment.o \
  119. obj/zerocoin/ParamGeneration.o \
  120. obj/zerocoin/Params.o \
  121. obj/zerocoin/SerialNumberSignatureOfKnowledge.o \
  122. obj/zerocoin/SpendMetaData.o \
  123. obj/zerocoin/ZeroTest.o
  124. all: ecoind
  125. LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
  126. DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
  127. DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
  128. OBJS += obj/txdb-leveldb.o
  129. leveldb/libleveldb.a:
  130. @echo "Building LevelDB ..."; cd leveldb; make libleveldb.a libmemenv.a; cd ..;
  131. obj/txdb-leveldb.o: leveldb/libleveldb.a
  132. # auto-generated dependencies:
  133. -include obj/*.P
  134. obj/build.h: FORCE
  135. /bin/sh ../share/genbuild.sh obj/build.h
  136. version.cpp: obj/build.h
  137. DEFS += -DHAVE_BUILD_INFO
  138. obj/scrypt-x86.o: scrypt-x86.S
  139. $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
  140. obj/scrypt-x86_64.o: scrypt-x86_64.S
  141. $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
  142. obj/scrypt-arm.o: scrypt-arm.S
  143. $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
  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. obj/zerocoin/%.o: zerocoin/%.cpp
  151. $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
  152. @cp $(@:%.o=%.d) $(@:%.o=%.P); \
  153. sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
  154. -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
  155. rm -f $(@:%.o=%.d)
  156. ecoind: $(OBJS:obj/%=obj/%)
  157. $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS)
  158. clean:
  159. -rm -f ecoind
  160. -rm -f obj/*.o
  161. -rm -f obj/zerocoin/*.o
  162. -rm -f obj/*.P
  163. -rm -f obj/zerocoin/*.P
  164. -rm -f obj/build.h
  165. FORCE: