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.

699 lines
21KB

  1. #!/usr/bin/make -f
  2. # Makefile for Carla C++ code #
  3. # --------------------------- #
  4. # Created by falkTX
  5. #
  6. # ---------------------------------------------------------------------------------------------------------------------
  7. # Base environment vars
  8. AR ?= ar
  9. CC ?= gcc
  10. CXX ?= g++
  11. # ---------------------------------------------------------------------------------------------------------------------
  12. # Auto-detect OS if not defined
  13. TARGET_MACHINE := $(shell $(CC) -dumpmachine)
  14. ifneq ($(BSD),true)
  15. ifneq ($(HAIKU),true)
  16. ifneq ($(HURD),true)
  17. ifneq ($(LINUX),true)
  18. ifneq ($(MACOS),true)
  19. ifneq ($(WASM),true)
  20. ifneq ($(WINDOWS),true)
  21. ifneq (,$(findstring bsd,$(TARGET_MACHINE)))
  22. BSD = true
  23. else ifneq (,$(findstring haiku,$(TARGET_MACHINE)))
  24. HAIKU = true
  25. else ifneq (,$(findstring linux,$(TARGET_MACHINE)))
  26. LINUX = true
  27. else ifneq (,$(findstring gnu,$(TARGET_MACHINE)))
  28. HURD = true
  29. else ifneq (,$(findstring apple,$(TARGET_MACHINE)))
  30. MACOS = true
  31. else ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
  32. WINDOWS = true
  33. else ifneq (,$(findstring msys,$(TARGET_MACHINE)))
  34. WINDOWS = true
  35. else ifneq (,$(findstring wasm,$(TARGET_MACHINE)))
  36. WASM = true
  37. else ifneq (,$(findstring windows,$(TARGET_MACHINE)))
  38. WINDOWS = true
  39. endif
  40. endif # WINDOWS
  41. endif # WASM
  42. endif # MACOS
  43. endif # LINUX
  44. endif # HURD
  45. endif # HAIKU
  46. endif # BSD
  47. # ---------------------------------------------------------------------------------------------------------------------
  48. # Auto-detect the processor
  49. TARGET_PROCESSOR := $(firstword $(subst -, ,$(TARGET_MACHINE)))
  50. ifneq (,$(filter i%86,$(TARGET_PROCESSOR)))
  51. CPU_I386 = true
  52. CPU_I386_OR_X86_64 = true
  53. endif
  54. ifneq (,$(filter wasm32,$(TARGET_PROCESSOR)))
  55. CPU_I386 = true
  56. CPU_I386_OR_X86_64 = true
  57. endif
  58. ifneq (,$(filter x86_64,$(TARGET_PROCESSOR)))
  59. CPU_X86_64 = true
  60. CPU_I386_OR_X86_64 = true
  61. endif
  62. ifneq (,$(filter arm%,$(TARGET_PROCESSOR)))
  63. CPU_ARM = true
  64. CPU_ARM_OR_AARCH64 = true
  65. endif
  66. ifneq (,$(filter arm64%,$(TARGET_PROCESSOR)))
  67. CPU_ARM64 = true
  68. CPU_ARM_OR_AARCH64 = true
  69. endif
  70. ifneq (,$(filter aarch64%,$(TARGET_PROCESSOR)))
  71. CPU_AARCH64 = true
  72. CPU_ARM_OR_AARCH64 = true
  73. endif
  74. ifneq (,$(filter riscv64%,$(TARGET_PROCESSOR)))
  75. CPU_RISCV64 = true
  76. endif
  77. # ---------------------------------------------------------------------------------------------------------------------
  78. # Set PKG_CONFIG (can be overridden by environment variable)
  79. ifeq ($(WASM),true)
  80. # Skip on wasm by default
  81. PKG_CONFIG ?= false
  82. else ifeq ($(WINDOWS),true)
  83. # Build statically on Windows by default
  84. PKG_CONFIG ?= pkg-config --static
  85. else
  86. PKG_CONFIG ?= pkg-config
  87. endif
  88. # ---------------------------------------------------------------------------------------------------------------------
  89. # Set cross compiling flag
  90. ifeq ($(WASM),true)
  91. CROSS_COMPILING = true
  92. endif
  93. # ---------------------------------------------------------------------------------------------------------------------
  94. # Set LINUX_OR_MACOS
  95. ifeq ($(LINUX),true)
  96. LINUX_OR_MACOS = true
  97. endif
  98. ifeq ($(MACOS),true)
  99. LINUX_OR_MACOS = true
  100. endif
  101. # ---------------------------------------------------------------------------------------------------------------------
  102. # Set HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS, HAIKU_OR_MACOS_OR_WINDOWS, MACOS_OR_WASM_OR_WINDOWS and MACOS_OR_WINDOWS
  103. ifeq ($(HAIKU),true)
  104. HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS = true
  105. HAIKU_OR_MACOS_OR_WINDOWS = true
  106. endif
  107. ifeq ($(MACOS),true)
  108. HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS = true
  109. HAIKU_OR_MACOS_OR_WINDOWS = true
  110. MACOS_OR_WASM_OR_WINDOWS = true
  111. MACOS_OR_WINDOWS = true
  112. endif
  113. ifeq ($(WASM),true)
  114. HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS = true
  115. MACOS_OR_WASM_OR_WINDOWS = true
  116. endif
  117. ifeq ($(WINDOWS),true)
  118. HAIKU_OR_MACOS_OR_WASM_OR_WINDOWS = true
  119. HAIKU_OR_MACOS_OR_WINDOWS = true
  120. MACOS_OR_WASM_OR_WINDOWS = true
  121. MACOS_OR_WINDOWS = true
  122. endif
  123. # ---------------------------------------------------------------------------------------------------------------------
  124. # Set UNIX
  125. ifeq ($(BSD),true)
  126. UNIX = true
  127. endif
  128. ifeq ($(HURD),true)
  129. UNIX = true
  130. endif
  131. ifeq ($(LINUX),true)
  132. UNIX = true
  133. endif
  134. ifeq ($(MACOS),true)
  135. UNIX = true
  136. endif
  137. # ---------------------------------------------------------------------------------------------------------------------
  138. # Check for optional libs (required by backend or bridges)
  139. ifeq ($(LINUX),true)
  140. HAVE_ALSA = $(shell $(PKG_CONFIG) --exists alsa && echo true)
  141. HAVE_HYLIA = true
  142. else ifeq ($(MACOS),true)
  143. HAVE_HYLIA = true
  144. else ifeq ($(WINDOWS),true)
  145. HAVE_HYLIA = true
  146. endif
  147. ifeq ($(MACOS_OR_WASM_OR_WINDOWS),true)
  148. HAVE_DGL = true
  149. HAVE_YSFXGUI = true
  150. else
  151. HAVE_DBUS = $(shell $(PKG_CONFIG) --exists dbus-1 && echo true)
  152. HAVE_DGL = $(shell $(PKG_CONFIG) --exists gl x11 xcursor xext xrandr && echo true)
  153. HAVE_YSFXGUI = $(shell $(PKG_CONFIG) --exists freetype2 fontconfig gl x11 && echo true)
  154. HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true)
  155. HAVE_XCURSOR = $(shell $(PKG_CONFIG) --exists xcursor && echo true)
  156. HAVE_XEXT = $(shell $(PKG_CONFIG) --exists xext && echo true)
  157. HAVE_XRANDR = $(shell $(PKG_CONFIG) --exists xrandr && echo true)
  158. endif
  159. # FIXME update to DGL with wasm compat
  160. ifeq ($(WASM),true)
  161. HAVE_DGL = false
  162. endif
  163. # NOTE opt-out rather than opt-in
  164. HAVE_YSFX = true
  165. # NOTE not yet implemented, disabled for now
  166. HAVE_YSFXGUI = false
  167. ifeq ($(UNIX),true)
  168. ifneq ($(MACOS),true)
  169. HAVE_PULSEAUDIO = $(shell $(PKG_CONFIG) --exists libpulse-simple && echo true)
  170. endif
  171. endif
  172. # ffmpeg values taken from https://ffmpeg.org/download.html (v2.8.15 maximum)
  173. HAVE_FFMPEG = $(shell $(PKG_CONFIG) --max-version=56.60.100 libavcodec && \
  174. $(PKG_CONFIG) --max-version=56.40.101 libavformat && \
  175. $(PKG_CONFIG) --max-version=54.31.100 libavutil && echo true)
  176. HAVE_FLUIDSYNTH = $(shell $(PKG_CONFIG) --atleast-version=1.1.7 fluidsynth && echo true)
  177. HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
  178. HAVE_QT4 = $(shell $(PKG_CONFIG) --exists QtCore QtGui && echo true)
  179. HAVE_QT5 = $(shell $(PKG_CONFIG) --exists Qt5Core Qt5Gui Qt5Widgets && \
  180. $(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true)
  181. HAVE_QT5PKG = $(shell $(PKG_CONFIG) --silence-errors --variable=prefix Qt5OpenGLExtensions 1>/dev/null && echo true)
  182. HAVE_QT5BREW = $(shell test -e /usr/local/opt/qt5/bin/uic && echo true)
  183. HAVE_QT6 = $(shell $(PKG_CONFIG) --exists Qt6Core Qt6Gui Qt6Widgets && echo true)
  184. HAVE_QT6BREW = $(shell test -e /opt/homebrew/opt/qt6/share/qt/libexec/uic && echo true)
  185. HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && echo true)
  186. ifeq ($(HAVE_FLUIDSYNTH),true)
  187. HAVE_FLUIDSYNTH_INSTPATCH = $(shell $(PKG_CONFIG) --atleast-version=2.1.0 fluidsynth && \
  188. $(PKG_CONFIG) --atleast-version=1.1.4 libinstpatch-1.0 && echo true)
  189. endif
  190. ifeq ($(JACKBRIDGE_DIRECT),true)
  191. HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true)
  192. HAVE_JACKLIB = $(HAVE_JACK)
  193. else ifeq ($(WASM),true)
  194. HAVE_JACK = false
  195. HAVE_JACKLIB = false
  196. else
  197. HAVE_JACK = true
  198. HAVE_JACKLIB = false
  199. endif
  200. ifeq ($(WASM),true)
  201. HAVE_SDL1 = false
  202. HAVE_SDL2 = true
  203. else
  204. HAVE_SDL1 = $(shell $(PKG_CONFIG) --exists sdl && echo true)
  205. HAVE_SDL2 = $(shell $(PKG_CONFIG) --exists sdl2 && echo true)
  206. endif
  207. # ---------------------------------------------------------------------------------------------------------------------
  208. # Check for optional libs (special non-pkgconfig tests)
  209. ifneq ($(WASM),true)
  210. ifneq ($(WINDOWS),true)
  211. ifeq ($(shell $(PKG_CONFIG) --exists libmagic && echo true),true)
  212. HAVE_LIBMAGIC = true
  213. HAVE_LIBMAGICPKG = true
  214. else
  215. # old libmagic versions don't have a pkg-config file, so we need to call the compiler to test it
  216. CFLAGS_WITHOUT_ARCH = $(subst -arch arm64,,$(CFLAGS))
  217. HAVE_LIBMAGIC = $(shell echo '\#include <magic.h>' | $(CC) $(CFLAGS_WITHOUT_ARCH) -x c -w -c - -o /dev/null 2>/dev/null && echo true)
  218. endif
  219. endif
  220. endif
  221. # ---------------------------------------------------------------------------------------------------------------------
  222. # Set Qt tools, part1
  223. ifeq ($(HAVE_QT4),true)
  224. MOC_QT4 ?= $(shell $(PKG_CONFIG) --variable=moc_location QtCore)
  225. RCC_QT4 ?= $(shell $(PKG_CONFIG) --variable=rcc_location QtCore)
  226. QT4_CXX_FLAGS = $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags QtCore QtGui)
  227. QT4_LINK_FLAGS = $(NON_STATIC_LINK_FLAGS) $(shell pkg-config --libs QtCore QtGui)
  228. QT4_STYLES_DIR = $(shell pkg-config --variable=libdir QtCore)/qt4/plugins/styles
  229. endif
  230. ifeq ($(HAVE_QT5),true)
  231. QT5_HOSTBINS = $(shell $(PKG_CONFIG) --variable=host_bins Qt5Core)
  232. QT5_PREFIX = $(shell $(PKG_CONFIG) --variable=prefix Qt5Core)
  233. QT5_CXX_FLAGS = $(shell $(PKG_CONFIG) --cflags Qt5Core Qt5Gui Qt5Widgets)
  234. QT5_LINK_FLAGS = -Wl,-rpath,$(QT5_PREFIX)/lib $(shell $(PKG_CONFIG) --libs Qt5Core Qt5Gui Qt5Widgets)
  235. QT5_STYLES_DIR = $(shell pkg-config --variable=libdir Qt5Core)/qt5/plugins/styles
  236. else ifeq ($(HAVE_QT5PKG),true)
  237. QT5_HOSTBINS = $(shell $(PKG_CONFIG) --variable=prefix Qt5OpenGLExtensions)/bin
  238. QT5_PREFIX = $(shell $(PKG_CONFIG) --variable=prefix Qt5OpenGLExtensions)
  239. QT5_CXX_FLAGS = -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I $(QT5_PREFIX)/include/qt5
  240. QT5_LINK_FLAGS = -Wl,-rpath,$(QT5_PREFIX)/lib -F $(QT5_PREFIX)/lib -framework QtCore -framework QtGui -framework QtWidgets
  241. QT5_STYLES_DIR = $(QT5_PREFIX)/lib/qt5/plugins/styles
  242. else ifeq ($(HAVE_QT5BREW),true)
  243. QT5_HOSTBINS = /usr/local/opt/qt5/bin
  244. QT5_PREFIX = /usr/local/opt/qt5
  245. QT5_CXX_FLAGS = -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I $(QT5_PREFIX)/include
  246. QT5_LINK_FLAGS = -Wl,-rpath,$(QT5_PREFIX)/lib -F $(QT5_PREFIX)/lib -framework QtCore -framework QtGui -framework QtWidgets
  247. QT5_STYLES_DIR = $(QT5_PREFIX)/plugins/styles
  248. endif
  249. ifeq ($(HAVE_QT6),true)
  250. QT6_HOSTBINS = $(shell $(PKG_CONFIG) --variable=libexecdir Qt6Core)
  251. QT6_PREFIX = $(shell $(PKG_CONFIG) --variable=prefix Qt6Core)
  252. QT6_CXX_FLAGS = $(shell $(PKG_CONFIG) --cflags Qt6Core Qt6Gui Qt6Widgets) -std=gnu++17
  253. QT6_LINK_FLAGS = -Wl,-rpath,$(QT6_PREFIX)/lib $(shell $(PKG_CONFIG) --libs Qt6Core Qt6Gui Qt6Widgets)
  254. QT6_STYLES_DIR = $(shell pkg-config --variable=libdir Qt6Core)/qt6/plugins/styles
  255. else ifeq ($(HAVE_QT6BREW),true)
  256. QT6_HOSTBINS = /opt/homebrew/opt/qt6/share/qt/libexec
  257. QT6_PREFIX = /opt/homebrew/opt/qt6
  258. QT6_CXX_FLAGS = -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I $(QT6_PREFIX)/include -std=gnu++17
  259. QT6_LINK_FLAGS = -Wl,-rpath,$(QT6_PREFIX)/lib -F $(QT6_PREFIX)/lib -framework QtCore -framework QtGui -framework QtWidgets
  260. QT6_STYLES_DIR = $(QT6_PREFIX)/share/qt/plugins/styles
  261. endif
  262. MOC_QT5 ?= $(QT5_HOSTBINS)/moc
  263. RCC_QT5 ?= $(QT5_HOSTBINS)/rcc
  264. UIC_QT5 ?= $(QT5_HOSTBINS)/uic
  265. MOC_QT6 ?= $(QT6_HOSTBINS)/moc
  266. RCC_QT6 ?= $(QT6_HOSTBINS)/rcc
  267. UIC_QT6 ?= $(QT6_HOSTBINS)/uic
  268. ifeq (,$(wildcard $(MOC_QT4)))
  269. HAVE_QT4 = false
  270. endif
  271. ifeq (,$(wildcard $(RCC_QT4)))
  272. HAVE_QT4 = false
  273. endif
  274. ifeq (,$(wildcard $(MOC_QT5)))
  275. HAVE_QT5 = false
  276. endif
  277. ifeq (,$(wildcard $(RCC_QT5)))
  278. HAVE_QT5 = false
  279. endif
  280. ifeq (,$(wildcard $(UIC_QT5)))
  281. HAVE_QT5 = false
  282. endif
  283. ifeq (,$(wildcard $(MOC_QT6)))
  284. HAVE_QT6 = false
  285. endif
  286. ifeq (,$(wildcard $(RCC_QT6)))
  287. HAVE_QT6 = false
  288. endif
  289. ifeq (,$(wildcard $(UIC_QT6)))
  290. HAVE_QT6 = false
  291. endif
  292. # ---------------------------------------------------------------------------------------------------------------------
  293. # Set PyQt tools
  294. PYRCC5 ?= $(shell which pyrcc5 2>/dev/null)
  295. PYUIC5 ?= $(shell which pyuic5 2>/dev/null)
  296. PYUIC6 ?= $(shell which pyuic6 2>/dev/null)
  297. ifneq (,$(findstring true,$(HAVE_QT6)$(HAVE_QT6BREW)))
  298. ifneq ($(PYUIC6),)
  299. HAVE_FRONTEND = true
  300. HAVE_PYQT = true
  301. FRONTEND_TYPE = 6
  302. endif
  303. endif
  304. ifneq (,$(findstring true,$(HAVE_QT5)$(HAVE_QT5PKG)$(HAVE_QT5BREW)))
  305. ifneq ($(PYUIC5)$(PYRCC5),)
  306. HAVE_FRONTEND = true
  307. HAVE_PYQT = true
  308. FRONTEND_TYPE = 5
  309. endif
  310. endif
  311. # ---------------------------------------------------------------------------------------------------------------------
  312. # Set Qt tools, part2
  313. ifneq (,$(findstring true,$(HAVE_QT4)$(HAVE_QT5)$(HAVE_QT5PKG)$(HAVE_QT5BREW)$(HAVE_QT6)$(HAVE_QT6BREW)))
  314. HAVE_QT = true
  315. endif
  316. ifeq ($(FRONTEND_TYPE),5)
  317. MOC = $(MOC_QT5)
  318. RCC = $(RCC_QT5)
  319. UIC = $(UIC_QT5)
  320. PYRCC ?= $(PYRCC5)
  321. PYUIC ?= $(PYUIC5)
  322. HAVE_THEME = $(HAVE_QT5)
  323. QT_CXX_FLAGS = $(QT5_CXX_FLAGS)
  324. QT_LINK_FLAGS = $(QT5_LINK_FLAGS)
  325. else ifeq ($(FRONTEND_TYPE),6)
  326. MOC = $(MOC_QT6)
  327. RCC = $(RCC_QT6)
  328. UIC = $(UIC_QT6)
  329. PYRCC ?= $(RCC_QT6) -g python
  330. PYUIC ?= $(PYUIC6)
  331. HAVE_THEME = $(HAVE_QT6)
  332. QT_CXX_FLAGS = $(QT6_CXX_FLAGS)
  333. QT_LINK_FLAGS = $(QT6_LINK_FLAGS)
  334. endif
  335. # ---------------------------------------------------------------------------------------------------------------------
  336. # Set USING_RTAUDIO
  337. ifneq ($(HAIKU),true)
  338. ifneq ($(WASM),true)
  339. USING_RTAUDIO = true
  340. endif
  341. endif
  342. # ---------------------------------------------------------------------------------------------------------------------
  343. # Disable features for static plugin target
  344. ifeq ($(STATIC_PLUGIN_TARGET),true)
  345. HAVE_ALSA = false
  346. HAVE_JACK = false
  347. HAVE_JACKLIB = false
  348. HAVE_FRONTEND = false
  349. HAVE_HYLIA = false
  350. HAVE_LIBLO = false
  351. HAVE_PULSEAUDIO = false
  352. HAVE_PYQT = false
  353. HAVE_QT4 = false
  354. HAVE_QT5 = false
  355. HAVE_QT5PKG = false
  356. HAVE_QT5BREW = false
  357. HAVE_QT6 = false
  358. HAVE_SDL = false
  359. HAVE_SDL1 = false
  360. HAVE_SDL2 = false
  361. USING_RTAUDIO = false
  362. endif
  363. # ---------------------------------------------------------------------------------------------------------------------
  364. # Set libs stuff (part 1)
  365. ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
  366. LIBDL_LIBS = -ldl
  367. endif
  368. ifeq ($(HAVE_LIBLO),true)
  369. LIBLO_FLAGS = $(shell $(PKG_CONFIG) --cflags liblo)
  370. LIBLO_LIBS = $(shell $(PKG_CONFIG) --libs liblo)
  371. endif
  372. ifeq ($(HAVE_FFMPEG),true)
  373. FFMPEG_FLAGS = $(shell $(PKG_CONFIG) --cflags libavcodec libavformat libavutil)
  374. FFMPEG_LIBS = $(shell $(PKG_CONFIG) --libs libavcodec libavformat libavutil)
  375. endif
  376. ifeq ($(HAVE_FLUIDSYNTH),true)
  377. FLUIDSYNTH_FLAGS = $(shell $(PKG_CONFIG) --cflags fluidsynth)
  378. FLUIDSYNTH_LIBS = $(shell $(PKG_CONFIG) --libs fluidsynth)
  379. endif
  380. ifeq ($(HAVE_JACKLIB),true)
  381. JACK_FLAGS = $(shell $(PKG_CONFIG) --cflags jack)
  382. JACK_LIBS = $(shell $(PKG_CONFIG) --libs jack)
  383. JACK_LIBDIR = $(shell $(PKG_CONFIG) --variable=libdir jack)/jack
  384. endif
  385. ifeq ($(HAVE_QT5),true)
  386. QT5_FLAGS = $(shell $(PKG_CONFIG) --cflags Qt5Core Qt5Gui Qt5Widgets)
  387. QT5_LIBS = $(shell $(PKG_CONFIG) --libs Qt5Core Qt5Gui Qt5Widgets)
  388. endif
  389. ifeq ($(HAVE_QT6),true)
  390. QT6_FLAGS = $(shell $(PKG_CONFIG) --cflags Qt6Core Qt6Gui Qt6Widgets)
  391. QT6_LIBS = $(shell $(PKG_CONFIG) --libs Qt6Core Qt6Gui Qt6Widgets)
  392. endif
  393. ifeq ($(WASM),true)
  394. HAVE_SDL = true
  395. SDL_FLAGS = -sUSE_SDL=2
  396. SDL_LIBS = -sUSE_SDL=2
  397. else ifeq ($(HAVE_SDL2),true)
  398. HAVE_SDL = true
  399. SDL_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags sdl2)
  400. SDL_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs sdl2)
  401. else ifeq ($(HAVE_SDL1),true)
  402. HAVE_SDL = true
  403. SDL_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags sdl)
  404. SDL_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs sdl)
  405. endif
  406. ifeq ($(HAVE_SNDFILE),true)
  407. SNDFILE_FLAGS = $(shell $(PKG_CONFIG) --cflags sndfile)
  408. SNDFILE_LIBS = $(shell $(PKG_CONFIG) --libs sndfile)
  409. endif
  410. # ifeq ($(HAVE_YSFXGUI),true)
  411. # ifeq ($(MACOS),true)
  412. # YSFX_LIBS = -framework Cocoa -framework Carbon -framework Metal -framework Foundation
  413. # else ifeq ($(WASM),true)
  414. # # TODO
  415. # YSFX_LIBS =
  416. # else
  417. # YSFX_FLAGS = $(shell $(PKG_CONFIG) --cflags freetype2 fontconfig)
  418. # YSFX_LIBS = $(shell $(PKG_CONFIG) --libs freetype2 fontconfig gl x11)
  419. # endif
  420. # endif
  421. ifeq ($(HAVE_X11),true)
  422. X11_FLAGS = $(shell $(PKG_CONFIG) --cflags x11)
  423. X11_LIBS = $(shell $(PKG_CONFIG) --libs x11)
  424. endif
  425. # ---------------------------------------------------------------------------------------------------------------------
  426. # Set libs stuff (dgl)
  427. ifeq ($(HAVE_DGL),true)
  428. DGL_FLAGS = -DHAVE_OPENGL -DDGL_OPENGL -DHAVE_DGL
  429. ifeq ($(HAIKU),true)
  430. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags gl)
  431. DGL_LIBS = $(shell $(PKG_CONFIG) --libs gl) -lbe
  432. else ifeq ($(MACOS),true)
  433. DGL_FLAGS += -DGL_SILENCE_DEPRECATION=1 -Wno-deprecated-declarations
  434. DGL_LIBS = -framework OpenGL -framework Cocoa -framework CoreVideo
  435. else ifeq ($(WASM),true)
  436. ifneq ($(USE_GLES2)$(USE_GLES3),true)
  437. DGL_LIBS = -sLEGACY_GL_EMULATION -sGL_UNSAFE_OPTS=0
  438. endif
  439. else ifeq ($(WINDOWS),true)
  440. DGL_LIBS = -lcomdlg32 -ldwmapi -lopengl32 -lgdi32
  441. else
  442. DGL_FLAGS += -DHAVE_X11 -DHAVE_XCURSOR -DHAVE_XEXT -DHAVE_XSYNC -DHAVE_XRANDR
  443. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags gl x11 xcursor xext xrandr)
  444. DGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11 xcursor xext xrandr)
  445. ifeq ($(HAVE_DBUS)$(STATIC_PLUGIN_TARGET)$(USING_CUSTOM_DPF),truetruetrue)
  446. DGL_FLAGS += -DHAVE_DBUS
  447. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1)
  448. DGL_LIBS += $(shell $(PKG_CONFIG) --libs dbus-1)
  449. endif
  450. endif
  451. endif
  452. # ---------------------------------------------------------------------------------------------------------------------
  453. # Set libs stuff (libmagic)
  454. ifeq ($(HAVE_LIBMAGICPKG),true)
  455. MAGIC_FLAGS = $(shell $(PKG_CONFIG) --cflags libmagic)
  456. # this is missing in upstream pkg-config
  457. MAGIC_FLAGS += -I$(shell $(PKG_CONFIG) --variable=includedir libmagic)
  458. MAGIC_LIBS = $(shell $(PKG_CONFIG) --libs libmagic)
  459. else ifeq ($(HAVE_LIBMAGIC),true)
  460. MAGIC_LIBS += -lmagic
  461. ifeq ($(LINUX_OR_MACOS),true)
  462. MAGIC_LIBS += -lz
  463. endif
  464. endif
  465. # ---------------------------------------------------------------------------------------------------------------------
  466. # Set libs stuff (rtaudio)
  467. ifeq ($(USING_RTAUDIO),true)
  468. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY
  469. RTMIDI_FLAGS =
  470. ifeq ($(DEBUG),true)
  471. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  472. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  473. endif
  474. ifeq ($(HAVE_ALSA),true)
  475. RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) --cflags alsa) -D__LINUX_ALSA__
  476. RTAUDIO_LIBS += $(shell $(PKG_CONFIG) --libs alsa) -pthread
  477. RTMIDI_FLAGS += $(shell $(PKG_CONFIG) --cflags alsa) -D__LINUX_ALSA__
  478. RTMIDI_LIBS += $(shell $(PKG_CONFIG) --libs alsa)
  479. endif
  480. ifeq ($(HAVE_JACK),true)
  481. ifeq ($(UNIX),true)
  482. RTAUDIO_FLAGS += -D__UNIX_JACK__
  483. endif
  484. endif
  485. ifeq ($(HAVE_PULSEAUDIO),true)
  486. RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) --cflags libpulse-simple) -D__UNIX_PULSE__
  487. RTAUDIO_LIBS += $(shell $(PKG_CONFIG) --libs libpulse-simple)
  488. endif
  489. ifeq ($(MACOS),true)
  490. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  491. RTAUDIO_LIBS += -framework CoreAudio
  492. RTMIDI_FLAGS += -D__MACOSX_CORE__
  493. RTMIDI_LIBS += -framework CoreMIDI
  494. else ifeq ($(WINDOWS),true)
  495. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__ -D__WINDOWS_WASAPI__
  496. RTAUDIO_LIBS += -ldsound -luuid -lksuser
  497. RTMIDI_FLAGS += -D__WINDOWS_MM__
  498. RTMIDI_LIBS += -lwinmm
  499. endif
  500. endif
  501. # ---------------------------------------------------------------------------------------------------------------------
  502. # Set libs stuff (extra)
  503. ifeq ($(BSD),true)
  504. HYLIA_FLAGS =
  505. HYLIA_LIBS =
  506. JACKBRIDGE_LIBS = -pthread -lrt
  507. LILV_LIBS = -lm -lrt
  508. RTMEMPOOL_LIBS = -pthread
  509. WATER_LIBS = -pthread -lrt
  510. else ifeq ($(HAIKU),true)
  511. HYLIA_FLAGS =
  512. HYLIA_LIBS =
  513. JACKBRIDGE_LIBS = -lpthread
  514. LILV_LIBS = -lm
  515. RTMEMPOOL_LIBS = -lpthread
  516. WATER_LIBS = -lpthread
  517. else ifeq ($(HURD),true)
  518. HYLIA_FLAGS =
  519. HYLIA_LIBS =
  520. JACKBRIDGE_LIBS = -ldl -pthread -lrt
  521. LILV_LIBS = -ldl -lm -lrt
  522. RTMEMPOOL_LIBS = -pthread -lrt
  523. WATER_LIBS = -ldl -pthread -lrt
  524. else ifeq ($(LINUX),true)
  525. HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1
  526. HYLIA_LIBS =
  527. JACKBRIDGE_LIBS = -ldl -pthread -lrt
  528. LILV_LIBS = -ldl -lm -lrt
  529. RTMEMPOOL_LIBS = -pthread -lrt
  530. WATER_LIBS = -ldl -pthread -lrt
  531. else ifeq ($(MACOS),true)
  532. HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1
  533. HYLIA_LIBS =
  534. JACKBRIDGE_LIBS = -pthread
  535. LILV_LIBS = -lm
  536. RTMEMPOOL_LIBS = -pthread
  537. WATER_LIBS = -pthread -framework AppKit
  538. else ifeq ($(WASM),true)
  539. HYLIA_FLAGS =
  540. HYLIA_LIBS =
  541. JACKBRIDGE_LIBS =
  542. LILV_LIBS = -ldl -lm
  543. RTMEMPOOL_LIBS =
  544. WATER_LIBS =
  545. else ifeq ($(WINDOWS),true)
  546. HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1
  547. HYLIA_LIBS = -liphlpapi
  548. JACKBRIDGE_LIBS = -pthread
  549. LILV_LIBS = -lm
  550. RTMEMPOOL_LIBS = -pthread
  551. WATER_LIBS = -pthread -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  552. endif
  553. # ---------------------------------------------------------------------------------------------------------------------
  554. AUDIO_DECODER_LIBS = $(FFMPEG_LIBS)
  555. AUDIO_DECODER_LIBS += $(SNDFILE_LIBS)
  556. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  557. NATIVE_PLUGINS_LIBS += $(FFMPEG_LIBS)
  558. NATIVE_PLUGINS_LIBS += $(SNDFILE_LIBS)
  559. STATIC_CARLA_PLUGIN_LIBS = $(AUDIO_DECODER_LIBS)
  560. STATIC_CARLA_PLUGIN_LIBS += $(NATIVE_PLUGINS_LIBS)
  561. STATIC_CARLA_PLUGIN_LIBS += $(FLUIDSYNTH_LIBS)
  562. STATIC_CARLA_PLUGIN_LIBS += $(HYLIA_LIBS)
  563. STATIC_CARLA_PLUGIN_LIBS += $(LIBLO_LIBS)
  564. STATIC_CARLA_PLUGIN_LIBS += $(LILV_LIBS)
  565. STATIC_CARLA_PLUGIN_LIBS += $(MAGIC_LIBS)
  566. STATIC_CARLA_PLUGIN_LIBS += $(RTMEMPOOL_LIBS)
  567. STATIC_CARLA_PLUGIN_LIBS += $(WATER_LIBS)
  568. STATIC_CARLA_PLUGIN_LIBS += $(YSFX_LIBS)
  569. ifeq ($(EXTERNAL_PLUGINS),true)
  570. ifneq ($(DEBUG),true)
  571. ifneq ($(TESTBUILD),true)
  572. ifeq ($(shell $(PKG_CONFIG) --exists liblo fftw3 mxml zlib && echo true),true)
  573. STATIC_CARLA_PLUGIN_LIBS += $(filter-out -lpthread,$(shell $(PKG_CONFIG) --libs liblo fftw3 mxml zlib))
  574. ifneq ($(WASM),true)
  575. STATIC_CARLA_PLUGIN_LIBS += -pthread
  576. endif
  577. endif
  578. endif
  579. endif
  580. endif
  581. # ---------------------------------------------------------------------------------------------------------------------