make-linux.mk 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. # Enable SSE-optimized Salsa20 on x86 and x86_64 machines
  10. MACHINE=$(shell uname -m)
  11. ifeq ($(MACHINE),x86_64)
  12. DEFS+=-DZT_SALSA20_SSE
  13. endif
  14. ifeq ($(MACHINE),amd64)
  15. DEFS+=-DZT_SALSA20_SSE
  16. endif
  17. ifeq ($(MACHINE),i686)
  18. DEFS+=-DZT_SALSA20_SSE
  19. endif
  20. ifeq ($(MACHINE),i586)
  21. DEFS+=-DZT_SALSA20_SSE
  22. endif
  23. ifeq ($(MACHINE),i386)
  24. DEFS+=-DZT_SALSA20_SSE
  25. endif
  26. ifeq ($(MACHINE),x86)
  27. DEFS+=-DZT_SALSA20_SSE
  28. endif
  29. # "make official" is a shortcut for this
  30. ifeq ($(ZT_OFFICIAL_RELEASE),1)
  31. ZT_AUTO_UPDATE=1
  32. DEFS+=-DZT_OFFICIAL_RELEASE
  33. endif
  34. ifeq ($(ZT_AUTO_UPDATE),1)
  35. DEFS+=-DZT_AUTO_UPDATE
  36. endif
  37. # Build with ZT_ENABLE_NETWORK_CONTROLLER=1 to build with the Sqlite network controller
  38. ifeq ($(ZT_ENABLE_NETWORK_CONTROLLER),1)
  39. DEFS+=-DZT_ENABLE_NETWORK_CONTROLLER
  40. LIBS+=-L/usr/local/lib -lsqlite3
  41. OBJS+=controller/SqliteNetworkController.o
  42. endif
  43. # "make debug" is a shortcut for this
  44. ifeq ($(ZT_DEBUG),1)
  45. DEFS+=-DZT_TRACE
  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) one.o
  64. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
  65. $(STRIP) zerotier-one
  66. ln -sf zerotier-one zerotier-idtool
  67. ln -sf zerotier-one zerotier-cli
  68. selftest: $(OBJS) selftest.o
  69. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  70. $(STRIP) zerotier-selftest
  71. installer: one FORCE
  72. ./ext/installfiles/linux/buildinstaller.sh
  73. clean:
  74. rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o zerotier-one zerotier-idtool zerotier-cli zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm
  75. debug: FORCE
  76. make -j 4 ZT_DEBUG=1
  77. official: FORCE
  78. make -j 4 ZT_OFFICIAL_RELEASE=1
  79. make ZT_OFFICIAL_RELEASE=1 installer
  80. FORCE: