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.

374 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. USE_NANOVG_FBO = true
  42. include ../../dpf/Makefile.base.mk
  43. # --------------------------------------------------------------
  44. # Build config
  45. PREFIX ?= /usr/local
  46. ifeq ($(BSD),true)
  47. SYSDEPS ?= true
  48. else
  49. SYSDEPS ?= false
  50. endif
  51. ifeq ($(SYSDEPS),true)
  52. DEP_LIB_PATH = $(abspath ../../deps/sysroot/lib)
  53. else
  54. DEP_LIB_PATH = $(abspath ../Rack/dep/lib)
  55. endif
  56. # --------------------------------------------------------------
  57. # Files to build (DPF stuff)
  58. FILES_DSP = CardinalPlugin.cpp
  59. FILES_DSP += CardinalCommon.cpp
  60. FILES_DSP += common.cpp
  61. ifeq ($(HEADLESS),true)
  62. FILES_DSP += RemoteNanoVG.cpp
  63. FILES_DSP += RemoteWindow.cpp
  64. else
  65. FILES_UI = CardinalUI.cpp
  66. FILES_UI += Window.cpp
  67. endif
  68. ifeq ($(WINDOWS),true)
  69. FILES_UI += distrho.rc
  70. endif
  71. # --------------------------------------------------------------
  72. # Extra libraries to link against
  73. RACK_EXTRA_LIBS = ../../plugins/plugins.a
  74. RACK_EXTRA_LIBS += ../rack.a
  75. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libquickjs.a
  76. ifneq ($(SYSDEPS),true)
  77. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libjansson.a
  78. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libsamplerate.a
  79. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libspeexdsp.a
  80. ifeq ($(WINDOWS),true)
  81. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libarchive_static.a
  82. else
  83. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libarchive.a
  84. endif
  85. RACK_EXTRA_LIBS += $(DEP_LIB_PATH)/libzstd.a
  86. endif
  87. # --------------------------------------------------------------
  88. EXTRA_DEPENDENCIES = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS)
  89. EXTRA_LIBS = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS) $(STATIC_CARLA_PLUGIN_LIBS)
  90. ifeq ($(shell pkg-config --exists fftw3f && echo true),true)
  91. EXTRA_DEPENDENCIES += ../../deps/aubio/libaubio.a
  92. EXTRA_LIBS += ../../deps/aubio/libaubio.a
  93. EXTRA_LIBS += $(shell $(PKG_CONFIG) --libs fftw3f)
  94. endif
  95. # --------------------------------------------------------------
  96. # Do some magic
  97. NVG_DISABLE_SKIPPING_WHITESPACE = true
  98. NVG_FONT_TEXTURE_FLAGS = NVG_IMAGE_NEAREST
  99. USE_NANOVG_FBO = true
  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 = $(subst ../Rack/res/,,$(wildcard ../Rack/res/ComponentLibrary/*.svg ../Rack/res/fonts/*.ttf))
  226. CORE_RESOURCES += $(subst ../,,$(wildcard ../template*.vcv))
  227. LV2_RESOURCES = $(CORE_RESOURCES:%=$(TARGET_DIR)/$(NAME).lv2/resources/%)
  228. VST3_RESOURCES = $(CORE_RESOURCES:%=$(TARGET_DIR)/$(NAME).vst3/Contents/Resources/%)
  229. # Install modgui resources if MOD build
  230. ifeq ($(MOD_BUILD),true)
  231. LV2_RESOURCES += $(TARGET_DIR)/$(NAME).lv2/Plateau_Reverb.ttl
  232. LV2_RESOURCES += $(TARGET_DIR)/$(NAME).lv2/modgui.ttl
  233. LV2_RESOURCES += $(TARGET_DIR)/$(NAME).lv2/modgui/documentation.pdf
  234. LV2_RESOURCES += $(TARGET_DIR)/$(NAME).lv2/modgui
  235. endif
  236. # Cardinal main variant should not use rtaudio fallback (it has CV ports)
  237. ifeq ($(CARDINAL_VARIANT),main)
  238. jack: BUILD_CXX_FLAGS += -DDPF_JACK_STANDALONE_SKIP_RTAUDIO_FALLBACK
  239. endif
  240. # Cardinal main variant is not available as VST2 due to lack of CV ports
  241. ifneq ($(CARDINAL_VARIANT),main)
  242. ifeq ($(MACOS),true)
  243. VST2_RESOURCES = $(CORE_RESOURCES:%=$(TARGET_DIR)/$(NAME).vst/Contents/Resources/%)
  244. else
  245. VST2_RESOURCES = $(CORE_RESOURCES:%=$(TARGET_DIR)/Cardinal.vst/resources/%)
  246. endif
  247. endif
  248. lv2: $(LV2_RESOURCES)
  249. vst2: $(VST2_RESOURCES)
  250. vst3: $(VST3_RESOURCES)
  251. # --------------------------------------------------------------
  252. # Extra rules for Windows icon
  253. ifeq ($(WINDOWS),true)
  254. JACK_LIBS += -Wl,-subsystem,windows
  255. $(BUILD_DIR)/distrho.rc.o: ../../utils/distrho.rc ../../utils/distrho.ico
  256. -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
  257. @echo "Compiling distrho.rc"
  258. $(SILENT)$(WINDRES) $< -O coff -o $@
  259. endif
  260. # --------------------------------------------------------------
  261. $(TARGET_DIR)/%/template.vcv: ../template.vcv
  262. -@mkdir -p "$(shell dirname $@)"
  263. $(SILENT)ln -sf $(abspath $<) $@
  264. $(TARGET_DIR)/%/template-fx.vcv: ../template-fx.vcv
  265. -@mkdir -p "$(shell dirname $@)"
  266. $(SILENT)ln -sf $(abspath $<) $@
  267. $(TARGET_DIR)/%/template-synth.vcv: ../template-synth.vcv
  268. -@mkdir -p "$(shell dirname $@)"
  269. $(SILENT)ln -sf $(abspath $<) $@
  270. $(TARGET_DIR)/$(NAME).lv2/resources/%: ../Rack/res/%
  271. -@mkdir -p "$(shell dirname $@)"
  272. $(SILENT)ln -sf $(abspath $<) $@
  273. ifeq ($(MOD_BUILD),true)
  274. $(TARGET_DIR)/$(NAME).lv2/resources/%.svg: ../Rack/res/%.svg ../../deps/svg2stub.py
  275. -@mkdir -p "$(shell dirname $@)"
  276. $(SILENT)python3 ../../deps/svg2stub.py $< $@
  277. $(TARGET_DIR)/$(NAME).lv2/mod%: ../MOD/$(NAME).lv2/mod%
  278. -@mkdir -p "$(shell dirname $@)"
  279. $(SILENT)ln -sf $(abspath $<) $@
  280. $(TARGET_DIR)/$(NAME).lv2/%.ttl: ../MOD/$(NAME).lv2/%.ttl
  281. -@mkdir -p "$(shell dirname $@)"
  282. $(SILENT)ln -sf $(abspath $<) $@
  283. $(TARGET_DIR)/$(NAME).lv2/modgui/documentation.pdf: ../../docs/MODDEVICES.md $(TARGET_DIR)/$(NAME).lv2/modgui
  284. (cd ../../docs/ && pandoc MODDEVICES.md -f markdown+implicit_figures -o $(abspath $@))
  285. endif
  286. $(TARGET_DIR)/Cardinal.vst/resources/%: ../Rack/res/%
  287. -@mkdir -p "$(shell dirname $@)"
  288. $(SILENT)ln -sf $(abspath $<) $@
  289. $(TARGET_DIR)/$(NAME).vst/Contents/Resources/%: ../Rack/res/%
  290. -@mkdir -p "$(shell dirname $@)"
  291. $(SILENT)ln -sf $(abspath $<) $@
  292. $(TARGET_DIR)/$(NAME).vst3/Contents/Resources/%: ../Rack/res/%
  293. -@mkdir -p "$(shell dirname $@)"
  294. $(SILENT)ln -sf $(abspath $<) $@
  295. # --------------------------------------------------------------