2
0

make-linux.mk 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE -DZT_LOG_STDOUT $(DEFS)
  38. LDFLAGS=
  39. STRIP=echo
  40. DEFS+=-DZT_TRACE -DZT_LOG_STDOUT
  41. else
  42. CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
  43. LDFLAGS=-pie -Wl,-z,relro,-z,now
  44. STRIP=strip --strip-all
  45. endif
  46. # Uncomment for gprof profile build
  47. #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
  48. #LDFLAGS=
  49. #STRIP=echo
  50. CXXFLAGS=$(CFLAGS) -fno-rtti
  51. include objects.mk
  52. OBJS+=osnet/LinuxRoutingTable.o osnet/LinuxEthernetTap.o osnet/LinuxEthernetTapFactory.o
  53. all: one
  54. one: $(OBJS) main.o
  55. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
  56. $(STRIP) zerotier-one
  57. ln -sf zerotier-one zerotier-cli
  58. ln -sf zerotier-one zerotier-idtool
  59. selftest: $(OBJS) selftest.o
  60. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  61. $(STRIP) zerotier-selftest
  62. installer: one FORCE
  63. ./buildinstaller.sh
  64. clean:
  65. rm -rf $(OBJS) node/*.o osnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-*
  66. debug: FORCE
  67. make -j 4 ZT_DEBUG=1
  68. official: FORCE
  69. make -j 4 ZT_OFFICIAL_RELEASE=1
  70. ./buildinstaller.sh
  71. FORCE: