make-mac.mk 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. CC=clang
  2. CXX=clang++
  3. INCLUDES=-I/usr/local/include
  4. DEFS=
  5. LIBS=
  6. ARCH_FLAGS=-arch i386 -arch x86_64
  7. include objects.mk
  8. OBJS+=osdep/OSXEthernetTap.o
  9. TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o
  10. # Disable codesign since open source users will not have ZeroTier's certs
  11. CODESIGN=echo
  12. CODESIGN_CERT=
  13. ifeq ($(ZT_OFFICIAL_RELEASE),1)
  14. # For use by ZeroTier Networks -- sign with developer cert
  15. ZT_AUTO_UPDATE=1
  16. DEFS+=-DZT_OFFICIAL_RELEASE
  17. CODESIGN=codesign
  18. CODESIGN_CERT="Developer ID Application: ZeroTier Networks LLC (8ZD9JUCZ4V)"
  19. endif
  20. ifeq ($(ZT_AUTO_UPDATE),1)
  21. DEFS+=-DZT_AUTO_UPDATE
  22. endif
  23. # Build with ZT_ENABLE_NETCONF_MASTER=1 to build with NetworkConfigMaster enabled
  24. ifeq ($(ZT_ENABLE_NETCONF_MASTER),1)
  25. DEFS+=-DZT_ENABLE_NETCONF_MASTER
  26. LIBS+=-L/usr/local/lib -lsqlite3
  27. ARCH_FLAGS=-arch x86_64
  28. OBJS+=netconf/SqliteNetworkConfigMaster.o
  29. endif
  30. # Enable SSE-optimized Salsa20 -- all Intel macs support SSE2
  31. DEFS+=-DZT_SALSA20_SSE
  32. ifeq ($(ZT_DEBUG),1)
  33. DEFS+=-DZT_TRACE
  34. CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS)
  35. STRIP=echo
  36. # The following line enables optimization for the crypto code, since
  37. # C25519 in particular is almost UNUSABLE in heavy testing without it.
  38. ext/lz4/lz4.o node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CFLAGS = -Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
  39. else
  40. CFLAGS=$(ARCH_FLAGS) -Wall -O3 -flto -fPIE -fvectorize -fstack-protector -pthread -mmacosx-version-min=10.6 -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS)
  41. STRIP=strip
  42. endif
  43. CXXFLAGS=$(CFLAGS) -fno-rtti
  44. all: one
  45. one: $(OBJS) main.o
  46. $(CXX) $(CXXFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
  47. $(STRIP) zerotier-one
  48. ln -sf zerotier-one zerotier-cli
  49. ln -sf zerotier-one zerotier-idtool
  50. selftest: $(OBJS) selftest.o
  51. $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
  52. $(STRIP) zerotier-selftest
  53. testnet: $(TESTNET_OBJS) $(OBJS) testnet.o
  54. $(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS)
  55. $(STRIP) zerotier-testnet
  56. # Requires that ../Qt be symlinked to the Qt root to use for UI build
  57. mac-ui: FORCE
  58. mkdir -p build-ZeroTierUI-release
  59. cd build-ZeroTierUI-release ; ../../Qt/bin/qmake ../ZeroTierUI/ZeroTierUI.pro ; make -j 4
  60. strip "build-ZeroTierUI-release/ZeroTier One.app/Contents/MacOS/ZeroTier One"
  61. find "build-ZeroTierUI-release/ZeroTier One.app" -type f -name '.DS_Store' -print0 | xargs -0 rm -f
  62. $(CODESIGN) -f -s $(CODESIGN_CERT) "build-ZeroTierUI-release/ZeroTier One.app"
  63. $(CODESIGN) -vvv "build-ZeroTierUI-release/ZeroTier One.app"
  64. clean:
  65. rm -rf *.dSYM build-* *.o netconf/*.o control/*.o node/*.o testnet/*.o osdep/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-* ZeroTierOneInstaller-* "ZeroTier One.zip" "ZeroTier One.dmg"
  66. # For our use -- builds official signed binary, packages in installer and download DMG
  67. official: FORCE
  68. make -j 4 ZT_OFFICIAL_RELEASE=1
  69. make mac-ui ZT_OFFICIAL_RELEASE=1
  70. ./buildinstaller.sh
  71. make mac-dmg ZT_OFFICIAL_RELEASE=1
  72. mac-dmg: FORCE
  73. mkdir -p build-ZeroTierOne-dmg
  74. cd build-ZeroTierOne-dmg ; ln -sf /Applications Applications
  75. cp -a "build-ZeroTierUI-release/ZeroTier One.app" build-ZeroTierOne-dmg/
  76. rm -f /tmp/tmp.dmg
  77. hdiutil create /tmp/tmp.dmg -ov -volname "ZeroTier One" -fs HFS+ -srcfolder ./build-ZeroTierOne-dmg
  78. hdiutil convert /tmp/tmp.dmg -format UDZO -o "ZeroTier One.dmg"
  79. $(CODESIGN) -f -s $(CODESIGN_CERT) "ZeroTier One.dmg"
  80. rm -f /tmp/tmp.dmg
  81. # For those building from source -- installs signed binary tap driver in system ZT home
  82. install-mac-tap: FORCE
  83. mkdir -p /Library/Application\ Support/ZeroTier/One
  84. rm -rf /Library/Application\ Support/ZeroTier/One/tap.kext
  85. cp -R ext/bin/tap-mac/tap.kext /Library/Application\ Support/ZeroTier/One
  86. chown -R root:wheel /Library/Application\ Support/ZeroTier/One/tap.kext
  87. FORCE: