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. # Enable SSE-optimized Salsa20 on x86 and x86_64 machines
  8. MACHINE=$(shell uname -m)
  9. ifeq ($(MACHINE),x86_64)
  10. DEFS+=-DZT_SALSA20_SSE
  11. endif
  12. ifeq ($(MACHINE),amd64)
  13. DEFS+=-DZT_SALSA20_SSE
  14. endif
  15. ifeq ($(MACHINE),i686)
  16. DEFS+=-DZT_SALSA20_SSE
  17. endif
  18. ifeq ($(MACHINE),i586)
  19. DEFS+=-DZT_SALSA20_SSE
  20. endif
  21. ifeq ($(MACHINE),i386)
  22. DEFS+=-DZT_SALSA20_SSE
  23. endif
  24. ifeq ($(MACHINE),x86)
  25. DEFS+=-DZT_SALSA20_SSE
  26. endif
  27. # "make official" is a shortcut for this
  28. ifeq ($(ZT_OFFICIAL_RELEASE),1)
  29. ZT_AUTO_UPDATE=1
  30. DEFS+=-DZT_OFFICIAL_RELEASE
  31. endif
  32. ifeq ($(ZT_AUTO_UPDATE),1)
  33. DEFS+=-DZT_AUTO_UPDATE
  34. endif
  35. # "make debug" is a shortcut for this
  36. ifeq ($(ZT_DEBUG),1)
  37. # DEFS+=-DZT_TRACE -DZT_LOG_STDOUT
  38. CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
  39. LDFLAGS=
  40. STRIP=echo
  41. # The following line enables optimization for the crypto code, since
  42. # C25519 in particular is almost UNUSABLE in heavy testing without it.
  43. ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -ftree-vectorize -pthread $(INCLUDES) $(DEFS)
  44. else
  45. CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
  46. LDFLAGS=-pie -Wl,-z,relro,-z,now
  47. STRIP=strip --strip-all
  48. endif
  49. # Uncomment for gprof profile build
  50. #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
  51. #LDFLAGS=
  52. #STRIP=echo
  53. CXXFLAGS=$(CFLAGS) -fno-rtti
  54. include objects.mk
  55. OBJS+=osnet/LinuxRoutingTable.o osnet/LinuxEthernetTap.o osnet/LinuxEthernetTapFactory.o
  56. all: one
  57. one: $(OBJS) main.o
  58. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
  59. $(STRIP) zerotier-one
  60. ln -sf zerotier-one zerotier-cli
  61. ln -sf zerotier-one zerotier-idtool
  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 $(OBJS) node/*.o osnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-*
  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: