make-linux.mk 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Pick clang or gcc, with preference for clang
  2. CC=$(shell if [ -e /usr/bin/clang ]; then echo clang; else echo gcc; fi)
  3. CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
  4. INCLUDES=
  5. DEFS=
  6. LIBS=
  7. include objects.mk
  8. OBJS+=osdep/LinuxEthernetTap.o
  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. # Build with ZT_ENABLE_NETWORK_CONTROLLER=1 to build with the Sqlite network controller
  18. ifeq ($(ZT_ENABLE_NETWORK_CONTROLLER),1)
  19. DEFS+=-DZT_ENABLE_NETWORK_CONTROLLER
  20. LIBS+=-L/usr/local/lib -lsqlite3
  21. OBJS+=controller/SqliteNetworkController.o
  22. endif
  23. # "make debug" is a shortcut for this
  24. ifeq ($(ZT_DEBUG),1)
  25. DEFS+=-DZT_TRACE
  26. CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
  27. LDFLAGS=
  28. STRIP=echo
  29. # The following line enables optimization for the crypto code, since
  30. # C25519 in particular is almost UNUSABLE in heavy testing without it.
  31. ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
  32. else
  33. CFLAGS=-Wall -O3 -fPIE -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
  34. LDFLAGS=-pie -Wl,-z,relro,-z,now
  35. STRIP=strip --strip-all
  36. endif
  37. # Uncomment for gprof profile build
  38. #CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
  39. #LDFLAGS=
  40. #STRIP=echo
  41. CXXFLAGS=$(CFLAGS) -fno-rtti
  42. all: one
  43. one: $(OBJS) one.o
  44. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
  45. $(STRIP) zerotier-one
  46. ln -sf zerotier-one zerotier-idtool
  47. ln -sf zerotier-one zerotier-cli
  48. selftest: $(OBJS) selftest.o
  49. $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  50. $(STRIP) zerotier-selftest
  51. installer: one FORCE
  52. ./ext/installfiles/linux/buildinstaller.sh
  53. clean:
  54. 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
  55. debug: FORCE
  56. make -j 4 ZT_DEBUG=1
  57. official: FORCE
  58. make -j 4 ZT_OFFICIAL_RELEASE=1
  59. make ZT_OFFICIAL_RELEASE=1 installer
  60. FORCE: