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.

Makefile.dist.mk 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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 = \
  82. build/Carla.app/Contents/Info.plist \
  83. build/Carla-Control.app/Contents/Info.plist \
  84. build/Carla-Plugins.pkg
  85. dist: $(TARGETS)
  86. # ----------------------------------------------------------------------------------------------------------------------------
  87. # final cleanup, after everything is in place
  88. define PATCH_QT_DEPENDENCIES
  89. install_name_tool -change "@rpath/QtCore.framework/Versions/5/QtCore" @executable_path/QtCore ${1} && \
  90. install_name_tool -change "@rpath/QtGui.framework/Versions/5/QtGui" @executable_path/QtGui ${1} && \
  91. install_name_tool -change "@rpath/QtOpenGL.framework/Versions/5/QtOpenGL" @executable_path/QtOpenGL ${1} && \
  92. install_name_tool -change "@rpath/QtPrintSupport.framework/Versions/5/QtPrintSupport" @executable_path/QtPrintSupport ${1} && \
  93. install_name_tool -change "@rpath/QtSvg.framework/Versions/5/QtSvg" @executable_path/QtSvg ${1} && \
  94. install_name_tool -change "@rpath/QtWidgets.framework/Versions/5/QtWidgets" @executable_path/QtWidgets ${1} && \
  95. install_name_tool -change "@rpath/QtMacExtras.framework/Versions/5/QtMacExtras" @executable_path/QtMacExtras ${1}
  96. endef
  97. define CLEANUP_AND_PATCH_CXFREEZE_FILES
  98. # cleanup
  99. find build/${1}.app/Contents/MacOS/ -type f -name "*.py" -delete
  100. find build/${1}.app/Contents/MacOS/ -type f -name "*.pyi" -delete
  101. find build/${1}.app/Contents/MacOS/ -type f -name "pylupdate.so" -delete
  102. find build/${1}.app/Contents/MacOS/ -type f -name "pyrcc.so" -delete
  103. find build/${1}.app/Contents/MacOS/ -type f -name "QtMacExtras*" -delete
  104. find build/${1}.app/Contents/MacOS/ -type f -name "QtNetwork*" -delete
  105. find build/${1}.app/Contents/MacOS/ -type f -name "QtSql*" -delete
  106. find build/${1}.app/Contents/MacOS/ -type f -name "QtTest*" -delete
  107. find build/${1}.app/Contents/MacOS/ -type f -name "QtXml*" -delete
  108. #find build/${1}.app/Contents/MacOS/ -type f -name "*.pyc" -delete
  109. rm -rf build/${1}.app/Contents/MacOS/lib/PyQt5/uic
  110. # adjust binaries
  111. (cd build/${1}.app/Contents/MacOS && \
  112. for f in `find . -type f | grep -e /Qt -e QOpenGL -e libq -e carlastyle.dylib -e sip.so`; do \
  113. $(call PATCH_QT_DEPENDENCIES,$$f); \
  114. done)
  115. endef
  116. build/Carla.app/Contents/Info.plist: $(CARLA_APP_FILES)
  117. $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla)
  118. # extra step for standalone, symlink resources used in plugin UIs
  119. mkdir -p build/Carla.app/Contents/MacOS/resources
  120. (cd build/Carla.app/Contents/MacOS/resources && \
  121. ln -sf ../Qt* ../lib ../iconengines ../imageformats ../platforms ../styles . && \
  122. ln -sf carla-plugin$(APP_EXT) carla-plugin-patchbay$(APP_EXT))
  123. # mark as done
  124. touch $@
  125. build/Carla-Control.app/Contents/Info.plist: $(CARLA_CONTROL_APP_FILES)
  126. $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla-Control)
  127. # mark as done
  128. touch $@
  129. # ----------------------------------------------------------------------------------------------------------------------------
  130. # macOS application bundle, depends on cxfreeze library.zip
  131. define GENERATE_LIBRARY_ZIP
  132. env PYTHONPATH=$(CURDIR)/source/frontend SCRIPT_NAME=${1} python3 ./data/macos/bundle.py bdist_mac --bundle-name=${1}
  133. endef
  134. # ----------------------------------------------------------------------------------------------------------------------------
  135. build/Carla.app/Contents/MacOS/Carla: build/Carla.app/Contents/MacOS/lib/library.zip
  136. build/Carla.app/Contents/MacOS/lib/library.zip: $(CARLA_APP_ZIPS) data/macos/bundle.py data/macos/Carla_Info.plist source/frontend/*
  137. $(call GENERATE_LIBRARY_ZIP,Carla)
  138. # merge all zips into 1
  139. rm -rf build/Carla.app/Contents/MacOS/lib/_lib
  140. mkdir build/Carla.app/Contents/MacOS/lib/_lib
  141. (cd build/Carla.app/Contents/MacOS/lib/_lib && \
  142. mv ../library.zip ../library-main.zip && \
  143. $(_PLUGIN_UIS:%=unzip -n $(CURDIR)/build/%.app/Contents/MacOS/lib/library.zip &&) \
  144. unzip -o ../library-main.zip && \
  145. zip -r -9 ../library.zip *)
  146. rm -rf build/Carla.app/Contents/MacOS/lib/_lib
  147. rm -rf build/Carla.app/Contents/MacOS/lib/library-main.zip
  148. # ----------------------------------------------------------------------------------------------------------------------------
  149. build/Carla-Control.app/Contents/MacOS/Carla-Control: build/Carla-Control.app/Contents/MacOS/lib/library.zip
  150. build/Carla-Control.app/Contents/MacOS/lib/library.zip: data/macos/bundle.py data/macos/Carla-Control_Info.plist source/frontend/*
  151. $(call GENERATE_LIBRARY_ZIP,Carla-Control)
  152. # ----------------------------------------------------------------------------------------------------------------------------
  153. # macOS plugin UIs (stored in resources, depend on their respective startup script and generation of matching library.zip)
  154. build/Carla.app/Contents/MacOS/resources/%: build/%.app/Contents/MacOS/lib/library.zip
  155. -@mkdir -p $(shell dirname $@)
  156. @cp -v build/$*.app/Contents/MacOS/$* $@
  157. build/%.app/Contents/MacOS/lib/library.zip: data/macos/bundle.py source/frontend/%
  158. $(call GENERATE_LIBRARY_ZIP,$*)
  159. # ----------------------------------------------------------------------------------------------------------------------------
  160. # macOS generic bundle files (either Qt or Carla binaries)
  161. build/Carla.app/Contents/MacOS/Qt% build/Carla-Control.app/Contents/MacOS/Qt%: $(QT5_PREFIX)/lib/Qt%.framework
  162. -@mkdir -p $(shell dirname $@)
  163. @cp -v $</Versions/5/Qt$* $@
  164. $(call PATCH_QT_DEPENDENCIES,$@)
  165. build/Carla.app/Contents/MacOS/iconengines/% build/Carla-Control.app/Contents/MacOS/iconengines/%: $(QT5_PREFIX)/lib/qt5/plugins/iconengines/%
  166. -@mkdir -p $(shell dirname $@)
  167. @cp -v $< $@
  168. $(call PATCH_QT_DEPENDENCIES,$@)
  169. build/Carla.app/Contents/MacOS/imageformats/% build/Carla-Control.app/Contents/MacOS/imageformats/%: $(QT5_PREFIX)/lib/qt5/plugins/imageformats/%
  170. -@mkdir -p $(shell dirname $@)
  171. @cp -v $< $@
  172. $(call PATCH_QT_DEPENDENCIES,$@)
  173. build/Carla.app/Contents/MacOS/platforms/% build/Carla-Control.app/Contents/MacOS/platforms/%: $(QT5_PREFIX)/lib/qt5/plugins/platforms/%
  174. -@mkdir -p $(shell dirname $@)
  175. @cp -v $< $@
  176. $(call PATCH_QT_DEPENDENCIES,$@)
  177. build/Carla.app/Contents/MacOS/styles/%.dylib build/Carla-Control.app/Contents/MacOS/styles/%.dylib: bin/styles/%.dylib
  178. -@mkdir -p $(shell dirname $@)
  179. @cp -v $< $@
  180. $(call PATCH_QT_DEPENDENCIES,$@)
  181. build/Carla.app/Contents/MacOS/% build/Carla-Control.app/Contents/MacOS/%: bin/%
  182. -@mkdir -p $(shell dirname $@)
  183. @cp -v $< $@
  184. # ----------------------------------------------------------------------------------------------------------------------------
  185. # Plugin rules
  186. build/Carla-Plugins.pkg: build/carla-lv2.pkg build/carla-vst2fx.pkg build/carla-vst2syn.pkg
  187. productbuild \
  188. --distribution data/macos/package.xml \
  189. --identifier studio.kx.carla \
  190. --package-path "build" \
  191. --version "2.3.0-alpha3" \
  192. "$@"
  193. build/carla-lv2.pkg: $(_CARLA_LV2_PLUGIN_FILES:%=build/%)
  194. pkgbuild \
  195. --identifier "studio.kx.carla.lv2" \
  196. --install-location "/Library/Audio/Plug-Ins/LV2/carla.lv2/" \
  197. --root "build/carla.lv2/" \
  198. "$@"
  199. build/carla-vst2fx.pkg: $(_CARLA_VST2FX_PLUGIN_FILES:%=build/%)
  200. pkgbuild \
  201. --identifier "studio.kx.carla.vst2fx" \
  202. --install-location "/Library/Audio/Plug-Ins/VST/carlafx.vst/" \
  203. --root "build/carlafx.vst/" \
  204. "$@"
  205. build/carla-vst2syn.pkg: $(_CARLA_VST2SYN_PLUGIN_FILES:%=build/%)
  206. pkgbuild \
  207. --identifier "studio.kx.carla.vst2syn" \
  208. --install-location "/Library/Audio/Plug-Ins/VST/carla.vst/" \
  209. --root "build/carla.vst/" \
  210. "$@"
  211. # ----------------------------------------------------------------------------------------------------------------------------
  212. # LV2 specific files
  213. build/carla.lv2/%$(LIB_EXT): bin/carla.lv2/%$(LIB_EXT)
  214. -@mkdir -p $(shell dirname $@)
  215. @cp -v $< $@
  216. build/carla.lv2/manifest.ttl: bin/carla.lv2/manifest.ttl
  217. -@mkdir -p $(shell dirname $@)
  218. @cp -v bin/carla.lv2/*.ttl build/carla.lv2/
  219. # ----------------------------------------------------------------------------------------------------------------------------
  220. # VST2 specific files
  221. _MACVST_FILES = Contents/Info.plist Contents/PkgInfo Contents/Resources/empty.lproj
  222. build/carla.vst/Contents/MacOS/CarlaVstShell: bin/CarlaVstShell.dylib $(_MACVST_FILES:%=build/carla.vst/%)
  223. -@mkdir -p $(shell dirname $@)
  224. @cp -v $< $@
  225. build/carlafx.vst/Contents/MacOS/CarlaVstFxShell: bin/CarlaVstFxShell.dylib $(_MACVST_FILES:%=build/carlafx.vst/%)
  226. -@mkdir -p $(shell dirname $@)
  227. @cp -v $< $@
  228. # ----------------------------------------------------------------------------------------------------------------------------
  229. build/carla.vst/Contents/Info.plist: data/macos/CarlaVstShell.plist
  230. -@mkdir -p $(shell dirname $@)
  231. @cp -v $< $@
  232. build/carlafx.vst/Contents/Info.plist: data/macos/CarlaVstFxShell.plist
  233. -@mkdir -p $(shell dirname $@)
  234. @cp -v $< $@
  235. build/%.vst/Contents/PkgInfo:
  236. -@mkdir -p $(shell dirname $@)
  237. @echo "BNDL????" > $@
  238. build/%.vst/Contents/Resources/empty.lproj:
  239. -@mkdir -p $(shell dirname $@)
  240. @touch $@
  241. # ----------------------------------------------------------------------------------------------------------------------------
  242. # Generic plugin rules
  243. build/carla%/resources/carla-plugin-patchbay$(APP_EXT): build/carla%/resources/carla-plugin$(APP_EXT)
  244. -@mkdir -p $(shell dirname $@)
  245. @ln -sfv carla-plugin$(APP_EXT) $@
  246. # ----------------------------------------------------------------------------------------------------------------------------
  247. build/carla.lv2/resources/% build/carla.vst/Contents/MacOS/resources/% build/carlafx.vst/Contents/MacOS/resources/%: build/Carla.app/Contents/MacOS/resources/%
  248. -@mkdir -p $(shell dirname $@)
  249. @cp -v $< $@
  250. 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
  251. -@mkdir -p $(shell dirname $@)
  252. @cp -rv build/Carla.app/Contents/MacOS/resources/lib/* $(shell dirname $@)/
  253. build/carla.lv2/% build/carla.vst/Contents/MacOS/% build/carlafx.vst/Contents/MacOS/%: build/Carla.app/Contents/MacOS/%
  254. -@mkdir -p $(shell dirname $@)
  255. @cp -v $< $@
  256. # ----------------------------------------------------------------------------------------------------------------------------