2
0

make-linux.mk 2.1 KB

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