Audio plugin host https://kx.studio/carla
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.

338 lines
14KB

  1. #!/usr/bin/make -f
  2. # Makefile for Carla #
  3. # ------------------ #
  4. # Created by falkTX
  5. #
  6. # NOTE to be imported from main Makefile
  7. # ----------------------------------------------------------------------------------------------------------------------------
  8. QT5_PREFIX = $(shell pkg-config --variable=prefix Qt5OpenGLExtensions)
  9. # ----------------------------------------------------------------------------------------------------------------------------
  10. _PLUGIN_UIS = \
  11. carla-plugin \
  12. bigmeter-ui \
  13. midipattern-ui \
  14. notes-ui \
  15. xycontroller-ui
  16. _QT5_DLLS = \
  17. QtCore \
  18. QtGui \
  19. QtOpenGL \
  20. QtPrintSupport \
  21. QtSvg \
  22. QtWidgets
  23. _QT5_PLUGINS = \
  24. iconengines/libqsvgicon$(LIB_EXT) \
  25. imageformats/libqjpeg$(LIB_EXT) \
  26. imageformats/libqsvg$(LIB_EXT) \
  27. platforms/libqcocoa$(LIB_EXT)
  28. _THEME_FILES = \
  29. styles/carlastyle.json \
  30. styles/carlastyle$(LIB_EXT)
  31. _CARLA_HOST_FILES = \
  32. carla-bridge-lv2-cocoa$(APP_EXT) \
  33. carla-bridge-lv2$(LIB_EXT) \
  34. carla-bridge-native$(APP_EXT) \
  35. carla-discovery-native$(APP_EXT) \
  36. libcarla_utils$(LIB_EXT) \
  37. $(_PLUGIN_UIS:%=resources/%$(APP_EXT))
  38. _CARLA_APP_FILES = \
  39. Carla$(APP_EXT) \
  40. libcarla_standalone2$(LIB_EXT) \
  41. $(_CARLA_HOST_FILES) \
  42. $(_QT5_DLLS) \
  43. $(_QT5_PLUGINS) \
  44. $(_THEME_FILES)
  45. _CARLA_CONTROL_APP_FILES = \
  46. Carla-Control$(APP_EXT) \
  47. libcarla_utils$(LIB_EXT) \
  48. $(_QT5_DLLS) \
  49. $(_QT5_PLUGINS) \
  50. $(_THEME_FILES)
  51. _CARLA_LV2_PLUGIN_FILES = \
  52. carla.lv2/carla$(LIB_EXT) \
  53. carla.lv2/manifest.ttl \
  54. carla.lv2/resources/carla-plugin-patchbay \
  55. carla.lv2/resources/lib/library.zip \
  56. $(_CARLA_HOST_FILES:%=carla.lv2/%) \
  57. $(_QT5_DLLS:%=carla.lv2/resources/%) \
  58. $(_QT5_PLUGINS:%=carla.lv2/resources/%) \
  59. $(_THEME_FILES:%=carla.lv2/resources/%)
  60. _CARLA_VST2FX_PLUGIN_FILES = \
  61. carlafx.vst/Contents/MacOS/CarlaVstFxShell \
  62. carlafx.vst/Contents/MacOS/resources/carla-plugin-patchbay \
  63. carlafx.vst/Contents/MacOS/resources/lib/library.zip \
  64. $(_CARLA_HOST_FILES:%=carlafx.vst/Contents/MacOS/%) \
  65. $(_QT5_DLLS:%=carlafx.vst/Contents/MacOS/resources/%) \
  66. $(_QT5_PLUGINS:%=carlafx.vst/Contents/MacOS/resources/%) \
  67. $(_THEME_FILES:%=carlafx.vst/Contents/MacOS/resources/%)
  68. _CARLA_VST2SYN_PLUGIN_FILES = \
  69. carla.vst/Contents/MacOS/CarlaVstShell \
  70. carla.vst/Contents/MacOS/resources/carla-plugin-patchbay \
  71. carla.vst/Contents/MacOS/resources/lib/library.zip \
  72. $(_CARLA_HOST_FILES:%=carla.vst/Contents/MacOS/%) \
  73. $(_QT5_DLLS:%=carla.vst/Contents/MacOS/resources/%) \
  74. $(_QT5_PLUGINS:%=carla.vst/Contents/MacOS/resources/%) \
  75. $(_THEME_FILES:%=carla.vst/Contents/MacOS/resources/%)
  76. CARLA_APP_FILES = $(_CARLA_APP_FILES:%=build/Carla.app/Contents/MacOS/%)
  77. CARLA_APP_ZIPS = $(_PLUGIN_UIS:%=build/%.app/Contents/MacOS/lib/library.zip)
  78. CARLA_CONTROL_APP_FILES = $(_CARLA_CONTROL_APP_FILES:%=build/Carla-Control.app/Contents/MacOS/%)
  79. # ----------------------------------------------------------------------------------------------------------------------------
  80. # entry point
  81. TARGETS = Carla-$(VERSION)-macOS.dmg
  82. dist: $(TARGETS)
  83. # ----------------------------------------------------------------------------------------------------------------------------
  84. # create final file
  85. Carla-$(VERSION)-macOS.dmg: build/Carla.app/Contents/Info.plist build/Carla-Control.app/Contents/Info.plist build/Carla-Plugins.pkg
  86. rm -rf build/macos-pkg $@
  87. mkdir build/macos-pkg
  88. cp -r build/Carla.app build/Carla-Control.app build/Carla-Plugins.pkg data/macos/README build/macos-pkg/
  89. hdiutil create $@ -srcfolder build/macos-pkg -volname "Carla-$(VERSION)" -fs HFS+ -ov
  90. rm -rf build/macos-pkg
  91. # ----------------------------------------------------------------------------------------------------------------------------
  92. # final cleanup, after everything is in place
  93. define PATCH_QT_DEPENDENCIES
  94. install_name_tool -change "@rpath/QtCore.framework/Versions/5/QtCore" @executable_path/QtCore ${1} && \
  95. install_name_tool -change "@rpath/QtGui.framework/Versions/5/QtGui" @executable_path/QtGui ${1} && \
  96. install_name_tool -change "@rpath/QtOpenGL.framework/Versions/5/QtOpenGL" @executable_path/QtOpenGL ${1} && \
  97. install_name_tool -change "@rpath/QtPrintSupport.framework/Versions/5/QtPrintSupport" @executable_path/QtPrintSupport ${1} && \
  98. install_name_tool -change "@rpath/QtSvg.framework/Versions/5/QtSvg" @executable_path/QtSvg ${1} && \
  99. install_name_tool -change "@rpath/QtWidgets.framework/Versions/5/QtWidgets" @executable_path/QtWidgets ${1} && \
  100. install_name_tool -change "@rpath/QtMacExtras.framework/Versions/5/QtMacExtras" @executable_path/QtMacExtras ${1}
  101. endef
  102. define CLEANUP_AND_PATCH_CXFREEZE_FILES
  103. # cleanup
  104. find build/${1}.app/Contents/MacOS/ -type f -name "*.py" -delete
  105. find build/${1}.app/Contents/MacOS/ -type f -name "*.pyi" -delete
  106. find build/${1}.app/Contents/MacOS/ -type f -name "pylupdate.so" -delete
  107. find build/${1}.app/Contents/MacOS/ -type f -name "pyrcc.so" -delete
  108. find build/${1}.app/Contents/MacOS/ -type f -name "QtMacExtras*" -delete
  109. find build/${1}.app/Contents/MacOS/ -type f -name "QtNetwork*" -delete
  110. find build/${1}.app/Contents/MacOS/ -type f -name "QtSql*" -delete
  111. find build/${1}.app/Contents/MacOS/ -type f -name "QtTest*" -delete
  112. find build/${1}.app/Contents/MacOS/ -type f -name "QtXml*" -delete
  113. #find build/${1}.app/Contents/MacOS/ -type f -name "*.pyc" -delete
  114. rm -rf build/${1}.app/Contents/MacOS/lib/PyQt5/uic
  115. # adjust binaries
  116. (cd build/${1}.app/Contents/MacOS && \
  117. for f in `find . -type f | grep -e /Qt -e QOpenGL -e libq -e carlastyle.dylib -e sip.so`; do \
  118. $(call PATCH_QT_DEPENDENCIES,$$f); \
  119. done)
  120. endef
  121. build/Carla.app/Contents/Info.plist: $(CARLA_APP_FILES)
  122. $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla)
  123. # extra step for standalone, symlink resources used in plugin UIs
  124. mkdir -p build/Carla.app/Contents/MacOS/resources
  125. (cd build/Carla.app/Contents/MacOS/resources && \
  126. ln -sf ../Qt* ../lib ../iconengines ../imageformats ../platforms ../styles . && \
  127. ln -sf carla-plugin$(APP_EXT) carla-plugin-patchbay$(APP_EXT))
  128. # mark as done
  129. touch $@
  130. build/Carla-Control.app/Contents/Info.plist: $(CARLA_CONTROL_APP_FILES)
  131. $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla-Control)
  132. # mark as done
  133. touch $@
  134. # ----------------------------------------------------------------------------------------------------------------------------
  135. # macOS application bundle, depends on cxfreeze library.zip
  136. define GENERATE_LIBRARY_ZIP
  137. env PYTHONPATH=$(CURDIR)/source/frontend SCRIPT_NAME=${1} python3 ./data/macos/bundle.py bdist_mac --bundle-name=${1}
  138. endef
  139. # ----------------------------------------------------------------------------------------------------------------------------
  140. build/Carla.app/Contents/MacOS/Carla: build/Carla.app/Contents/MacOS/lib/library.zip
  141. build/Carla.app/Contents/MacOS/lib/library.zip: $(CARLA_APP_ZIPS) data/macos/bundle.py data/macos/Carla.plist source/frontend/*
  142. $(call GENERATE_LIBRARY_ZIP,Carla)
  143. # merge all zips into 1
  144. rm -rf build/Carla.app/Contents/MacOS/lib/_lib
  145. mkdir build/Carla.app/Contents/MacOS/lib/_lib
  146. (cd build/Carla.app/Contents/MacOS/lib/_lib && \
  147. mv ../library.zip ../library-main.zip && \
  148. $(_PLUGIN_UIS:%=unzip -n $(CURDIR)/build/%.app/Contents/MacOS/lib/library.zip &&) \
  149. unzip -o ../library-main.zip && \
  150. zip -r -9 ../library.zip *)
  151. rm -rf build/Carla.app/Contents/MacOS/lib/_lib
  152. rm -rf build/Carla.app/Contents/MacOS/lib/library-main.zip
  153. # ----------------------------------------------------------------------------------------------------------------------------
  154. build/Carla-Control.app/Contents/MacOS/Carla-Control: build/Carla-Control.app/Contents/MacOS/lib/library.zip
  155. build/Carla-Control.app/Contents/MacOS/lib/library.zip: data/macos/bundle.py data/macos/Carla-Control.plist source/frontend/*
  156. $(call GENERATE_LIBRARY_ZIP,Carla-Control)
  157. # ----------------------------------------------------------------------------------------------------------------------------
  158. # macOS plugin UIs (stored in resources, depend on their respective startup script and generation of matching library.zip)
  159. build/Carla.app/Contents/MacOS/resources/%: build/%.app/Contents/MacOS/lib/library.zip
  160. -@mkdir -p $(shell dirname $@)
  161. @cp -v build/$*.app/Contents/MacOS/$* $@
  162. build/%.app/Contents/MacOS/lib/library.zip: data/macos/bundle.py source/frontend/%
  163. $(call GENERATE_LIBRARY_ZIP,$*)
  164. # ----------------------------------------------------------------------------------------------------------------------------
  165. # macOS generic bundle files (either Qt or Carla binaries)
  166. build/Carla.app/Contents/MacOS/Qt% build/Carla-Control.app/Contents/MacOS/Qt%: $(QT5_PREFIX)/lib/Qt%.framework
  167. -@mkdir -p $(shell dirname $@)
  168. @cp -v $</Versions/5/Qt$* $@
  169. $(call PATCH_QT_DEPENDENCIES,$@)
  170. build/Carla.app/Contents/MacOS/iconengines/% build/Carla-Control.app/Contents/MacOS/iconengines/%: $(QT5_PREFIX)/lib/qt5/plugins/iconengines/%
  171. -@mkdir -p $(shell dirname $@)
  172. @cp -v $< $@
  173. $(call PATCH_QT_DEPENDENCIES,$@)
  174. build/Carla.app/Contents/MacOS/imageformats/% build/Carla-Control.app/Contents/MacOS/imageformats/%: $(QT5_PREFIX)/lib/qt5/plugins/imageformats/%
  175. -@mkdir -p $(shell dirname $@)
  176. @cp -v $< $@
  177. $(call PATCH_QT_DEPENDENCIES,$@)
  178. build/Carla.app/Contents/MacOS/platforms/% build/Carla-Control.app/Contents/MacOS/platforms/%: $(QT5_PREFIX)/lib/qt5/plugins/platforms/%
  179. -@mkdir -p $(shell dirname $@)
  180. @cp -v $< $@
  181. $(call PATCH_QT_DEPENDENCIES,$@)
  182. build/Carla.app/Contents/MacOS/styles/%.dylib build/Carla-Control.app/Contents/MacOS/styles/%.dylib: bin/styles/%.dylib
  183. -@mkdir -p $(shell dirname $@)
  184. @cp -v $< $@
  185. $(call PATCH_QT_DEPENDENCIES,$@)
  186. build/Carla.app/Contents/MacOS/% build/Carla-Control.app/Contents/MacOS/%: bin/%
  187. -@mkdir -p $(shell dirname $@)
  188. @cp -v $< $@
  189. # ----------------------------------------------------------------------------------------------------------------------------
  190. # Plugin rules
  191. MACOS_PACKAGE_EXP = -e 's/version="0"/version="$(VERSION)"/'
  192. ifeq ($(CPU_ARM64),true)
  193. MACOS_PACKAGE_EXP += -e 's/hostArchitectures="x86_64"/hostArchitectures="arm64,x86_64"/'
  194. endif
  195. build/Carla-Plugins.pkg: build/carla-lv2.pkg build/carla-vst2fx.pkg build/carla-vst2syn.pkg build/package.xml
  196. productbuild \
  197. --distribution build/package.xml \
  198. --identifier studio.kx.carla \
  199. --package-path "build" \
  200. --version "$(VERSION)" \
  201. "$@"
  202. build/package.xml: data/macos/package.xml
  203. sed $(MACOS_PACKAGE_EXP) $< > $@
  204. build/carla-lv2.pkg: $(_CARLA_LV2_PLUGIN_FILES:%=build/%)
  205. pkgbuild \
  206. --identifier "studio.kx.carla.lv2" \
  207. --install-location "/Library/Audio/Plug-Ins/LV2/carla.lv2/" \
  208. --root "build/carla.lv2/" \
  209. "$@"
  210. build/carla-vst2fx.pkg: $(_CARLA_VST2FX_PLUGIN_FILES:%=build/%)
  211. pkgbuild \
  212. --identifier "studio.kx.carla.vst2fx" \
  213. --install-location "/Library/Audio/Plug-Ins/VST/carlafx.vst/" \
  214. --root "build/carlafx.vst/" \
  215. "$@"
  216. build/carla-vst2syn.pkg: $(_CARLA_VST2SYN_PLUGIN_FILES:%=build/%)
  217. pkgbuild \
  218. --identifier "studio.kx.carla.vst2syn" \
  219. --install-location "/Library/Audio/Plug-Ins/VST/carla.vst/" \
  220. --root "build/carla.vst/" \
  221. "$@"
  222. # ----------------------------------------------------------------------------------------------------------------------------
  223. # LV2 specific files
  224. build/carla.lv2/%$(LIB_EXT): bin/carla.lv2/%$(LIB_EXT)
  225. -@mkdir -p $(shell dirname $@)
  226. @cp -v $< $@
  227. build/carla.lv2/manifest.ttl: bin/carla.lv2/manifest.ttl
  228. -@mkdir -p $(shell dirname $@)
  229. @cp -v bin/carla.lv2/*.ttl build/carla.lv2/
  230. # ----------------------------------------------------------------------------------------------------------------------------
  231. # VST2 specific files
  232. _MACVST_FILES = Contents/Info.plist Contents/PkgInfo Contents/Resources/empty.lproj
  233. build/carla.vst/Contents/MacOS/CarlaVstShell: bin/CarlaVstShell.dylib $(_MACVST_FILES:%=build/carla.vst/%)
  234. -@mkdir -p $(shell dirname $@)
  235. @cp -v $< $@
  236. build/carlafx.vst/Contents/MacOS/CarlaVstFxShell: bin/CarlaVstFxShell.dylib $(_MACVST_FILES:%=build/carlafx.vst/%)
  237. -@mkdir -p $(shell dirname $@)
  238. @cp -v $< $@
  239. # ----------------------------------------------------------------------------------------------------------------------------
  240. build/carla.vst/Contents/Info.plist: data/macos/CarlaVstShell.plist
  241. -@mkdir -p $(shell dirname $@)
  242. @cp -v $< $@
  243. build/carlafx.vst/Contents/Info.plist: data/macos/CarlaVstFxShell.plist
  244. -@mkdir -p $(shell dirname $@)
  245. @cp -v $< $@
  246. build/%.vst/Contents/PkgInfo:
  247. -@mkdir -p $(shell dirname $@)
  248. @echo "BNDL????" > $@
  249. build/%.vst/Contents/Resources/empty.lproj:
  250. -@mkdir -p $(shell dirname $@)
  251. @touch $@
  252. # ----------------------------------------------------------------------------------------------------------------------------
  253. # Generic plugin rules
  254. build/carla%/resources/carla-plugin-patchbay$(APP_EXT): build/carla%/resources/carla-plugin$(APP_EXT)
  255. -@mkdir -p $(shell dirname $@)
  256. @ln -sfv carla-plugin$(APP_EXT) $@
  257. # ----------------------------------------------------------------------------------------------------------------------------
  258. build/carla.lv2/resources/% build/carla.vst/Contents/MacOS/resources/% build/carlafx.vst/Contents/MacOS/resources/%: build/Carla.app/Contents/MacOS/resources/%
  259. -@mkdir -p $(shell dirname $@)
  260. @cp -v $< $@
  261. build/carla.lv2/resources/lib/library.zip build/carla.vst/Contents/MacOS/resources/lib/library.zip build/carlafx.vst/Contents/MacOS/resources/lib/library.zip: build/Carla.app/Contents/MacOS/resources/lib/library.zip
  262. -@mkdir -p $(shell dirname $@)
  263. @cp -rv build/Carla.app/Contents/MacOS/resources/lib/* $(shell dirname $@)/
  264. build/carla.lv2/% build/carla.vst/Contents/MacOS/% build/carlafx.vst/Contents/MacOS/%: build/Carla.app/Contents/MacOS/%
  265. -@mkdir -p $(shell dirname $@)
  266. @cp -v $< $@
  267. # ----------------------------------------------------------------------------------------------------------------------------