make-linux.mk 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # Pick clang or gcc, with preference for clang
  2. CC=$(shell which clang gcc cc 2>/dev/null | head -n 1)
  3. CXX=$(shell which clang++ g++ c++ 2>/dev/null | head -n 1)
  4. INCLUDES=
  5. DEFS=
  6. LIBS=
  7. include objects.mk
  8. OBJS+=osnet/LinuxRoutingTable.o osnet/LinuxEthernetTap.o osnet/LinuxEthernetTapFactory.o
  9. TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o testnet/TestEthernetTapFactory.o testnet/TestRoutingTable.o
  10. # Enable SSE-optimized Salsa20 on x86 and x86_64 machines
  11. MACHINE=$(shell uname -m)
  12. ifeq ($(MACHINE),x86_64)
  13. DEFS+=-DZT_SALSA20_SSE
  14. endif
  15. ifeq ($(MACHINE),amd64)
  16. DEFS+=-DZT_SALSA20_SSE
  17. endif
  18. ifeq ($(MACHINE),i686)
  19. DEFS+=-DZT_SALSA20_SSE
  20. endif
  21. ifeq ($(MACHINE),i586)
  22. DEFS+=-DZT_SALSA20_SSE
  23. endif
  24. ifeq ($(MACHINE),i386)
  25. DEFS+=-DZT_SALSA20_SSE
  26. endif
  27. ifeq ($(MACHINE),x86)
  28. DEFS+=-DZT_SALSA20_SSE
  29. endif
  30. # Build with ZT_ENABLE_NETCONF_MASTER=1 to build with NetworkConfigMaster enabled
  31. ifeq ($(ZT_ENABLE_NETCONF_MASTER),1)
  32. DEFS+=-DZT_ENABLE_NETCONF_MASTER
  33. LIBS+=-lhiredis
  34. endif
  35. # "make official" is a shortcut for this
  36. ifeq ($(ZT_OFFICIAL_RELEASE),1)
  37. ZT_AUTO_UPDATE=1
  38. DEFS+=-DZT_OFFICIAL_RELEASE
  39. endif
  40. ifeq ($(ZT_AUTO_UPDATE),1)
  41. DEFS+=-DZT_AUTO_UPDATE
  42. endif
  43. # "make debug" is a shortcut for this
  44. ifeq ($(ZT_DEBUG),1)
  45. # DEFS+=-DZT_TRACE -DZT_LOG_STDOUT
  46. CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
  47. LDFLAGS=
  48. STRIP=echo
  49. # The following line enables optimization for the crypto code, since
  50. # C25519 in particular is almost UNUSABLE in heavy testing without it.
  51. ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
  52. else
  53. CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
  54. LDFLAGS=-pie -Wl,-z,relro,-z,now
  55. STRIP=strip --strip-all
  56. endif
  57. # Uncomment for gprof profile build
  58. #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
  59. #LDFLAGS=
  60. #STRIP=echo
  61. CXXFLAGS=$(CFLAGS) -fno-rtti
  62. all: one
  63. one: $(OBJS) main.o
  64. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
  65. $(STRIP) zerotier-one
  66. ln -sf zerotier-one zerotier-cli
  67. ln -sf zerotier-one zerotier-idtool
  68. selftest: $(OBJS) selftest.o
  69. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  70. $(STRIP) zerotier-selftest
  71. testnet: $(TESTNET_OBJS) $(OBJS) testnet.o
  72. $(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS)
  73. $(STRIP) zerotier-testnet
  74. installer: one FORCE
  75. ./buildinstaller.sh
  76. clean:
  77. rm -rf *.o netconf/*.o node/*.o osnet/*.o control/*.o testnet/*.o ext/lz4/*.o zerotier-* build-* ZeroTierOneInstaller-* *.deb *.rpm
  78. debug: FORCE
  79. make -j 4 ZT_DEBUG=1
  80. official: FORCE
  81. make -j 4 ZT_OFFICIAL_RELEASE=1
  82. ./buildinstaller.sh
  83. FORCE: