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.

444 lines
17KB

  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. PYTHON = $(EXE_WRAPPER) $(shell which python3$(APP_EXT))
  9. ifeq ($(WIN32),true)
  10. QT5_DLL_EXT = .dll
  11. QT5_DLL_V = 5
  12. endif
  13. ifeq ($(MACOS),true)
  14. QT5_LIB_PREFIX = lib
  15. endif
  16. QT5_PREFIX = $(shell pkg-config --variable=prefix Qt5OpenGLExtensions)
  17. # ----------------------------------------------------------------------------------------------------------------------------
  18. _PLUGIN_UIS = \
  19. carla-plugin \
  20. bigmeter-ui \
  21. midipattern-ui \
  22. notes-ui \
  23. xycontroller-ui
  24. _QT5_DLLS = \
  25. Qt$(QT5_DLL_V)Core$(QT5_DLL_EXT) \
  26. Qt$(QT5_DLL_V)Gui$(QT5_DLL_EXT) \
  27. Qt$(QT5_DLL_V)OpenGL$(QT5_DLL_EXT) \
  28. Qt$(QT5_DLL_V)PrintSupport$(QT5_DLL_EXT) \
  29. Qt$(QT5_DLL_V)Svg$(QT5_DLL_EXT) \
  30. Qt$(QT5_DLL_V)Widgets$(QT5_DLL_EXT)
  31. _QT5_PLUGINS = \
  32. iconengines/$(QT5_LIB_PREFIX)qsvgicon$(LIB_EXT) \
  33. imageformats/$(QT5_LIB_PREFIX)qjpeg$(LIB_EXT) \
  34. imageformats/$(QT5_LIB_PREFIX)qsvg$(LIB_EXT)
  35. ifeq ($(MACOS),true)
  36. _QT5_PLUGINS += \
  37. platforms/$(QT5_LIB_PREFIX)qcocoa$(LIB_EXT)
  38. else ifeq ($(WIN32),true)
  39. _QT5_PLUGINS += \
  40. platforms/$(QT5_LIB_PREFIX)qwindows$(LIB_EXT)
  41. endif
  42. # NOTE this has to be hardcoded for now. oh well
  43. ifeq ($(WIN32),true)
  44. _PYTHON_FILES = \
  45. libpython3.8.dll
  46. endif
  47. _THEME_FILES = \
  48. styles/carlastyle.json \
  49. styles/carlastyle$(LIB_EXT)
  50. _CARLA_HOST_FILES = \
  51. carla-bridge-lv2$(LIB_EXT) \
  52. carla-bridge-native$(APP_EXT) \
  53. carla-discovery-native$(APP_EXT) \
  54. libcarla_utils$(LIB_EXT)
  55. # TODO plugin UIs on windows
  56. ifeq ($(MACOS),true)
  57. _CARLA_HOST_FILES += \
  58. $(_PLUGIN_UIS:%=resources/%$(APP_EXT)) \
  59. carla-bridge-lv2-cocoa$(APP_EXT)
  60. endif
  61. _CARLA_APP_FILES = \
  62. Carla$(APP_EXT) \
  63. libcarla_standalone2$(LIB_EXT) \
  64. $(_CARLA_HOST_FILES) \
  65. $(_QT5_DLLS) \
  66. $(_QT5_PLUGINS) \
  67. $(_PYTHON_FILES) \
  68. $(_THEME_FILES)
  69. _CARLA_CONTROL_APP_FILES = \
  70. Carla-Control$(APP_EXT) \
  71. libcarla_utils$(LIB_EXT) \
  72. $(_QT5_DLLS) \
  73. $(_QT5_PLUGINS) \
  74. $(_PYTHON_FILES) \
  75. $(_THEME_FILES)
  76. _CARLA_LV2_PLUGIN_FILES = \
  77. carla.lv2/carla$(LIB_EXT) \
  78. carla.lv2/manifest.ttl \
  79. carla.lv2/resources/carla-plugin-patchbay \
  80. carla.lv2/resources/lib/library.zip \
  81. $(_CARLA_HOST_FILES:%=carla.lv2/%) \
  82. $(_QT5_DLLS:%=carla.lv2/resources/%) \
  83. $(_QT5_PLUGINS:%=carla.lv2/resources/%) \
  84. $(_THEME_FILES:%=carla.lv2/resources/%)
  85. _CARLA_VST2FX_PLUGIN_FILES = \
  86. carlafx.vst/Contents/MacOS/CarlaVstFxShell \
  87. carlafx.vst/Contents/MacOS/resources/carla-plugin-patchbay \
  88. carlafx.vst/Contents/MacOS/resources/lib/library.zip \
  89. $(_CARLA_HOST_FILES:%=carlafx.vst/Contents/MacOS/%) \
  90. $(_QT5_DLLS:%=carlafx.vst/Contents/MacOS/resources/%) \
  91. $(_QT5_PLUGINS:%=carlafx.vst/Contents/MacOS/resources/%) \
  92. $(_THEME_FILES:%=carlafx.vst/Contents/MacOS/resources/%)
  93. _CARLA_VST2SYN_PLUGIN_FILES = \
  94. carla.vst/Contents/MacOS/CarlaVstShell \
  95. carla.vst/Contents/MacOS/resources/carla-plugin-patchbay \
  96. carla.vst/Contents/MacOS/resources/lib/library.zip \
  97. $(_CARLA_HOST_FILES:%=carla.vst/Contents/MacOS/%) \
  98. $(_QT5_DLLS:%=carla.vst/Contents/MacOS/resources/%) \
  99. $(_QT5_PLUGINS:%=carla.vst/Contents/MacOS/resources/%) \
  100. $(_THEME_FILES:%=carla.vst/Contents/MacOS/resources/%)
  101. ifeq ($(WIN32),true)
  102. CARLA_APP_FILES = $(_CARLA_APP_FILES:%=build/Carla/%)
  103. CARLA_APP_ZIPS = $(_PLUGIN_UIS:%=build/%/lib/library.zip)
  104. CARLA_CONTROL_APP_FILES = $(_CARLA_CONTROL_APP_FILES:%=build/Carla-Control/%)
  105. else
  106. CARLA_APP_FILES = $(_CARLA_APP_FILES:%=build/Carla.app/Contents/MacOS/%)
  107. CARLA_APP_ZIPS = $(_PLUGIN_UIS:%=build/%.app/Contents/MacOS/lib/library.zip)
  108. CARLA_CONTROL_APP_FILES = $(_CARLA_CONTROL_APP_FILES:%=build/Carla-Control.app/Contents/MacOS/%)
  109. endif
  110. # ----------------------------------------------------------------------------------------------------------------------------
  111. # entry point
  112. ifeq ($(WIN64),true)
  113. TARGETS = Carla-$(VERSION)-win64.zip
  114. else ifeq ($(WIN32),true)
  115. TARGETS = Carla-$(VERSION)-win32.zip
  116. else
  117. TARGETS = Carla-$(VERSION)-macOS.dmg
  118. endif
  119. dist: $(TARGETS)
  120. # ----------------------------------------------------------------------------------------------------------------------------
  121. # create final file
  122. Carla-$(VERSION)-macOS.dmg: build/Carla.app/Contents/Info.plist build/Carla-Control.app/Contents/Info.plist build/Carla-Plugins.pkg
  123. rm -rf build/macos-pkg $@
  124. mkdir build/macos-pkg
  125. cp -r build/Carla.app build/Carla-Control.app build/Carla-Plugins.pkg data/macos/README build/macos-pkg/
  126. hdiutil create $@ -srcfolder build/macos-pkg -volname "Carla-$(VERSION)" -fs HFS+ -ov
  127. rm -rf build/macos-pkg
  128. Carla-$(VERSION)-win64.zip: $(CARLA_APP_FILES)
  129. $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla)
  130. # env PYTHONPATH=$(CURDIR)/source/frontend $(PYTHON) ./data/windows/app-gui.py build_exe
  131. # ----------------------------------------------------------------------------------------------------------------------------
  132. # macOS final cleanup, after everything is in place
  133. define PATCH_QT_DEPENDENCIES
  134. install_name_tool -change "@rpath/QtCore.framework/Versions/5/QtCore" @executable_path/QtCore ${1} && \
  135. install_name_tool -change "@rpath/QtGui.framework/Versions/5/QtGui" @executable_path/QtGui ${1} && \
  136. install_name_tool -change "@rpath/QtOpenGL.framework/Versions/5/QtOpenGL" @executable_path/QtOpenGL ${1} && \
  137. install_name_tool -change "@rpath/QtPrintSupport.framework/Versions/5/QtPrintSupport" @executable_path/QtPrintSupport ${1} && \
  138. install_name_tool -change "@rpath/QtSvg.framework/Versions/5/QtSvg" @executable_path/QtSvg ${1} && \
  139. install_name_tool -change "@rpath/QtWidgets.framework/Versions/5/QtWidgets" @executable_path/QtWidgets ${1} && \
  140. install_name_tool -change "@rpath/QtMacExtras.framework/Versions/5/QtMacExtras" @executable_path/QtMacExtras ${1}
  141. endef
  142. ifeq ($(MACOS),true)
  143. define CLEANUP_AND_PATCH_CXFREEZE_FILES
  144. # cleanup
  145. find build/${1}.app/Contents/MacOS/ -type f -name "*.py" -delete
  146. find build/${1}.app/Contents/MacOS/ -type f -name "*.pyi" -delete
  147. find build/${1}.app/Contents/MacOS/ -type f -name "pylupdate.so" -delete
  148. find build/${1}.app/Contents/MacOS/ -type f -name "pyrcc.so" -delete
  149. find build/${1}.app/Contents/MacOS/ -type f -name "QtMacExtras*" -delete
  150. find build/${1}.app/Contents/MacOS/ -type f -name "QtNetwork*" -delete
  151. find build/${1}.app/Contents/MacOS/ -type f -name "QtSql*" -delete
  152. find build/${1}.app/Contents/MacOS/ -type f -name "QtTest*" -delete
  153. find build/${1}.app/Contents/MacOS/ -type f -name "QtXml*" -delete
  154. #find build/${1}.app/Contents/MacOS/ -type f -name "*.pyc" -delete
  155. rm -rf build/${1}.app/Contents/MacOS/lib/PyQt5/uic
  156. # adjust binaries
  157. (cd build/${1}.app/Contents/MacOS && \
  158. for f in `find . -type f | grep -e /Qt -e QOpenGL -e libq -e carlastyle.dylib -e sip.so`; do \
  159. $(call PATCH_QT_DEPENDENCIES,$$f); \
  160. done)
  161. endef
  162. else ifeq ($(WIN32),true)
  163. define CLEANUP_AND_PATCH_CXFREEZE_FILES
  164. # cleanup
  165. find build/${1}/ -type f -name "*.py" -delete
  166. find build/${1}/ -type f -name "*.pyi" -delete
  167. find build/${1}/ -type f -name "pylupdate.so" -delete
  168. find build/${1}/ -type f -name "pyrcc.so" -delete
  169. find build/${1}/ -type f -name "QtMacExtras*" -delete
  170. find build/${1}/ -type f -name "QtNetwork*" -delete
  171. find build/${1}/ -type f -name "QtSql*" -delete
  172. find build/${1}/ -type f -name "QtTest*" -delete
  173. find build/${1}/ -type f -name "QtXml*" -delete
  174. #find build/${1}/ -type f -name "*.pyc" -delete
  175. rm -rf build/${1}/lib/PyQt5/uic
  176. endef
  177. endif
  178. build/Carla.app/Contents/Info.plist: $(CARLA_APP_FILES)
  179. $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla)
  180. # extra step for standalone, symlink resources used in plugin UIs
  181. mkdir -p build/Carla.app/Contents/MacOS/resources
  182. (cd build/Carla.app/Contents/MacOS/resources && \
  183. ln -sf ../Qt* ../lib ../iconengines ../imageformats ../platforms ../styles . && \
  184. ln -sf carla-plugin$(APP_EXT) carla-plugin-patchbay$(APP_EXT))
  185. # mark as done
  186. touch $@
  187. build/Carla-Control.app/Contents/Info.plist: $(CARLA_CONTROL_APP_FILES)
  188. $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla-Control)
  189. # mark as done
  190. touch $@
  191. # ----------------------------------------------------------------------------------------------------------------------------
  192. # application bundle, depends on cxfreeze library.zip
  193. ifeq ($(WIN32),true)
  194. define GENERATE_LIBRARY_ZIP
  195. # FIXME
  196. env PYTHONPATH=$(CURDIR)/source/frontend SCRIPT_NAME=${1} $(PYTHON) ./data/windows/app-gui.py build_exe
  197. endef
  198. else
  199. define GENERATE_LIBRARY_ZIP
  200. env PYTHONPATH=$(CURDIR)/source/frontend SCRIPT_NAME=${1} $(PYTHON) ./data/macos/bundle.py bdist_mac --bundle-name=${1}
  201. endef
  202. endif
  203. # ----------------------------------------------------------------------------------------------------------------------------
  204. build/Carla.app/Contents/MacOS/Carla: build/Carla.app/Contents/MacOS/lib/library.zip
  205. build/Carla.app/Contents/MacOS/lib/library.zip: $(CARLA_APP_ZIPS) data/macos/bundle.py data/macos/Carla.plist source/frontend/*
  206. $(call GENERATE_LIBRARY_ZIP,Carla)
  207. # merge all zips into 1
  208. rm -rf build/Carla.app/Contents/MacOS/lib/_lib
  209. mkdir build/Carla.app/Contents/MacOS/lib/_lib
  210. (cd build/Carla.app/Contents/MacOS/lib/_lib && \
  211. mv ../library.zip ../library-main.zip && \
  212. $(_PLUGIN_UIS:%=unzip -n $(CURDIR)/build/%.app/Contents/MacOS/lib/library.zip &&) \
  213. unzip -o ../library-main.zip && \
  214. zip -r -9 ../library.zip *)
  215. rm -rf build/Carla.app/Contents/MacOS/lib/_lib
  216. rm -rf build/Carla.app/Contents/MacOS/lib/library-main.zip
  217. # ----------------------------------------------------------------------------------------------------------------------------
  218. build/Carla/Carla.exe: build/Carla/lib/library.zip
  219. build/Carla/lib/library.zip: data/windows/app-gui.py source/frontend/*
  220. $(call GENERATE_LIBRARY_ZIP,Carla)
  221. # $(CARLA_APP_ZIPS)
  222. # ----------------------------------------------------------------------------------------------------------------------------
  223. build/Carla-Control.app/Contents/MacOS/Carla-Control: build/Carla-Control.app/Contents/MacOS/lib/library.zip
  224. build/Carla-Control.app/Contents/MacOS/lib/library.zip: data/macos/bundle.py data/macos/Carla-Control.plist source/frontend/*
  225. $(call GENERATE_LIBRARY_ZIP,Carla-Control)
  226. # ----------------------------------------------------------------------------------------------------------------------------
  227. # macOS plugin UIs (stored in resources, depend on their respective startup script and generation of matching library.zip)
  228. build/Carla.app/Contents/MacOS/resources/%: build/%.app/Contents/MacOS/lib/library.zip
  229. -@mkdir -p $(shell dirname $@)
  230. @cp -v build/$*.app/Contents/MacOS/$* $@
  231. build/%.app/Contents/MacOS/lib/library.zip: data/macos/bundle.py source/frontend/%
  232. $(call GENERATE_LIBRARY_ZIP,$*)
  233. # ----------------------------------------------------------------------------------------------------------------------------
  234. # macOS generic bundle files (either Qt or Carla binaries)
  235. build/Carla.app/Contents/MacOS/Qt% build/Carla-Control.app/Contents/MacOS/Qt%: $(QT5_PREFIX)/lib/Qt%.framework
  236. -@mkdir -p $(shell dirname $@)
  237. @cp -v $</Versions/5/Qt$* $@
  238. $(call PATCH_QT_DEPENDENCIES,$@)
  239. build/Carla.app/Contents/MacOS/iconengines/% build/Carla-Control.app/Contents/MacOS/iconengines/%: $(QT5_PREFIX)/lib/qt5/plugins/iconengines/%
  240. -@mkdir -p $(shell dirname $@)
  241. @cp -v $< $@
  242. $(call PATCH_QT_DEPENDENCIES,$@)
  243. build/Carla.app/Contents/MacOS/imageformats/% build/Carla-Control.app/Contents/MacOS/imageformats/%: $(QT5_PREFIX)/lib/qt5/plugins/imageformats/%
  244. -@mkdir -p $(shell dirname $@)
  245. @cp -v $< $@
  246. $(call PATCH_QT_DEPENDENCIES,$@)
  247. build/Carla.app/Contents/MacOS/platforms/% build/Carla-Control.app/Contents/MacOS/platforms/%: $(QT5_PREFIX)/lib/qt5/plugins/platforms/%
  248. -@mkdir -p $(shell dirname $@)
  249. @cp -v $< $@
  250. $(call PATCH_QT_DEPENDENCIES,$@)
  251. build/Carla.app/Contents/MacOS/styles/%.dylib build/Carla-Control.app/Contents/MacOS/styles/%.dylib: bin/styles/%.dylib
  252. -@mkdir -p $(shell dirname $@)
  253. @cp -v $< $@
  254. $(call PATCH_QT_DEPENDENCIES,$@)
  255. build/Carla.app/Contents/MacOS/% build/Carla-Control.app/Contents/MacOS/%: bin/%
  256. -@mkdir -p $(shell dirname $@)
  257. @cp -v $< $@
  258. # ----------------------------------------------------------------------------------------------------------------------------
  259. # win32 generic bundle files (either Qt or Carla binaries)
  260. build/Carla/libpython3% build/Carla-Control/libpython3%: $(QT5_PREFIX)/bin/libpython3%
  261. -@mkdir -p $(shell dirname $@)
  262. @cp -v $< $@
  263. build/Carla/Qt5% build/Carla-Control/Qt5%: $(QT5_PREFIX)/bin/Qt5%
  264. -@mkdir -p $(shell dirname $@)
  265. @cp -v $< $@
  266. build/Carla/iconengines/% build/Carla-Control/iconengines/%: $(QT5_PREFIX)/lib/qt5/plugins/iconengines/%
  267. -@mkdir -p $(shell dirname $@)
  268. @cp -v $< $@
  269. build/Carla/imageformats/% build/Carla-Control/imageformats/%: $(QT5_PREFIX)/lib/qt5/plugins/imageformats/%
  270. -@mkdir -p $(shell dirname $@)
  271. @cp -v $< $@
  272. build/Carla/platforms/% build/Carla-Control/platforms/%: $(QT5_PREFIX)/lib/qt5/plugins/platforms/%
  273. -@mkdir -p $(shell dirname $@)
  274. @cp -v $< $@
  275. build/Carla/% build/Carla-Control/%: bin/%
  276. -@mkdir -p $(shell dirname $@)
  277. @cp -v $< $@
  278. # ----------------------------------------------------------------------------------------------------------------------------
  279. # Plugin rules
  280. MACOS_PACKAGE_EXP = -e 's/version="0"/version="$(VERSION)"/'
  281. ifeq ($(CPU_ARM64),true)
  282. MACOS_PACKAGE_EXP += -e 's/hostArchitectures="x86_64"/hostArchitectures="arm64,x86_64"/'
  283. endif
  284. build/Carla-Plugins.pkg: build/carla-lv2.pkg build/carla-vst2fx.pkg build/carla-vst2syn.pkg build/package.xml
  285. productbuild \
  286. --distribution build/package.xml \
  287. --identifier studio.kx.carla \
  288. --package-path "build" \
  289. --version "$(VERSION)" \
  290. "$@"
  291. build/package.xml: data/macos/package.xml
  292. sed $(MACOS_PACKAGE_EXP) $< > $@
  293. build/carla-lv2.pkg: $(_CARLA_LV2_PLUGIN_FILES:%=build/%)
  294. pkgbuild \
  295. --identifier "studio.kx.carla.lv2" \
  296. --install-location "/Library/Audio/Plug-Ins/LV2/carla.lv2/" \
  297. --root "build/carla.lv2/" \
  298. "$@"
  299. build/carla-vst2fx.pkg: $(_CARLA_VST2FX_PLUGIN_FILES:%=build/%)
  300. pkgbuild \
  301. --identifier "studio.kx.carla.vst2fx" \
  302. --install-location "/Library/Audio/Plug-Ins/VST/carlafx.vst/" \
  303. --root "build/carlafx.vst/" \
  304. "$@"
  305. build/carla-vst2syn.pkg: $(_CARLA_VST2SYN_PLUGIN_FILES:%=build/%)
  306. pkgbuild \
  307. --identifier "studio.kx.carla.vst2syn" \
  308. --install-location "/Library/Audio/Plug-Ins/VST/carla.vst/" \
  309. --root "build/carla.vst/" \
  310. "$@"
  311. # ----------------------------------------------------------------------------------------------------------------------------
  312. # LV2 specific files
  313. build/carla.lv2/%$(LIB_EXT): bin/carla.lv2/%$(LIB_EXT)
  314. -@mkdir -p $(shell dirname $@)
  315. @cp -v $< $@
  316. build/carla.lv2/manifest.ttl: bin/carla.lv2/manifest.ttl
  317. -@mkdir -p $(shell dirname $@)
  318. @cp -v bin/carla.lv2/*.ttl build/carla.lv2/
  319. # ----------------------------------------------------------------------------------------------------------------------------
  320. # VST2 specific files
  321. _MACVST_FILES = Contents/Info.plist Contents/PkgInfo Contents/Resources/empty.lproj
  322. build/carla.vst/Contents/MacOS/CarlaVstShell: bin/CarlaVstShell.dylib $(_MACVST_FILES:%=build/carla.vst/%)
  323. -@mkdir -p $(shell dirname $@)
  324. @cp -v $< $@
  325. build/carlafx.vst/Contents/MacOS/CarlaVstFxShell: bin/CarlaVstFxShell.dylib $(_MACVST_FILES:%=build/carlafx.vst/%)
  326. -@mkdir -p $(shell dirname $@)
  327. @cp -v $< $@
  328. # ----------------------------------------------------------------------------------------------------------------------------
  329. build/carla.vst/Contents/Info.plist: data/macos/CarlaVstShell.plist
  330. -@mkdir -p $(shell dirname $@)
  331. @cp -v $< $@
  332. build/carlafx.vst/Contents/Info.plist: data/macos/CarlaVstFxShell.plist
  333. -@mkdir -p $(shell dirname $@)
  334. @cp -v $< $@
  335. build/%.vst/Contents/PkgInfo:
  336. -@mkdir -p $(shell dirname $@)
  337. @echo "BNDL????" > $@
  338. build/%.vst/Contents/Resources/empty.lproj:
  339. -@mkdir -p $(shell dirname $@)
  340. @touch $@
  341. # ----------------------------------------------------------------------------------------------------------------------------
  342. # Generic plugin rules
  343. build/carla%/resources/carla-plugin-patchbay$(APP_EXT): build/carla%/resources/carla-plugin$(APP_EXT)
  344. -@mkdir -p $(shell dirname $@)
  345. @ln -sfv carla-plugin$(APP_EXT) $@
  346. # ----------------------------------------------------------------------------------------------------------------------------
  347. build/carla.lv2/resources/% build/carla.vst/Contents/MacOS/resources/% build/carlafx.vst/Contents/MacOS/resources/%: build/Carla.app/Contents/MacOS/resources/%
  348. -@mkdir -p $(shell dirname $@)
  349. @cp -v $< $@
  350. 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
  351. -@mkdir -p $(shell dirname $@)
  352. @cp -rv build/Carla.app/Contents/MacOS/resources/lib/* $(shell dirname $@)/
  353. build/carla.lv2/% build/carla.vst/Contents/MacOS/% build/carlafx.vst/Contents/MacOS/%: build/Carla.app/Contents/MacOS/%
  354. -@mkdir -p $(shell dirname $@)
  355. @cp -v $< $@
  356. # ----------------------------------------------------------------------------------------------------------------------------