make-linux.mk 2.5 KB

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