make-linux.mk 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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+=osdep/LinuxEthernetTap.o
  9. TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.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+=-lsqlite3
  34. OBJS+=netconf/SqliteNetworkConfigMaster.o
  35. endif
  36. # "make official" is a shortcut for this
  37. ifeq ($(ZT_OFFICIAL_RELEASE),1)
  38. ZT_AUTO_UPDATE=1
  39. DEFS+=-DZT_OFFICIAL_RELEASE
  40. endif
  41. ifeq ($(ZT_AUTO_UPDATE),1)
  42. DEFS+=-DZT_AUTO_UPDATE
  43. endif
  44. # "make debug" is a shortcut for this
  45. ifeq ($(ZT_DEBUG),1)
  46. # DEFS+=-DZT_TRACE -DZT_LOG_STDOUT
  47. CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
  48. LDFLAGS=
  49. STRIP=echo
  50. # The following line enables optimization for the crypto code, since
  51. # C25519 in particular is almost UNUSABLE in heavy testing without it.
  52. ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
  53. else
  54. CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
  55. LDFLAGS=-pie -Wl,-z,relro,-z,now
  56. STRIP=strip --strip-all
  57. endif
  58. # Uncomment for gprof profile build
  59. #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
  60. #LDFLAGS=
  61. #STRIP=echo
  62. CXXFLAGS=$(CFLAGS) -fno-rtti
  63. all: one
  64. one: $(OBJS) main.o
  65. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
  66. $(STRIP) zerotier-one
  67. ln -sf zerotier-one zerotier-cli
  68. ln -sf zerotier-one zerotier-idtool
  69. selftest: $(OBJS) selftest.o
  70. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  71. $(STRIP) zerotier-selftest
  72. testnet: $(TESTNET_OBJS) $(OBJS) testnet.o
  73. $(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS)
  74. $(STRIP) zerotier-testnet
  75. installer: one FORCE
  76. ./buildinstaller.sh
  77. clean:
  78. rm -rf *.o netconf/*.o node/*.o osdep/*.o control/*.o testnet/*.o ext/lz4/*.o zerotier-* build-* ZeroTierOneInstaller-* *.deb *.rpm
  79. debug: FORCE
  80. make -j 4 ZT_DEBUG=1
  81. official: FORCE
  82. make -j 4 ZT_OFFICIAL_RELEASE=1
  83. ./buildinstaller.sh
  84. FORCE: