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.

436 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/% build/Carla-Control/%: bin/%
  270. -@mkdir -p $(shell dirname $@)
  271. @cp -v $< $@
  272. # ----------------------------------------------------------------------------------------------------------------------------
  273. # Plugin rules
  274. MACOS_PACKAGE_EXP = -e 's/version="0"/version="$(VERSION)"/'
  275. ifeq ($(CPU_ARM64),true)
  276. MACOS_PACKAGE_EXP += -e 's/hostArchitectures="x86_64"/hostArchitectures="arm64,x86_64"/'
  277. endif
  278. build/Carla-Plugins.pkg: build/carla-lv2.pkg build/carla-vst2fx.pkg build/carla-vst2syn.pkg build/package.xml
  279. productbuild \
  280. --distribution build/package.xml \
  281. --identifier studio.kx.carla \
  282. --package-path "build" \
  283. --version "$(VERSION)" \
  284. "$@"
  285. build/package.xml: data/macos/package.xml
  286. sed $(MACOS_PACKAGE_EXP) $< > $@
  287. build/carla-lv2.pkg: $(_CARLA_LV2_PLUGIN_FILES:%=build/%)
  288. pkgbuild \
  289. --identifier "studio.kx.carla.lv2" \
  290. --install-location "/Library/Audio/Plug-Ins/LV2/carla.lv2/" \
  291. --root "build/carla.lv2/" \
  292. "$@"
  293. build/carla-vst2fx.pkg: $(_CARLA_VST2FX_PLUGIN_FILES:%=build/%)
  294. pkgbuild \
  295. --identifier "studio.kx.carla.vst2fx" \
  296. --install-location "/Library/Audio/Plug-Ins/VST/carlafx.vst/" \
  297. --root "build/carlafx.vst/" \
  298. "$@"
  299. build/carla-vst2syn.pkg: $(_CARLA_VST2SYN_PLUGIN_FILES:%=build/%)
  300. pkgbuild \
  301. --identifier "studio.kx.carla.vst2syn" \
  302. --install-location "/Library/Audio/Plug-Ins/VST/carla.vst/" \
  303. --root "build/carla.vst/" \
  304. "$@"
  305. # ----------------------------------------------------------------------------------------------------------------------------
  306. # LV2 specific files
  307. build/carla.lv2/%$(LIB_EXT): bin/carla.lv2/%$(LIB_EXT)
  308. -@mkdir -p $(shell dirname $@)
  309. @cp -v $< $@
  310. build/carla.lv2/manifest.ttl: bin/carla.lv2/manifest.ttl
  311. -@mkdir -p $(shell dirname $@)
  312. @cp -v bin/carla.lv2/*.ttl build/carla.lv2/
  313. # ----------------------------------------------------------------------------------------------------------------------------
  314. # VST2 specific files
  315. _MACVST_FILES = Contents/Info.plist Contents/PkgInfo Contents/Resources/empty.lproj
  316. build/carla.vst/Contents/MacOS/CarlaVstShell: bin/CarlaVstShell.dylib $(_MACVST_FILES:%=build/carla.vst/%)
  317. -@mkdir -p $(shell dirname $@)
  318. @cp -v $< $@
  319. build/carlafx.vst/Contents/MacOS/CarlaVstFxShell: bin/CarlaVstFxShell.dylib $(_MACVST_FILES:%=build/carlafx.vst/%)
  320. -@mkdir -p $(shell dirname $@)
  321. @cp -v $< $@
  322. # ----------------------------------------------------------------------------------------------------------------------------
  323. build/carla.vst/Contents/Info.plist: data/macos/CarlaVstShell.plist
  324. -@mkdir -p $(shell dirname $@)
  325. @cp -v $< $@
  326. build/carlafx.vst/Contents/Info.plist: data/macos/CarlaVstFxShell.plist
  327. -@mkdir -p $(shell dirname $@)
  328. @cp -v $< $@
  329. build/%.vst/Contents/PkgInfo:
  330. -@mkdir -p $(shell dirname $@)
  331. @echo "BNDL????" > $@
  332. build/%.vst/Contents/Resources/empty.lproj:
  333. -@mkdir -p $(shell dirname $@)
  334. @touch $@
  335. # ----------------------------------------------------------------------------------------------------------------------------
  336. # Generic plugin rules
  337. build/carla%/resources/carla-plugin-patchbay$(APP_EXT): build/carla%/resources/carla-plugin$(APP_EXT)
  338. -@mkdir -p $(shell dirname $@)
  339. @ln -sfv carla-plugin$(APP_EXT) $@
  340. # ----------------------------------------------------------------------------------------------------------------------------
  341. build/carla.lv2/resources/% build/carla.vst/Contents/MacOS/resources/% build/carlafx.vst/Contents/MacOS/resources/%: build/Carla.app/Contents/MacOS/resources/%
  342. -@mkdir -p $(shell dirname $@)
  343. @cp -v $< $@
  344. 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
  345. -@mkdir -p $(shell dirname $@)
  346. @cp -rv build/Carla.app/Contents/MacOS/resources/lib/* $(shell dirname $@)/
  347. build/carla.lv2/% build/carla.vst/Contents/MacOS/% build/carlafx.vst/Contents/MacOS/%: build/Carla.app/Contents/MacOS/%
  348. -@mkdir -p $(shell dirname $@)
  349. @cp -v $< $@
  350. # ----------------------------------------------------------------------------------------------------------------------------