make-mac.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 ext/lz4/lz4.o ext/http-parser/http_parser.o
  13. # Disable codesign since open source users will not have ZeroTier's certs
  14. CODESIGN=echo
  15. PRODUCTSIGN=echo
  16. CODESIGN_APP_CERT=
  17. CODESIGN_INSTALLER_CERT=
  18. # Build with libminiupnpc by default for Mac -- desktops/laptops almost always want this
  19. ZT_USE_MINIUPNPC?=1
  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_ENABLE_CLUSTER),1)
  30. DEFS+=-DZT_ENABLE_CLUSTER
  31. endif
  32. ifeq ($(ZT_AUTO_UPDATE),1)
  33. DEFS+=-DZT_AUTO_UPDATE
  34. endif
  35. ifeq ($(ZT_USE_MINIUPNPC),1)
  36. DEFS+=-DMACOSX -DZT_USE_MINIUPNPC -DMINIUPNP_STATICLIB -D_DARWIN_C_SOURCE -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNPC_GET_SRC_ADDR -D_BSD_SOURCE -D_DEFAULT_SOURCE -DOS_STRING=\"Darwin/15.0.0\" -DMINIUPNPC_VERSION_STRING=\"2.0\" -DUPNP_VERSION_STRING=\"UPnP/1.1\" -DENABLE_STRNATPMPERR
  37. OBJS+=ext/libnatpmp/natpmp.o ext/libnatpmp/getgateway.o ext/miniupnpc/connecthostport.o ext/miniupnpc/igd_desc_parse.o ext/miniupnpc/minisoap.o ext/miniupnpc/minissdpc.o ext/miniupnpc/miniupnpc.o ext/miniupnpc/miniwget.o ext/miniupnpc/minixml.o ext/miniupnpc/portlistingparse.o ext/miniupnpc/receivedata.o ext/miniupnpc/upnpcommands.o ext/miniupnpc/upnpdev.o ext/miniupnpc/upnperrors.o ext/miniupnpc/upnpreplyparse.o osdep/PortMapper.o
  38. endif
  39. # Debug mode -- dump trace output, build binary with -g
  40. ifeq ($(ZT_DEBUG),1)
  41. DEFS+=-DZT_TRACE
  42. CFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS)
  43. STRIP=echo
  44. # The following line enables optimization for the crypto code, since
  45. # C25519 in particular is almost UNUSABLE in heavy testing without it.
  46. ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
  47. else
  48. CFLAGS?=-Ofast -fstack-protector-strong
  49. CFLAGS+=$(ARCH_FLAGS) -Wall -flto -fPIE -pthread -mmacosx-version-min=10.7 -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS)
  50. STRIP=strip
  51. endif
  52. CXXFLAGS=$(CFLAGS) -mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++
  53. all: one
  54. one: $(OBJS) service/OneService.o one.o
  55. $(CXX) $(CXXFLAGS) -o zerotier-one $(OBJS) service/OneService.o one.o $(LIBS)
  56. $(STRIP) zerotier-one
  57. ln -sf zerotier-one zerotier-idtool
  58. ln -sf zerotier-one zerotier-cli
  59. $(CODESIGN) -f -s $(CODESIGN_APP_CERT) zerotier-one
  60. $(CODESIGN) -vvv zerotier-one
  61. cli: FORCE
  62. $(CXX) $(CXXFLAGS) -o zerotier cli/zerotier.cpp osdep/OSUtils.cpp node/InetAddress.cpp node/Utils.cpp node/Salsa20.cpp node/Identity.cpp node/SHA512.cpp node/C25519.cpp -lcurl
  63. $(STRIP) zerotier
  64. selftest: $(OBJS) selftest.o
  65. $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  66. $(STRIP) zerotier-selftest
  67. # Requires Packages: http://s.sudre.free.fr/Software/Packages/about.html
  68. mac-dist-pkg: FORCE
  69. packagesbuild "ext/installfiles/mac/ZeroTier One.pkgproj"
  70. rm -f "ZeroTier One Signed.pkg"
  71. $(PRODUCTSIGN) --sign $(CODESIGN_INSTALLER_CERT) "ZeroTier One.pkg" "ZeroTier One Signed.pkg"
  72. if [ -f "ZeroTier One Signed.pkg" ]; then mv -f "ZeroTier One Signed.pkg" "ZeroTier One.pkg"; fi
  73. # For ZeroTier, Inc. to build official signed packages
  74. official: FORCE
  75. make clean
  76. make ZT_OFFICIAL_RELEASE=1 -j 4 one
  77. make ZT_OFFICIAL_RELEASE=1 mac-dist-pkg
  78. clean:
  79. 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 $(OBJS) zerotier-one zerotier-idtool zerotier-selftest zerotier-cli zerotier ZeroTierOneInstaller-* mkworld doc/node_modules
  80. distclean: clean
  81. rm -rf doc/node_modules
  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: