make-linux.mk 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. ln -sf zerotier-one zerotier-cli
  62. selftest: $(OBJS) selftest.o
  63. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  64. $(STRIP) zerotier-selftest
  65. installer: one FORCE
  66. ./buildinstaller.sh
  67. clean:
  68. 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
  69. debug: FORCE
  70. make -j 4 ZT_DEBUG=1
  71. official: FORCE
  72. make -j 4 ZT_OFFICIAL_RELEASE=1
  73. ./buildinstaller.sh
  74. FORCE: