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.

379 lines
10KB

  1. #!/usr/bin/make -f
  2. # Makefile for DISTRHO Plugins #
  3. # ---------------------------- #
  4. # Created by falkTX
  5. #
  6. # Must have NAME defined
  7. ifeq ($(NAME),Cardinal)
  8. CARDINAL_VARIANT = main
  9. else ifeq ($(NAME),CardinalFX)
  10. CARDINAL_VARIANT = fx
  11. else ifeq ($(NAME),CardinalSynth)
  12. CARDINAL_VARIANT = synth
  13. endif
  14. # --------------------------------------------------------------
  15. # Carla stuff
  16. ifneq ($(STATIC_BUILD),true)
  17. CWD = ../../carla/source
  18. STATIC_PLUGIN_TARGET = true
  19. include $(CWD)/Makefile.deps.mk
  20. CARLA_BUILD_DIR = ../../carla/build
  21. ifeq ($(DEBUG),true)
  22. CARLA_BUILD_TYPE = Debug
  23. else
  24. CARLA_BUILD_TYPE = Release
  25. endif
  26. CARLA_EXTRA_LIBS = $(CARLA_BUILD_DIR)/plugin/$(CARLA_BUILD_TYPE)/carla-host-plugin.cpp.o
  27. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/carla_engine_plugin.a
  28. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/carla_plugin.a
  29. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/native-plugins.a
  30. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/audio_decoder.a
  31. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/jackbridge.min.a
  32. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/lilv.a
  33. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/rtmempool.a
  34. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/sfzero.a
  35. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/water.a
  36. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/ysfx.a
  37. CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/zita-resampler.a
  38. endif # STATIC_BUILD
  39. # --------------------------------------------------------------
  40. # Import base definitions
  41. NVG_DISABLE_SKIPPING_WHITESPACE = true
  42. NVG_FONT_TEXTURE_FLAGS = NVG_IMAGE_NEAREST
  43. USE_NANOVG_FBO = true
  44. include ../../dpf/Makefile.base.mk
  45. # --------------------------------------------------------------
  46. # Build config
  47. PREFIX ?= /usr/local
  48. ifeq ($(BSD),true)
  49. SYSDEPS ?= true
  50. else
  51. SYSDEPS ?= false
  52. endif
  53. ifeq ($(SYSDEPS),true)
  54. DEP_LIB_PATH = $(abspath ../../deps/sysroot/lib)
  55. else
  56. DEP_LIB_PATH = $(abspath ../Rack/dep/lib)
  57. endif
  58. # --------------------------------------------------------------
  59. # Files to build (DPF stuff)
  60. FILES_DSP = CardinalPlugin.cpp
  61. FILES_DSP += CardinalCommon.cpp
  62. FILES_DSP += common.cpp
  63. ifeq ($(HEADLESS),true)
  64. FILES_DSP += RemoteNanoVG.cpp
  65. FILES_DSP += RemoteWindow.cpp
  66. else
  67. FILES_UI = CardinalUI.cpp
  68. FILES_UI += glfw.cpp
  69. FILES_UI += Window.cpp
  70. endif
  71. ifeq ($(WINDOWS),true)
  72. FILES_UI += distrho.rc
  73. endif
  74. # --------------------------------------------------------------
  75. # Extra libraries to link against
  76. RACK_EXTRA_LIBS = ../../plugins/plugins.a
  77. RACK_EXTRA_LIBS += ../rack.a
  78. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libquickjs.a
  79. ifneq ($(SYSDEPS),true)
  80. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libjansson.a
  81. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libsamplerate.a
  82. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libspeexdsp.a
  83. ifeq ($(WINDOWS),true)
  84. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libarchive_static.a
  85. else
  86. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libarchive.a
  87. endif
  88. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libzstd.a
  89. endif
  90. # --------------------------------------------------------------
  91. EXTRA_DEPENDENCIES = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS)
  92. EXTRA_LIBS = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS) $(STATIC_CARLA_PLUGIN_LIBS)
  93. ifeq ($(shell pkg-config --exists fftw3f && echo true),true)
  94. EXTRA_DEPENDENCIES += ../../deps/aubio/libaubio.a
  95. EXTRA_LIBS += ../../deps/aubio/libaubio.a
  96. EXTRA_LIBS += $(shell $(PKG_CONFIG) --libs fftw3f)
  97. endif
  98. # --------------------------------------------------------------
  99. # Do some magic
  100. USE_VST2_BUNDLE = true
  101. include ../../dpf/Makefile.plugins.mk
  102. # --------------------------------------------------------------
  103. # Extra flags for VCV stuff
  104. ifeq ($(MACOS),true)
  105. BASE_FLAGS += -DARCH_MAC
  106. else ifeq ($(WINDOWS),true)
  107. BASE_FLAGS += -DARCH_WIN
  108. else
  109. BASE_FLAGS += -DARCH_LIN
  110. endif
  111. BASE_FLAGS += -DPRIVATE=
  112. BASE_FLAGS += -I..
  113. BASE_FLAGS += -I../../dpf/dgl/src/nanovg
  114. BASE_FLAGS += -I../../include
  115. BASE_FLAGS += -I../../include/neon-compat
  116. BASE_FLAGS += -I../Rack/include
  117. ifeq ($(SYSDEPS),true)
  118. BASE_FLAGS += -DCARDINAL_SYSDEPS
  119. BASE_FLAGS += $(shell pkg-config --cflags jansson libarchive samplerate speexdsp)
  120. else
  121. BASE_FLAGS += -DZSTDLIB_VISIBILITY=
  122. BASE_FLAGS += -I../Rack/dep/include
  123. endif
  124. BASE_FLAGS += -I../Rack/dep/glfw/include
  125. BASE_FLAGS += -I../Rack/dep/nanosvg/src
  126. BASE_FLAGS += -I../Rack/dep/oui-blendish
  127. ifeq ($(HEADLESS),true)
  128. BASE_FLAGS += -DHEADLESS
  129. endif
  130. ifeq ($(MOD_BUILD),true)
  131. BASE_FLAGS += -DDISTRHO_PLUGIN_USES_MODGUI=1 -DDISTRHO_PLUGIN_MINIMUM_BUFFER_SIZE=0xffff
  132. endif
  133. ifeq ($(WASM),true)
  134. BASE_FLAGS += -DNANOVG_GLES2=1
  135. BASE_FLAGS += -msse -msse2 -msse3 -msimd128
  136. else ifneq ($(HAIKU),true)
  137. BASE_FLAGS += -pthread
  138. endif
  139. ifeq ($(WINDOWS),true)
  140. BASE_FLAGS += -D_USE_MATH_DEFINES
  141. BASE_FLAGS += -DWIN32_LEAN_AND_MEAN
  142. BASE_FLAGS += -I../../include/mingw-compat
  143. BASE_FLAGS += -I../../include/mingw-std-threads
  144. endif
  145. BUILD_C_FLAGS += -std=gnu11
  146. BUILD_C_FLAGS += -fno-finite-math-only -fno-strict-aliasing
  147. BUILD_CXX_FLAGS += -fno-finite-math-only -fno-strict-aliasing
  148. ifneq ($(MACOS),true)
  149. BUILD_CXX_FLAGS += -faligned-new -Wno-abi
  150. endif
  151. # Rack code is not tested for this flag, unset it
  152. BUILD_CXX_FLAGS += -U_GLIBCXX_ASSERTIONS -Wp,-U_GLIBCXX_ASSERTIONS
  153. # --------------------------------------------------------------
  154. # FIXME lots of warnings from VCV side
  155. BASE_FLAGS += -Wno-unused-parameter
  156. BASE_FLAGS += -Wno-unused-variable
  157. # --------------------------------------------------------------
  158. # extra linker flags
  159. ifeq ($(HAIKU),true)
  160. LINK_FLAGS += -lpthread
  161. else
  162. LINK_FLAGS += -pthread
  163. endif
  164. ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
  165. ifneq ($(STATIC_BUILD),true)
  166. LINK_FLAGS += -ldl
  167. endif
  168. endif
  169. ifeq ($(BSD),true)
  170. ifeq ($(DEBUG),true)
  171. LINK_FLAGS += -lexecinfo
  172. endif
  173. endif
  174. ifeq ($(MACOS),true)
  175. LINK_FLAGS += -framework IOKit
  176. else ifeq ($(WINDOWS),true)
  177. # needed by VCVRack
  178. EXTRA_LIBS += -ldbghelp -lshlwapi -Wl,--stack,0x100000
  179. # needed by JW-Modules
  180. EXTRA_LIBS += -lws2_32 -lwinmm
  181. endif
  182. ifeq ($(SYSDEPS),true)
  183. EXTRA_LIBS += $(shell pkg-config --libs jansson libarchive samplerate speexdsp)
  184. endif
  185. ifeq ($(WITH_LTO),true)
  186. # false positive
  187. LINK_FLAGS += -Wno-alloc-size-larger-than
  188. ifneq ($(SYSDEPS),true)
  189. # triggered by jansson
  190. LINK_FLAGS += -Wno-stringop-overflow
  191. endif
  192. endif
  193. # --------------------------------------------------------------
  194. # optional liblo
  195. ifeq ($(HAVE_LIBLO),true)
  196. BASE_FLAGS += $(LIBLO_FLAGS)
  197. LINK_FLAGS += $(LIBLO_LIBS)
  198. endif
  199. # --------------------------------------------------------------
  200. # fallback path to resource files
  201. ifneq ($(CIBUILD),true)
  202. ifneq ($(SYSDEPS),true)
  203. ifeq ($(EXE_WRAPPER),wine)
  204. SOURCE_DIR = Z:$(subst /,\\,$(abspath $(CURDIR)/..))
  205. else
  206. SOURCE_DIR = $(abspath $(CURDIR)/..)
  207. endif
  208. BUILD_CXX_FLAGS += -DCARDINAL_PLUGIN_SOURCE_DIR='"$(SOURCE_DIR)"'
  209. endif
  210. endif
  211. # --------------------------------------------------------------
  212. # install path prefix for resource files
  213. BUILD_CXX_FLAGS += -DCARDINAL_PLUGIN_PREFIX='"$(PREFIX)"'
  214. # --------------------------------------------------------------
  215. # Enable all possible plugin types and setup resources
  216. ifeq ($(CARDINAL_VARIANT),main)
  217. ifneq ($(STATIC_BUILD),true)
  218. all: jack lv2 vst3 static
  219. else
  220. all: lv2 vst3
  221. endif # STATIC_BUILD
  222. else
  223. all: lv2 vst2 vst3 static
  224. endif
  225. CORE_RESOURCES = patches
  226. CORE_RESOURCES += $(subst ../Rack/res/,,$(wildcard ../Rack/res/ComponentLibrary/*.svg ../Rack/res/fonts/*.ttf))
  227. CORE_RESOURCES += $(subst ../,,$(wildcard ../template*.vcv))
  228. LV2_RESOURCES = $(CORE_RESOURCES:%=$(TARGET_DIR)/$(NAME).lv2/resources/%)
  229. VST3_RESOURCES = $(CORE_RESOURCES:%=$(TARGET_DIR)/$(NAME).vst3/Contents/Resources/%)
  230. # Install modgui resources if MOD build
  231. ifeq ($(MOD_BUILD),true)
  232. LV2_RESOURCES += $(TARGET_DIR)/$(NAME).lv2/Plateau_Reverb.ttl
  233. LV2_RESOURCES += $(TARGET_DIR)/$(NAME).lv2/modgui.ttl
  234. LV2_RESOURCES += $(TARGET_DIR)/$(NAME).lv2/modgui/documentation.pdf
  235. LV2_RESOURCES += $(TARGET_DIR)/$(NAME).lv2/modgui
  236. endif
  237. # Cardinal main variant should not use rtaudio fallback (it has CV ports)
  238. ifeq ($(CARDINAL_VARIANT),main)
  239. jack: BUILD_CXX_FLAGS += -DDPF_JACK_STANDALONE_SKIP_RTAUDIO_FALLBACK
  240. endif
  241. # Cardinal main variant is not available as VST2 due to lack of CV ports
  242. ifneq ($(CARDINAL_VARIANT),main)
  243. ifeq ($(MACOS),true)
  244. VST2_RESOURCES = $(CORE_RESOURCES:%=$(TARGET_DIR)/$(NAME).vst/Contents/Resources/%)
  245. else
  246. VST2_RESOURCES = $(CORE_RESOURCES:%=$(TARGET_DIR)/Cardinal.vst/resources/%)
  247. endif
  248. endif
  249. lv2: $(LV2_RESOURCES)
  250. vst2: $(VST2_RESOURCES)
  251. vst3: $(VST3_RESOURCES)
  252. # --------------------------------------------------------------
  253. # Extra rules for Windows icon
  254. ifeq ($(WINDOWS),true)
  255. JACK_LIBS += -Wl,-subsystem,windows
  256. $(BUILD_DIR)/distrho.rc.o: ../../utils/distrho.rc ../../utils/distrho.ico
  257. -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
  258. @echo "Compiling distrho.rc"
  259. $(SILENT)$(WINDRES) $< -O coff -o $@
  260. endif
  261. # --------------------------------------------------------------
  262. $(TARGET_DIR)/%/patches: ../../patches
  263. -@mkdir -p "$(shell dirname $@)"
  264. $(SILENT)ln -sf $(abspath $<) $@
  265. $(TARGET_DIR)/%/template.vcv: ../template.vcv
  266. -@mkdir -p "$(shell dirname $@)"
  267. $(SILENT)ln -sf $(abspath $<) $@
  268. $(TARGET_DIR)/%/template-fx.vcv: ../template-fx.vcv
  269. -@mkdir -p "$(shell dirname $@)"
  270. $(SILENT)ln -sf $(abspath $<) $@
  271. $(TARGET_DIR)/%/template-synth.vcv: ../template-synth.vcv
  272. -@mkdir -p "$(shell dirname $@)"
  273. $(SILENT)ln -sf $(abspath $<) $@
  274. $(TARGET_DIR)/$(NAME).lv2/resources/%: ../Rack/res/%
  275. -@mkdir -p "$(shell dirname $@)"
  276. $(SILENT)ln -sf $(abspath $<) $@
  277. ifeq ($(MOD_BUILD),true)
  278. $(TARGET_DIR)/$(NAME).lv2/resources/%.svg: ../Rack/res/%.svg ../../deps/svg2stub.py
  279. -@mkdir -p "$(shell dirname $@)"
  280. $(SILENT)python3 ../../deps/svg2stub.py $< $@
  281. $(TARGET_DIR)/$(NAME).lv2/mod%: ../MOD/$(NAME).lv2/mod%
  282. -@mkdir -p "$(shell dirname $@)"
  283. $(SILENT)ln -sf $(abspath $<) $@
  284. $(TARGET_DIR)/$(NAME).lv2/%.ttl: ../MOD/$(NAME).lv2/%.ttl
  285. -@mkdir -p "$(shell dirname $@)"
  286. $(SILENT)ln -sf $(abspath $<) $@
  287. $(TARGET_DIR)/$(NAME).lv2/modgui/documentation.pdf: ../../docs/MODDEVICES.md $(TARGET_DIR)/$(NAME).lv2/modgui
  288. (cd ../../docs/ && pandoc MODDEVICES.md -f markdown+implicit_figures -o $(abspath $@))
  289. endif
  290. $(TARGET_DIR)/Cardinal.vst/resources/%: ../Rack/res/%
  291. -@mkdir -p "$(shell dirname $@)"
  292. $(SILENT)ln -sf $(abspath $<) $@
  293. $(TARGET_DIR)/$(NAME).vst/Contents/Resources/%: ../Rack/res/%
  294. -@mkdir -p "$(shell dirname $@)"
  295. $(SILENT)ln -sf $(abspath $<) $@
  296. $(TARGET_DIR)/$(NAME).vst3/Contents/Resources/%: ../Rack/res/%
  297. -@mkdir -p "$(shell dirname $@)"
  298. $(SILENT)ln -sf $(abspath $<) $@
  299. # --------------------------------------------------------------