make-linux.mk 2.1 KB

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