Makefile.linux 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # set defaults instead redefine
  2. CXXFLAGS ?= ${CXX_DEBUG} -Wall -Wextra -Wno-unused-parameter -pedantic -Wno-misleading-indentation
  3. LDFLAGS ?= ${LD_DEBUG}
  4. ## NOTE: The NEEDED_CXXFLAGS are here so that custom CXXFLAGS can be specified at build time
  5. ## **without** overwriting the CXXFLAGS which we need in order to build.
  6. ## For example, when adding 'hardening flags' to the build
  7. ## (e.g. -fstack-protector-strong -Wformat -Werror=format-security), we do not want to remove
  8. ## -std=c++11. If you want to remove this variable please do so in a way that allows setting
  9. ## custom FDLAGS to work at build-time.
  10. # detect proper flag for c++11 support by compilers
  11. CXXVER := $(shell $(CXX) -dumpversion)
  12. ifeq ($(shell expr match $(CXX) 'clang'),5)
  13. NEEDED_CXXFLAGS += -std=c++11
  14. else ifeq ($(shell expr match ${CXXVER} "4\.[0-9][0-9]"),4) # gcc >= 4.10
  15. NEEDED_CXXFLAGS += -std=c++11
  16. else ifeq ($(shell expr match ${CXXVER} "4\.[7-9]"),3) # >= 4.7
  17. NEEDED_CXXFLAGS += -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1
  18. else ifeq ($(shell expr match ${CXXVER} "4\.6"),3) # = 4.6
  19. NEEDED_CXXFLAGS += -std=c++0x
  20. else ifeq ($(shell expr match ${CXXVER} "[5-9]"),1) # gcc >= 5
  21. NEEDED_CXXFLAGS += -std=c++11
  22. LDLIBS = -latomic
  23. else # not supported
  24. $(error Compiler too old)
  25. endif
  26. NEEDED_CXXFLAGS += -fPIC
  27. ifeq ($(USE_STATIC),yes)
  28. # NOTE: on glibc you will get this warning:
  29. # Using 'getaddrinfo' in statically linked applications requires at runtime
  30. # the shared libraries from the glibc version used for linking
  31. LIBDIR := /usr/lib
  32. LDLIBS += $(LIBDIR)/libboost_system.a
  33. LDLIBS += $(LIBDIR)/libboost_date_time.a
  34. LDLIBS += $(LIBDIR)/libboost_filesystem.a
  35. LDLIBS += $(LIBDIR)/libboost_program_options.a
  36. LDLIBS += $(LIBDIR)/libssl.a
  37. LDLIBS += $(LIBDIR)/libcrypto.a
  38. LDLIBS += $(LIBDIR)/libz.a
  39. LDLIBS += -lpthread -static-libstdc++ -static-libgcc -lrt -ldl
  40. USE_AESNI := no
  41. else
  42. LDLIBS += -lcrypto -lssl -lz -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread
  43. endif
  44. # UPNP Support (miniupnpc 1.5 and higher)
  45. ifeq ($(USE_UPNP),yes)
  46. CXXFLAGS += -DUSE_UPNP
  47. ifeq ($(USE_STATIC),yes)
  48. LDLIBS += $(LIBDIR)/libminiupnpc.a
  49. else
  50. LDLIBS += -lminiupnpc
  51. endif
  52. endif
  53. ifeq ($(USE_AESNI),yes)
  54. #check if AES-NI is supported by CPU
  55. ifneq ($(shell $(GREP) -c aes /proc/cpuinfo),0)
  56. machine := $(shell uname -m)
  57. ifeq ($(machine), aarch64)
  58. CXXFLAGS += -DARM64AES
  59. else
  60. CPU_FLAGS += -maes
  61. endif
  62. endif
  63. endif
  64. ifeq ($(USE_AVX),yes)
  65. #check if AVX supported by CPU
  66. ifneq ($(shell $(GREP) -c avx /proc/cpuinfo),0)
  67. CPU_FLAGS += -mavx
  68. endif
  69. endif