You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

296 lines
9.8KB

  1. RACK_DIR ?= .
  2. VERSION_MAJOR := 2
  3. VERSION := 2.2.1
  4. FLAGS += -Iinclude -Idep/include
  5. include arch.mk
  6. # Sources and build flags
  7. SOURCES += dep/nanovg/src/nanovg.c
  8. SOURCES += dep/osdialog/osdialog.c
  9. SOURCES += dep/oui-blendish/blendish.c
  10. SOURCES += dep/pffft/pffft.c dep/pffft/fftpack.c
  11. SOURCES += dep/tinyexpr/tinyexpr.c
  12. SOURCES += $(wildcard src/*.c src/*/*.c)
  13. SOURCES += $(wildcard src/*.cpp src/*/*.cpp)
  14. build/src/common.cpp.o: FLAGS += -D_APP_VERSION=$(VERSION)
  15. build/dep/tinyexpr/tinyexpr.c.o: FLAGS += -DTE_POW_FROM_RIGHT -DTE_NAT_LOG
  16. FLAGS += -fPIC
  17. LDFLAGS += -shared
  18. ifdef ARCH_LIN
  19. SED := sed -i
  20. TARGET := libRack.so
  21. SOURCES += dep/osdialog/osdialog_zenity.c
  22. # This prevents static variables in the DSO (dynamic shared object) from being preserved after dlclose().
  23. # I don't really understand the side effects (see GCC manual), but so far tests are positive.
  24. FLAGS += -fno-gnu-unique
  25. LDFLAGS += -Wl,--whole-archive
  26. LDFLAGS += -static-libstdc++ -static-libgcc
  27. LDFLAGS += dep/lib/libGLEW.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a dep/lib/libarchive.a dep/lib/libzstd.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a dep/lib/librtmidi.a dep/lib/librtaudio.a
  28. LDFLAGS += -Wl,--no-whole-archive
  29. LDFLAGS += -lpthread -lGL -ldl -lX11 -lasound -ljack -lpulse -lpulse-simple
  30. endif
  31. ifdef ARCH_MAC
  32. SED := sed -i ''
  33. TARGET := libRack.dylib
  34. SOURCES += dep/osdialog/osdialog_mac.m
  35. LDFLAGS += -lpthread -ldl
  36. LDFLAGS += -framework SystemConfiguration -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI
  37. LDFLAGS += -Wl,-all_load
  38. LDFLAGS += dep/lib/libGLEW.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a dep/lib/libarchive.a dep/lib/libzstd.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a dep/lib/librtmidi.a dep/lib/librtaudio.a
  39. endif
  40. ifdef ARCH_WIN
  41. SED := sed -i
  42. TARGET := libRack.dll
  43. SOURCES += dep/osdialog/osdialog_win.c
  44. LDFLAGS += -municode
  45. LDFLAGS += -Wl,--export-all-symbols
  46. LDFLAGS += -Wl,--out-implib,$(TARGET).a
  47. LDFLAGS += -Wl,-Bstatic -Wl,--whole-archive
  48. LDFLAGS += dep/lib/libglew32.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a dep/lib/libarchive_static.a dep/lib/libzstd.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a dep/lib/librtaudio.a dep/lib/librtmidi.a
  49. LDFLAGS += -Wl,-Bdynamic -Wl,--no-whole-archive
  50. LDFLAGS += -lpthread -lopengl32 -lgdi32 -lws2_32 -lcomdlg32 -lole32 -ldsound -lwinmm -lksuser -lshlwapi -lmfplat -lmfuuid -lwmcodecdspuuid -ldbghelp -lcrypt32
  51. endif
  52. include compile.mk
  53. # Standalone adapter
  54. STANDALONE_SOURCES += adapters/standalone.cpp
  55. ifdef ARCH_LIN
  56. STANDALONE_TARGET := Rack
  57. STANDALONE_LDFLAGS += -static-libstdc++ -static-libgcc
  58. STANDALONE_LDFLAGS += -Wl,-rpath=.
  59. endif
  60. ifdef ARCH_MAC
  61. STANDALONE_TARGET := Rack
  62. STANDALONE_LDFLAGS += -stdlib=libc++
  63. endif
  64. ifdef ARCH_WIN
  65. STANDALONE_TARGET := Rack.exe
  66. STANDALONE_LDFLAGS += -mwindows
  67. # 1MiB stack size to match MSVC
  68. STANDALONE_LDFLAGS += -Wl,--stack,0x100000
  69. STANDALONE_OBJECTS += build/Rack.res
  70. endif
  71. STANDALONE_OBJECTS += $(TARGET)
  72. $(STANDALONE_TARGET): $(STANDALONE_SOURCES) $(STANDALONE_OBJECTS)
  73. $(CXX) $(CXXFLAGS) -o $@ $^ $(STANDALONE_LDFLAGS)
  74. # Convenience targets
  75. all: $(TARGET) $(STANDALONE_TARGET)
  76. dep:
  77. $(MAKE) -C dep
  78. cleandep:
  79. $(MAKE) -C dep clean
  80. run: $(STANDALONE_TARGET)
  81. ./$< -d
  82. runr: $(STANDALONE_TARGET)
  83. ./$<
  84. debug: $(STANDALONE_TARGET)
  85. ifdef ARCH_MAC
  86. lldb -- ./$< -d
  87. endif
  88. ifdef ARCH_WIN
  89. gdb --args ./$< -d
  90. endif
  91. ifdef ARCH_LIN
  92. gdb --args ./$< -d
  93. endif
  94. perf: $(STANDALONE_TARGET)
  95. # Requires perf
  96. perf record --call-graph dwarf -o perf.data ./$< -d
  97. # Analyze with hotspot (https://github.com/KDAB/hotspot) for example
  98. hotspot perf.data
  99. rm perf.data
  100. valgrind: $(STANDALONE_TARGET)
  101. # --gen-suppressions=yes
  102. # --leak-check=full
  103. valgrind --suppressions=valgrind.supp ./$< -d
  104. clean:
  105. rm -rfv build dist $(TARGET) $(STANDALONE_TARGET) *.a
  106. # For Windows resources
  107. build/%.res: %.rc
  108. ifdef ARCH_WIN
  109. windres $^ -O coff -o $@
  110. endif
  111. DIST_RES := res cacert.pem Core.json template.vcv LICENSE-GPLv3.txt
  112. DIST_NAME := RackFree-$(VERSION)-$(ARCH_NAME)
  113. DIST_SDK_DIR := Rack-SDK
  114. DIST_SDK := Rack-SDK-$(VERSION)-$(ARCH_NAME).zip
  115. ifdef ARCH_MAC
  116. DIST_BUNDLE := VCV Rack $(VERSION_MAJOR) Free.app
  117. else
  118. DIST_DIR := Rack$(VERSION_MAJOR)Free
  119. endif
  120. DIST_MD := $(wildcard *.md)
  121. DIST_HTML := $(patsubst %.md, build/%.html, $(DIST_MD))
  122. # Target not supported for public use
  123. dist: $(TARGET) $(STANDALONE_TARGET) $(DIST_HTML) | cleandist
  124. mkdir -p dist
  125. # Copy Rack to dist
  126. ifdef ARCH_LIN
  127. mkdir -p dist/"$(DIST_DIR)"
  128. cp $(TARGET) dist/"$(DIST_DIR)"/
  129. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  130. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  131. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  132. # Manually check that no nonstandard shared libraries are linked
  133. ldd dist/"$(DIST_DIR)"/$(TARGET)
  134. ldd dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  135. # Copy resources
  136. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  137. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  138. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  139. # Make ZIP
  140. cd dist && zip -q -9 -r "$(DIST_NAME)".zip "$(DIST_DIR)"
  141. endif
  142. ifdef ARCH_MAC
  143. mkdir -p dist/"$(DIST_BUNDLE)"
  144. mkdir -p dist/"$(DIST_BUNDLE)"/Contents
  145. mkdir -p dist/"$(DIST_BUNDLE)"/Contents/Resources
  146. mkdir -p dist/"$(DIST_BUNDLE)"/Contents/MacOS
  147. cp $(TARGET) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  148. cp $(STANDALONE_TARGET) dist/"$(DIST_BUNDLE)"/Contents/MacOS/
  149. $(STRIP) -S dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET)
  150. $(STRIP) -S dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  151. install_name_tool -change $(TARGET) @executable_path/../Resources/$(TARGET) dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  152. # Manually check that no nonstandard shared libraries are linked
  153. otool -L dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET)
  154. otool -L dist/"$(DIST_BUNDLE)"/Contents/MacOS/$(STANDALONE_TARGET)
  155. # Copy resources
  156. cp Info.plist dist/"$(DIST_BUNDLE)"/Contents/
  157. $(SED) 's/{VERSION}/$(VERSION)/g' dist/"$(DIST_BUNDLE)"/Contents/Info.plist
  158. cp -R $(DIST_RES) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  159. cp $(DIST_HTML) dist/"$(DIST_BUNDLE)"/Contents/Resources/
  160. cp -R icon.icns dist/"$(DIST_BUNDLE)"/Contents/Resources/
  161. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_BUNDLE)"/Contents/Resources/Fundamental.vcvplugin
  162. # Clean up and sign bundle
  163. xattr -cr dist/"$(DIST_BUNDLE)"
  164. codesign --verbose --sign "Developer ID Application: Andrew Belt (VRF26934X5)" --options runtime --entitlements Entitlements.plist --timestamp --deep dist/"$(DIST_BUNDLE)"/Contents/Resources/$(TARGET) dist/"$(DIST_BUNDLE)"
  165. codesign --verify --deep --strict --verbose=2 dist/"$(DIST_BUNDLE)"
  166. # Make standalone PKG
  167. mkdir -p dist/Component
  168. cp -R dist/"$(DIST_BUNDLE)" dist/Component/
  169. pkgbuild --identifier com.vcvrack.rack --component-plist Component.plist --root dist/Component --install-location /Applications dist/Component.pkg
  170. # Make PKG
  171. productbuild --distribution Distribution.xml --package-path dist dist/"$(DIST_NAME)".pkg
  172. productsign --sign "Developer ID Installer: Andrew Belt (V8SW9J626X)" dist/"$(DIST_NAME)".pkg dist/"$(DIST_NAME)"-signed.pkg
  173. mv dist/"$(DIST_NAME)"-signed.pkg dist/"$(DIST_NAME)".pkg
  174. endif
  175. ifdef ARCH_WIN
  176. mkdir -p dist/"$(DIST_DIR)"
  177. cp $(TARGET) dist/"$(DIST_DIR)"/
  178. cp $(STANDALONE_TARGET) dist/"$(DIST_DIR)"/
  179. $(STRIP) -s dist/"$(DIST_DIR)"/$(TARGET)
  180. $(STRIP) -s dist/"$(DIST_DIR)"/$(STANDALONE_TARGET)
  181. # Copy resources
  182. cp -R $(DIST_RES) dist/"$(DIST_DIR)"/
  183. cp $(DIST_HTML) dist/"$(DIST_DIR)"/
  184. cp /mingw64/bin/libwinpthread-1.dll dist/"$(DIST_DIR)"/
  185. cp /mingw64/bin/libstdc++-6.dll dist/"$(DIST_DIR)"/
  186. cp /mingw64/bin/libgcc_s_seh-1.dll dist/"$(DIST_DIR)"/
  187. cp plugins/Fundamental/dist/Fundamental-*.vcvplugin dist/"$(DIST_DIR)"/Fundamental.vcvplugin
  188. # Make NSIS installer
  189. # pacman -S mingw-w64-x86_64-nsis
  190. makensis -DVERSION_MAJOR="$(VERSION_MAJOR)" -DVERSION="$(VERSION)" "-XOutFile dist/$(DIST_NAME).exe" installer.nsi
  191. endif
  192. # Build Rack SDK
  193. mkdir -p dist/"$(DIST_SDK_DIR)"
  194. cp -R LICENSE* *.mk include helper.py dist/"$(DIST_SDK_DIR)"/
  195. mkdir -p dist/"$(DIST_SDK_DIR)"/dep/
  196. cp -R dep/include dist/"$(DIST_SDK_DIR)"/dep/
  197. ifdef ARCH_LIN
  198. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  199. $(STRIP) -s dist/"$(DIST_SDK_DIR)"/$(TARGET)
  200. endif
  201. ifdef ARCH_MAC
  202. cp $(TARGET) dist/"$(DIST_SDK_DIR)"/
  203. $(STRIP) -S dist/"$(DIST_SDK_DIR)"/$(TARGET)
  204. endif
  205. ifdef ARCH_WIN
  206. cp libRack.dll.a dist/"$(DIST_SDK_DIR)"/
  207. endif
  208. cd dist && zip -q -9 -r "$(DIST_SDK)" "$(DIST_SDK_DIR)"
  209. install: dist
  210. ifdef ARCH_MAC
  211. sudo installer -pkg dist/"$(DIST_NAME)".pkg -target /
  212. endif
  213. uninstall:
  214. ifdef ARCH_MAC
  215. sudo rm -rf /Applications/"$(DIST_BUNDLE)"
  216. endif
  217. # Target not supported for public use
  218. notarize:
  219. ifdef ARCH_MAC
  220. xcrun altool --notarize-app --primary-bundle-id "com.vcvrack.rack" --username "andrew@vcvrack.com" --password @keychain:notarize --output-format xml --file dist/"$(DIST_NAME)".pkg > dist/UploadInfo.plist
  221. # Wait for Apple's servers to approve the app
  222. while true; do \
  223. echo "Waiting on Apple servers..." ; \
  224. sleep 10 ; \
  225. xcrun altool --notarization-info `/usr/libexec/PlistBuddy -c "Print :notarization-upload:RequestUUID" dist/UploadInfo.plist` -u "andrew@vcvrack.com" -p @keychain:notarize --output-format xml > dist/RequestInfo.plist ; \
  226. if [ "`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" dist/RequestInfo.plist`" != "in progress" ]; then \
  227. break ; \
  228. fi ; \
  229. done
  230. # Mark app as notarized
  231. xcrun stapler staple dist/"$(DIST_NAME)".pkg
  232. # Check notarization
  233. stapler validate dist/"$(DIST_NAME)".pkg
  234. endif
  235. cleandist:
  236. rm -rfv dist
  237. # Plugin helpers
  238. plugins:
  239. ifdef CMD
  240. for f in plugins/*; do (cd "$$f" && $(CMD)); done
  241. else
  242. for f in plugins/*; do $(MAKE) -C "$$f"; done
  243. endif
  244. # Includes
  245. .DEFAULT_GOAL := all
  246. .PHONY: all dep run debug clean dist upload src plugins