make-mac.mk 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ifeq ($(origin CC),default)
  2. CC=$(shell if [ -e /usr/bin/clang ]; then echo clang; else echo gcc; fi)
  3. endif
  4. ifeq ($(origin CXX),default)
  5. CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
  6. endif
  7. INCLUDES=
  8. DEFS=
  9. LIBS=
  10. ARCH_FLAGS=-arch x86_64
  11. include objects.mk
  12. OBJS+=osdep/OSXEthernetTap.o
  13. # Comment out to disable building against shipped libminiupnpc binary for Mac
  14. ZT_USE_MINIUPNPC=1
  15. # Disable codesign since open source users will not have ZeroTier's certs
  16. CODESIGN=echo
  17. PRODUCTSIGN=echo
  18. CODESIGN_APP_CERT=
  19. CODESIGN_INSTALLER_CERT=
  20. # For internal use only -- signs everything with ZeroTier's developer cert
  21. ifeq ($(ZT_OFFICIAL_RELEASE),1)
  22. DEFS+=-DZT_OFFICIAL_RELEASE -DZT_AUTO_UPDATE
  23. ZT_USE_MINIUPNPC=1
  24. CODESIGN=codesign
  25. PRODUCTSIGN=productsign
  26. CODESIGN_APP_CERT="Developer ID Application: ZeroTier Networks LLC (8ZD9JUCZ4V)"
  27. CODESIGN_INSTALLER_CERT="Developer ID Installer: ZeroTier Networks LLC (8ZD9JUCZ4V)"
  28. endif
  29. ifeq ($(ZT_AUTO_UPDATE),1)
  30. DEFS+=-DZT_AUTO_UPDATE
  31. endif
  32. ifeq ($(ZT_USE_MINIUPNPC),1)
  33. DEFS+=-DZT_USE_MINIUPNPC
  34. INCLUDES+=-Iext/bin/miniupnpc/include
  35. LIBS+=ext/bin/miniupnpc/mac-x64/libminiupnpc.a
  36. OBJS+=osdep/UPNPClient.o
  37. endif
  38. # Build with ZT_ENABLE_NETWORK_CONTROLLER=1 to build with the Sqlite network controller
  39. ifeq ($(ZT_ENABLE_NETWORK_CONTROLLER),1)
  40. DEFS+=-DZT_ENABLE_NETWORK_CONTROLLER
  41. LIBS+=-L/usr/local/lib -lsqlite3
  42. OBJS+=controller/SqliteNetworkController.o
  43. endif
  44. # Debug mode -- dump trace output, build binary with -g
  45. ifeq ($(ZT_DEBUG),1)
  46. DEFS+=-DZT_TRACE
  47. CFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS)
  48. STRIP=echo
  49. # The following line enables optimization for the crypto code, since
  50. # C25519 in particular is almost UNUSABLE in heavy testing without it.
  51. ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
  52. else
  53. CFLAGS?=-O3 -fstack-protector
  54. CFLAGS+=$(ARCH_FLAGS) -Wall -flto -fPIE -fvectorize -pthread -mmacosx-version-min=10.7 -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS)
  55. STRIP=strip
  56. endif
  57. CXXFLAGS=$(CFLAGS) -fno-rtti
  58. all: one
  59. one: $(OBJS) one.o
  60. $(CXX) $(CXXFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
  61. $(STRIP) zerotier-one
  62. ln -sf zerotier-one zerotier-idtool
  63. ln -sf zerotier-one zerotier-cli
  64. $(CODESIGN) -f -s $(CODESIGN_APP_CERT) zerotier-one
  65. $(CODESIGN) -vvv zerotier-one
  66. selftest: $(OBJS) selftest.o
  67. $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  68. $(STRIP) zerotier-selftest
  69. # Requires Packages: http://s.sudre.free.fr/Software/Packages/about.html
  70. mac-dist-pkg: FORCE
  71. packagesbuild "ext/installfiles/mac/ZeroTier One.pkgproj"
  72. rm -f "ZeroTier One Signed.pkg"
  73. $(PRODUCTSIGN) --sign $(CODESIGN_INSTALLER_CERT) "ZeroTier One.pkg" "ZeroTier One Signed.pkg"
  74. if [ -f "ZeroTier One Signed.pkg" ]; then mv -f "ZeroTier One Signed.pkg" "ZeroTier One.pkg"; fi
  75. # For internal use only
  76. official: FORCE
  77. make clean
  78. make -j 4 ZT_OFFICIAL_RELEASE=1
  79. make ZT_OFFICIAL_RELEASE=1 mac-dist-pkg
  80. clean:
  81. rm -rf *.dSYM build-* *.pkg *.dmg *.o node/*.o controller/*.o service/*.o osdep/*.o ext/http-parser/*.o ext/lz4/*.o ext/json-parser/*.o zerotier-one zerotier-idtool zerotier-selftest zerotier-cli ZeroTierOneInstaller-*
  82. # For those building from source -- installs signed binary tap driver in system ZT home
  83. install-mac-tap: FORCE
  84. mkdir -p /Library/Application\ Support/ZeroTier/One
  85. rm -rf /Library/Application\ Support/ZeroTier/One/tap.kext
  86. cp -R ext/bin/tap-mac/tap.kext /Library/Application\ Support/ZeroTier/One
  87. chown -R root:wheel /Library/Application\ Support/ZeroTier/One/tap.kext
  88. FORCE: