make-linux.mk 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 in all modes
  8. DEFS+=-DZT_SALSA20_SSE
  9. # "make official" is a shortcut for this
  10. ifeq ($(ZT_OFFICIAL_RELEASE),1)
  11. ZT_AUTO_UPDATE=1
  12. DEFS+=-DZT_OFFICIAL_RELEASE
  13. endif
  14. ifeq ($(ZT_AUTO_UPDATE),1)
  15. DEFS+=-DZT_AUTO_UPDATE
  16. endif
  17. # "make debug" is a shortcut for this
  18. ifeq ($(ZT_DEBUG),1)
  19. CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE -DZT_LOG_STDOUT $(DEFS)
  20. LDFLAGS=
  21. STRIP=echo
  22. DEFS+=-DZT_TRACE -DZT_LOG_STDOUT
  23. else
  24. CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
  25. LDFLAGS=-pie -Wl,-z,relro,-z,now
  26. STRIP=strip --strip-all
  27. endif
  28. # Uncomment for gprof profile build
  29. #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
  30. #LDFLAGS=
  31. #STRIP=echo
  32. # Our code doesn't use rtti, so don't bloat the binary with it.
  33. CXXFLAGS=$(CFLAGS) -fno-rtti
  34. include objects.mk
  35. OBJS+=main.o osnet/LinuxRoutingTable.o osnet/LinuxEthernetTap.o osnet/LinuxEthernetTapFactory.o
  36. all: one
  37. one: $(OBJS)
  38. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) $(LIBS)
  39. $(STRIP) zerotier-one
  40. ln -sf zerotier-one zerotier-cli
  41. ln -sf zerotier-one zerotier-idtool
  42. selftest: $(OBJS) selftest.o
  43. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  44. $(STRIP) zerotier-selftest
  45. installer: one FORCE
  46. ./buildinstaller.sh
  47. clean:
  48. rm -rf $(OBJS) node/*.o osnet/*.o *.o zerotier-* build-* ZeroTierOneInstaller-*
  49. debug: FORCE
  50. make -j 4 ZT_DEBUG=1
  51. official: FORCE
  52. make -j 4 ZT_OFFICIAL_RELEASE=1
  53. ./buildinstaller.sh
  54. FORCE: