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.

776 lines
22KB

  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. WINECC ?= winegcc
  12. # ---------------------------------------------------------------------------------------------------------------------
  13. # Internationalization
  14. I18N_LANGUAGES :=
  15. # ---------------------------------------------------------------------------------------------------------------------
  16. # Auto-detect OS if not defined
  17. TARGET_MACHINE := $(shell $(CC) -dumpmachine)
  18. ifneq ($(BSD),true)
  19. ifneq ($(HAIKU),true)
  20. ifneq ($(HURD),true)
  21. ifneq ($(LINUX),true)
  22. ifneq ($(MACOS),true)
  23. ifneq ($(WIN32),true)
  24. ifneq (,$(findstring bsd,$(TARGET_MACHINE)))
  25. BSD=true
  26. endif
  27. ifneq (,$(findstring haiku,$(TARGET_MACHINE)))
  28. HAIKU=true
  29. endif
  30. ifneq (,$(findstring gnu,$(TARGET_MACHINE)))
  31. HURD=true
  32. endif
  33. ifneq (,$(findstring linux,$(TARGET_MACHINE)))
  34. LINUX=true
  35. endif
  36. ifneq (,$(findstring apple,$(TARGET_MACHINE)))
  37. MACOS=true
  38. endif
  39. ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
  40. WIN32=true
  41. ifneq (,$(findstring x86_64,$(TARGET_MACHINE)))
  42. WIN64=true
  43. endif
  44. endif
  45. ifneq (,$(findstring msys,$(TARGET_MACHINE)))
  46. WIN32=true
  47. endif
  48. endif # WIN32
  49. endif # MACOS
  50. endif # LINUX
  51. endif # HURD
  52. endif # HAIKU
  53. endif # BSD
  54. # ---------------------------------------------------------------------------------------------------------------------
  55. # Auto-detect the processor
  56. TARGET_PROCESSOR := $(firstword $(subst -, ,$(TARGET_MACHINE)))
  57. ifneq (,$(filter i%86,$(TARGET_PROCESSOR)))
  58. CPU_I386=true
  59. CPU_I386_OR_X86_64=true
  60. endif
  61. ifneq (,$(filter x86_64,$(TARGET_PROCESSOR)))
  62. CPU_X86_64=true
  63. CPU_I386_OR_X86_64=true
  64. endif
  65. ifneq (,$(filter arm%,$(TARGET_PROCESSOR)))
  66. CPU_ARM=true
  67. CPU_ARM_OR_AARCH64=true
  68. endif
  69. ifneq (,$(filter arm64%,$(TARGET_PROCESSOR)))
  70. CPU_ARM64=true
  71. CPU_ARM_OR_AARCH64=true
  72. endif
  73. ifneq (,$(filter aarch64%,$(TARGET_PROCESSOR)))
  74. CPU_AARCH64=true
  75. CPU_ARM_OR_AARCH64=true
  76. endif
  77. # ---------------------------------------------------------------------------------------------------------------------
  78. # Set PKG_CONFIG (can be overridden by environment variable)
  79. ifeq ($(WIN32),true)
  80. # Build statically on Windows by default
  81. PKG_CONFIG ?= pkg-config --static
  82. else
  83. PKG_CONFIG ?= pkg-config
  84. endif
  85. # ---------------------------------------------------------------------------------------------------------------------
  86. # Set LINUX_OR_MACOS
  87. ifeq ($(LINUX),true)
  88. LINUX_OR_MACOS=true
  89. endif
  90. ifeq ($(MACOS),true)
  91. LINUX_OR_MACOS=true
  92. endif
  93. # ---------------------------------------------------------------------------------------------------------------------
  94. # Set MACOS_OR_WIN32 and HAIKU_OR_MACOS_OR_WINDOWS
  95. ifeq ($(HAIKU),true)
  96. HAIKU_OR_MACOS_OR_WIN32=true
  97. endif
  98. ifeq ($(MACOS),true)
  99. MACOS_OR_WIN32=true
  100. HAIKU_OR_MACOS_OR_WIN32=true
  101. endif
  102. ifeq ($(WIN32),true)
  103. MACOS_OR_WIN32=true
  104. HAIKU_OR_MACOS_OR_WIN32=true
  105. endif
  106. # ---------------------------------------------------------------------------------------------------------------------
  107. # Set UNIX
  108. ifeq ($(BSD),true)
  109. UNIX=true
  110. endif
  111. ifeq ($(HURD),true)
  112. UNIX=true
  113. endif
  114. ifeq ($(LINUX),true)
  115. UNIX=true
  116. endif
  117. ifeq ($(MACOS),true)
  118. UNIX=true
  119. endif
  120. # ---------------------------------------------------------------------------------------------------------------------
  121. # Set build and link flags
  122. BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MD -MP -fno-common
  123. BASE_OPTS = -O3 -ffast-math -fdata-sections -ffunction-sections
  124. ifeq ($(CPU_I386_OR_X86_64),true)
  125. BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse
  126. endif
  127. ifeq ($(CPU_ARM),true)
  128. ifneq ($(CPU_ARM64),true)
  129. BASE_OPTS += -mfpu=neon-vfpv4 -mfloat-abi=hard
  130. endif
  131. endif
  132. ifeq ($(MACOS),true)
  133. # MacOS linker flags
  134. BASE_FLAGS += -Wno-deprecated-declarations
  135. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  136. else
  137. # Common linker flags
  138. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed
  139. ifneq ($(SKIP_STRIPPING),true)
  140. LINK_OPTS += -Wl,--strip-all
  141. endif
  142. endif
  143. ifeq ($(NOOPT),true)
  144. # No CPU-specific optimization flags
  145. BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections -DBUILDING_CARLA_NOOPT
  146. endif
  147. ifeq ($(WIN32),true)
  148. # mingw has issues with this specific optimization
  149. # See https://github.com/falkTX/Carla/issues/696
  150. BASE_OPTS += -fno-rerun-cse-after-loop
  151. # See https://github.com/falkTX/Carla/issues/855
  152. BASE_OPTS += -mstackrealign
  153. ifeq ($(BUILDING_FOR_WINE),true)
  154. BASE_FLAGS += -DBUILDING_CARLA_FOR_WINE
  155. endif
  156. else
  157. # Not needed for Windows
  158. BASE_FLAGS += -fPIC -DPIC
  159. endif
  160. ifeq ($(CLANG),true)
  161. BASE_FLAGS += -Wabsolute-value
  162. endif
  163. ifeq ($(DEBUG),true)
  164. BASE_FLAGS += -DDEBUG -O0 -g
  165. LINK_OPTS =
  166. else
  167. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  168. CXXFLAGS += -fvisibility-inlines-hidden
  169. endif
  170. 32BIT_FLAGS = -m32
  171. 64BIT_FLAGS = -m64
  172. ARM32_FLAGS = -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad
  173. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  174. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++0x $(CXXFLAGS)
  175. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  176. ifneq ($(MACOS),true)
  177. # Not available on MacOS
  178. LINK_FLAGS += -Wl,--no-undefined
  179. endif
  180. ifeq ($(MACOS_OLD),true)
  181. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
  182. endif
  183. ifeq ($(WIN32),true)
  184. # Always build statically on windows
  185. LINK_FLAGS += -static
  186. endif
  187. # ---------------------------------------------------------------------------------------------------------------------
  188. # Strict test build
  189. ifeq ($(TESTBUILD),true)
  190. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wdisabled-optimization
  191. BASE_FLAGS += -Wdouble-promotion -Wfloat-equal -Wpointer-arith -Wsign-conversion
  192. BASE_FLAGS += -Wformat=2 -Woverlength-strings
  193. BASE_FLAGS += -Wmissing-declarations -Wredundant-decls
  194. BASE_FLAGS += -Wshadow -Wundef -Wuninitialized -Wunused
  195. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  196. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  197. BASE_FLAGS += -Wnull-dereference
  198. ifneq ($(CLANG),true)
  199. BASE_FLAGS += -Wabi=98 -Wclobbered -Wlogical-op
  200. BASE_FLAGS += -Wformat-truncation=2 -Wformat-overflow=2
  201. BASE_FLAGS += -Wstringop-overflow=4 -Wstringop-truncation
  202. BASE_FLAGS += -Wduplicated-branches -Wduplicated-cond
  203. endif
  204. CFLAGS += -Winit-self -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wwrite-strings
  205. ifneq ($(CLANG),true)
  206. CFLAGS += -Wjump-misses-init
  207. endif
  208. CXXFLAGS += -Wc++0x-compat -Wc++11-compat
  209. CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
  210. # CXXFLAGS += -Wold-style-cast -Wuseless-cast
  211. CXXFLAGS += -Wzero-as-null-pointer-constant
  212. ifneq ($(DEBUG),true)
  213. CXXFLAGS += -Weffc++
  214. endif
  215. ifeq ($(LINUX),true)
  216. BASE_FLAGS += -isystem /opt/kxstudio/include
  217. endif
  218. ifeq ($(MACOS),true)
  219. CXXFLAGS += -isystem /System/Library/Frameworks
  220. endif
  221. ifeq ($(WIN32),true)
  222. BASE_FLAGS += -isystem /opt/mingw32/include
  223. endif
  224. ifeq ($(WIN64),true)
  225. BASE_FLAGS += -isystem /opt/mingw64/include
  226. endif
  227. # TODO
  228. ifeq ($(CLANG),true)
  229. BASE_FLAGS += -Wno-double-promotion
  230. BASE_FLAGS += -Wno-format-nonliteral
  231. BASE_FLAGS += -Wno-tautological-pointer-compare
  232. endif
  233. endif
  234. # ---------------------------------------------------------------------------------------------------------------------
  235. # Check for optional libs (required by backend or bridges)
  236. ifeq ($(LINUX),true)
  237. HAVE_ALSA = $(shell $(PKG_CONFIG) --exists alsa && echo true)
  238. HAVE_HYLIA = true
  239. endif
  240. ifeq ($(MACOS),true)
  241. ifneq ($(MACOS_OLD),true)
  242. HAVE_HYLIA = true
  243. endif
  244. endif
  245. ifeq ($(WIN32),true)
  246. HAVE_HYLIA = true
  247. endif
  248. ifeq ($(MACOS_OR_WIN32),true)
  249. HAVE_DGL = true
  250. else
  251. HAVE_DGL = $(shell $(PKG_CONFIG) --exists gl x11 && echo true)
  252. HAVE_GTK2 = $(shell $(PKG_CONFIG) --exists gtk+-2.0 && echo true)
  253. HAVE_GTK3 = $(shell $(PKG_CONFIG) --exists gtk+-3.0 && echo true)
  254. HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true)
  255. endif
  256. ifeq ($(UNIX),true)
  257. ifneq ($(MACOS),true)
  258. HAVE_PULSEAUDIO = $(shell $(PKG_CONFIG) --exists libpulse-simple && echo true)
  259. endif
  260. endif
  261. # ffmpeg values taken from https://ffmpeg.org/download.html (v2.8.15 maximum)
  262. HAVE_FFMPEG = $(shell $(PKG_CONFIG) --max-version=56.60.100 libavcodec && \
  263. $(PKG_CONFIG) --max-version=56.40.101 libavformat && \
  264. $(PKG_CONFIG) --max-version=54.31.100 libavutil && echo true)
  265. HAVE_FLUIDSYNTH = $(shell $(PKG_CONFIG) --atleast-version=1.1.7 fluidsynth && echo true)
  266. HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true)
  267. HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
  268. HAVE_QT4 = $(shell $(PKG_CONFIG) --exists QtCore QtGui && echo true)
  269. HAVE_QT5 = $(shell $(PKG_CONFIG) --exists Qt5Core Qt5Gui Qt5Widgets && \
  270. $(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true)
  271. HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && echo true)
  272. ifeq ($(HAVE_FLUIDSYNTH),true)
  273. HAVE_FLUIDSYNTH_INSTPATCH = $(shell $(PKG_CONFIG) --atleast-version=2.1.0 fluidsynth && \
  274. $(PKG_CONFIG) --atleast-version=1.1.4 libinstpatch-1.0 && echo true)
  275. endif
  276. ifeq ($(LINUX),true)
  277. # juce only supports the most common architectures
  278. ifneq (,$(findstring arm,$(TARGET_MACHINE)))
  279. HAVE_JUCE_SUPPORTED_ARCH = true
  280. endif
  281. ifneq (,$(findstring aarch64,$(TARGET_MACHINE)))
  282. HAVE_JUCE_SUPPORTED_ARCH = true
  283. endif
  284. ifneq (,$(findstring i486,$(TARGET_MACHINE)))
  285. HAVE_JUCE_SUPPORTED_ARCH = true
  286. endif
  287. ifneq (,$(findstring i586,$(TARGET_MACHINE)))
  288. HAVE_JUCE_SUPPORTED_ARCH = true
  289. endif
  290. ifneq (,$(findstring i686,$(TARGET_MACHINE)))
  291. HAVE_JUCE_SUPPORTED_ARCH = true
  292. endif
  293. ifneq (,$(findstring x86_64,$(TARGET_MACHINE)))
  294. HAVE_JUCE_SUPPORTED_ARCH = true
  295. endif
  296. ifeq ($(HAVE_JUCE_SUPPORTED_ARCH),true)
  297. HAVE_JUCE_LINUX_DEPS = $(shell $(PKG_CONFIG) --exists x11 xcursor xext freetype2 && echo true)
  298. endif
  299. endif
  300. # ---------------------------------------------------------------------------------------------------------------------
  301. # Check for optional libs (special non-pkgconfig tests)
  302. ifneq ($(WIN32),true)
  303. ifeq ($(shell $(PKG_CONFIG) --exists libmagic && echo true),true)
  304. HAVE_LIBMAGIC = true
  305. else
  306. # old libmagic versions don't have a pkg-config file, so we need to call the compiler to test it
  307. CFLAGS_WITHOUT_ARCH = $(subst -arch arm64,,$(CFLAGS))
  308. HAVE_LIBMAGIC = $(shell echo '\#include <magic.h>' | $(CC) $(CFLAGS_WITHOUT_ARCH) -x c -w -c - -o /dev/null 2>/dev/null && echo true)
  309. endif
  310. endif
  311. # ---------------------------------------------------------------------------------------------------------------------
  312. # Set Qt tools
  313. ifeq ($(HAVE_QT4),true)
  314. MOC_QT4 ?= $(shell $(PKG_CONFIG) --variable=moc_location QtCore)
  315. RCC_QT4 ?= $(shell $(PKG_CONFIG) --variable=rcc_location QtCore)
  316. UIC_QT4 ?= $(shell $(PKG_CONFIG) --variable=uic_location QtCore)
  317. ifeq (,$(wildcard $(MOC_QT4)))
  318. HAVE_QT4=false
  319. endif
  320. ifeq (,$(wildcard $(RCC_QT4)))
  321. HAVE_QT4=false
  322. endif
  323. endif
  324. ifeq ($(HAVE_QT5),true)
  325. QT5_HOSTBINS = $(shell $(PKG_CONFIG) --variable=host_bins Qt5Core)
  326. MOC_QT5 ?= $(QT5_HOSTBINS)/moc
  327. RCC_QT5 ?= $(QT5_HOSTBINS)/rcc
  328. UIC_QT5 ?= $(QT5_HOSTBINS)/uic
  329. ifeq (,$(wildcard $(MOC_QT5)))
  330. HAVE_QT5=false
  331. endif
  332. ifeq (,$(wildcard $(RCC_QT5)))
  333. HAVE_QT5=false
  334. endif
  335. endif
  336. ifeq ($(HAVE_QT4),true)
  337. HAVE_QT=true
  338. endif
  339. ifeq ($(HAVE_QT5),true)
  340. HAVE_QT=true
  341. endif
  342. ifeq ($(WIN32),true)
  343. HAVE_QT=true
  344. endif
  345. # ---------------------------------------------------------------------------------------------------------------------
  346. # Set PyQt tools
  347. PYRCC5 ?= $(shell which pyrcc5 2>/dev/null)
  348. PYUIC5 ?= $(shell which pyuic5 2>/dev/null)
  349. ifneq ($(PYUIC5),)
  350. ifneq ($(PYRCC5),)
  351. HAVE_PYQT = true
  352. endif
  353. endif
  354. # ---------------------------------------------------------------------------------------------------------------------
  355. # Set PyQt tools, part2
  356. PYRCC ?= $(PYRCC5)
  357. PYUIC ?= $(PYUIC5)
  358. ifeq ($(HAVE_QT5),true)
  359. HAVE_THEME = true
  360. else
  361. ifeq ($(MACOS),true)
  362. ifeq ($(HAVE_PYQT),true)
  363. HAVE_THEME = true
  364. endif
  365. endif
  366. endif
  367. # ---------------------------------------------------------------------------------------------------------------------
  368. # Set USING_JUCE
  369. ifeq ($(MACOS_OR_WIN32),true)
  370. ifneq ($(MACOS_OLD),true)
  371. USING_JUCE = true
  372. USING_JUCE_AUDIO_DEVICES = true
  373. endif
  374. endif
  375. ifeq ($(HAVE_JUCE_LINUX_DEPS),true)
  376. USING_JUCE = true
  377. endif
  378. ifeq ($(USING_JUCE),true)
  379. ifeq ($(LINUX_OR_MACOS),true)
  380. USING_JUCE_GUI_EXTRA = true
  381. endif
  382. endif
  383. # ---------------------------------------------------------------------------------------------------------------------
  384. # Set base defines
  385. ifeq ($(JACKBRIDGE_DIRECT),true)
  386. ifeq ($(HAVE_JACK),true)
  387. BASE_FLAGS += -DJACKBRIDGE_DIRECT
  388. else
  389. $(error jackbridge direct mode requested, but jack not available)
  390. endif
  391. endif
  392. ifeq ($(HAVE_DGL),true)
  393. BASE_FLAGS += -DHAVE_DGL
  394. BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL -DDGL_FILE_BROWSER_DISABLED -DDGL_NO_SHARED_RESOURCES
  395. endif
  396. ifeq ($(HAVE_FLUIDSYNTH),true)
  397. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  398. ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
  399. BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
  400. endif
  401. endif
  402. ifeq ($(HAVE_FFMPEG),true)
  403. BASE_FLAGS += -DHAVE_FFMPEG
  404. endif
  405. ifeq ($(HAVE_HYLIA),true)
  406. BASE_FLAGS += -DHAVE_HYLIA
  407. endif
  408. ifeq ($(HAVE_LIBLO),true)
  409. BASE_FLAGS += -DHAVE_LIBLO
  410. endif
  411. ifeq ($(HAVE_LIBMAGIC),true)
  412. BASE_FLAGS += -DHAVE_LIBMAGIC
  413. endif
  414. ifeq ($(HAVE_PYQT),true)
  415. BASE_FLAGS += -DHAVE_PYQT
  416. endif
  417. ifeq ($(HAVE_SNDFILE),true)
  418. BASE_FLAGS += -DHAVE_SNDFILE
  419. endif
  420. ifeq ($(HAVE_X11),true)
  421. BASE_FLAGS += -DHAVE_X11
  422. endif
  423. ifeq ($(USING_JUCE),true)
  424. BASE_FLAGS += -DUSING_JUCE
  425. endif
  426. ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
  427. BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
  428. endif
  429. ifeq ($(USING_JUCE_GUI_EXTRA),true)
  430. BASE_FLAGS += -DUSING_JUCE_GUI_EXTRA
  431. endif
  432. # ---------------------------------------------------------------------------------------------------------------------
  433. # Set libs stuff (part 1)
  434. ifeq ($(LINUX_OR_MACOS),true)
  435. LIBDL_LIBS = -ldl
  436. endif
  437. ifeq ($(WIN32),true)
  438. PKG_CONFIG_FLAGS = --static
  439. endif
  440. ifeq ($(HAVE_DGL),true)
  441. ifeq ($(MACOS),true)
  442. DGL_LIBS = -framework OpenGL -framework Cocoa
  443. endif
  444. ifeq ($(WIN32),true)
  445. DGL_LIBS = -lopengl32 -lgdi32
  446. endif
  447. ifneq ($(MACOS_OR_WIN32),true)
  448. DGL_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags gl x11)
  449. DGL_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs gl x11)
  450. endif
  451. endif
  452. ifeq ($(HAVE_LIBLO),true)
  453. LIBLO_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags liblo)
  454. LIBLO_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs liblo)
  455. endif
  456. ifeq ($(HAVE_LIBMAGIC),true)
  457. MAGIC_LIBS += -lmagic
  458. ifeq ($(LINUX_OR_MACOS),true)
  459. MAGIC_LIBS += -lz
  460. endif
  461. endif
  462. ifeq ($(HAVE_FFMPEG),true)
  463. FFMPEG_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libavcodec libavformat libavutil)
  464. FFMPEG_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libavcodec libavformat libavutil)
  465. endif
  466. ifeq ($(HAVE_FLUIDSYNTH),true)
  467. FLUIDSYNTH_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags fluidsynth)
  468. FLUIDSYNTH_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs fluidsynth)
  469. endif
  470. ifeq ($(HAVE_JACK),true)
  471. JACK_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags jack)
  472. JACK_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs jack)
  473. JACK_LIBDIR = $(shell $(PKG_CONFIG) --variable=libdir jack)/jack
  474. endif
  475. ifeq ($(HAVE_QT5),true)
  476. QT5_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags Qt5Core Qt5Gui Qt5Widgets)
  477. QT5_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs Qt5Core Qt5Gui Qt5Widgets)
  478. endif
  479. ifeq ($(HAVE_SNDFILE),true)
  480. SNDFILE_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags sndfile)
  481. SNDFILE_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs sndfile)
  482. endif
  483. ifeq ($(HAVE_X11),true)
  484. X11_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags x11)
  485. X11_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11)
  486. endif
  487. # ---------------------------------------------------------------------------------------------------------------------
  488. # Set libs stuff (part 2)
  489. ifneq ($(USING_JUCE_AUDIO_DEVICES),true)
  490. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY
  491. RTMIDI_FLAGS =
  492. ifeq ($(DEBUG),true)
  493. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  494. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  495. endif
  496. ifeq ($(LINUX),true)
  497. ifeq ($(HAVE_ALSA),true)
  498. RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags alsa) -D__LINUX_ALSA__
  499. RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa) -lpthread
  500. RTMIDI_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags alsa) -D__LINUX_ALSA__
  501. RTMIDI_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa)
  502. endif
  503. endif
  504. ifeq ($(MACOS),true)
  505. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  506. RTAUDIO_LIBS += -framework CoreAudio
  507. RTMIDI_FLAGS += -D__MACOSX_CORE__
  508. RTMIDI_LIBS += -framework CoreMIDI
  509. endif
  510. ifeq ($(UNIX),true)
  511. RTAUDIO_FLAGS += -D__UNIX_JACK__
  512. ifeq ($(HAVE_PULSEAUDIO),true)
  513. RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libpulse-simple) -D__UNIX_PULSE__
  514. RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libpulse-simple)
  515. endif
  516. endif
  517. ifeq ($(WIN32),true)
  518. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__ -D__WINDOWS_WASAPI__
  519. RTAUDIO_LIBS += -ldsound -luuid -lksuser -lwinmm
  520. RTMIDI_FLAGS += -D__WINDOWS_MM__
  521. endif
  522. endif # USING_JUCE_AUDIO_DEVICES
  523. ifeq ($(BSD),true)
  524. JACKBRIDGE_LIBS = -lpthread -lrt
  525. LILV_LIBS = -lm -lrt
  526. RTMEMPOOL_LIBS = -lpthread
  527. WATER_LIBS = -lpthread -lrt
  528. endif
  529. ifeq ($(HAIKU),true)
  530. JACKBRIDGE_LIBS = -lpthread
  531. LILV_LIBS = -lm
  532. RTMEMPOOL_LIBS = -lpthread
  533. WATER_LIBS = -lpthread
  534. endif
  535. ifeq ($(HURD),true)
  536. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  537. LILV_LIBS = -ldl -lm -lrt
  538. RTMEMPOOL_LIBS = -lpthread -lrt
  539. WATER_LIBS = -ldl -lpthread -lrt
  540. endif
  541. ifeq ($(LINUX),true)
  542. HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1
  543. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  544. LILV_LIBS = -ldl -lm -lrt
  545. RTMEMPOOL_LIBS = -lpthread -lrt
  546. WATER_LIBS = -ldl -lpthread -lrt
  547. ifeq ($(USING_JUCE),true)
  548. JUCE_AUDIO_DEVICES_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa)
  549. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  550. JUCE_EVENTS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11)
  551. JUCE_GRAPHICS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs freetype2)
  552. JUCE_GUI_BASICS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11 xext)
  553. endif # USING_JUCE
  554. endif # LINUX
  555. ifeq ($(MACOS),true)
  556. HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1
  557. JACKBRIDGE_LIBS = -ldl -lpthread
  558. LILV_LIBS = -ldl -lm
  559. RTMEMPOOL_LIBS = -lpthread
  560. WATER_LIBS = -framework AppKit
  561. ifeq ($(USING_JUCE),true)
  562. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  563. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  564. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  565. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  566. JUCE_CORE_LIBS = -framework AppKit
  567. JUCE_EVENTS_LIBS = -framework AppKit
  568. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  569. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  570. JUCE_GUI_EXTRA_LIBS = -framework IOKit
  571. endif # USING_JUCE
  572. endif # MACOS
  573. ifeq ($(WIN32),true)
  574. HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1
  575. HYLIA_LIBS = -liphlpapi
  576. JACKBRIDGE_LIBS = -lpthread
  577. LILV_LIBS = -lm
  578. RTMEMPOOL_LIBS = -lpthread
  579. WATER_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  580. ifeq ($(USING_JUCE),true)
  581. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  582. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  583. JUCE_GRAPHICS_LIBS = -lgdi32
  584. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  585. endif # USING_JUCE
  586. endif # WIN32
  587. # ---------------------------------------------------------------------------------------------------------------------
  588. AUDIO_DECODER_LIBS = $(FFMPEG_LIBS)
  589. AUDIO_DECODER_LIBS += $(SNDFILE_LIBS)
  590. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  591. NATIVE_PLUGINS_LIBS += $(FFMPEG_LIBS)
  592. NATIVE_PLUGINS_LIBS += $(SNDFILE_LIBS)
  593. # ---------------------------------------------------------------------------------------------------------------------
  594. # Set app extension
  595. ifeq ($(WIN32),true)
  596. APP_EXT = .exe
  597. endif
  598. # ---------------------------------------------------------------------------------------------------------------------
  599. # Set shared lib extension
  600. LIB_EXT = .so
  601. ifeq ($(MACOS),true)
  602. LIB_EXT = .dylib
  603. endif
  604. ifeq ($(WIN32),true)
  605. LIB_EXT = .dll
  606. endif
  607. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  608. # ---------------------------------------------------------------------------------------------------------------------
  609. # Set static libs start & end
  610. ifneq ($(MACOS),true)
  611. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  612. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  613. endif
  614. # ---------------------------------------------------------------------------------------------------------------------
  615. # Set shared library CLI arg
  616. ifeq ($(MACOS),true)
  617. SHARED = -dynamiclib
  618. else
  619. SHARED = -shared
  620. endif
  621. # ---------------------------------------------------------------------------------------------------------------------
  622. # Set arguments used for inline 'sed'
  623. ifeq ($(BSD),true)
  624. SED_ARGS=-i '' -e
  625. else
  626. SED_ARGS=-i -e
  627. endif
  628. # ---------------------------------------------------------------------------------------------------------------------
  629. # Set command used for file symlinking
  630. LINK := ln -sf
  631. # ---------------------------------------------------------------------------------------------------------------------
  632. ifneq ($(DEBUG),true)
  633. ifneq ($(TESTBUILD),true)
  634. ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
  635. EXTERNAL_PLUGINS = true
  636. ifeq ($(EXTERNAL_PLUGINS),true)
  637. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  638. include $(CWD)/native-plugins/external/Makefile.mk
  639. endif
  640. endif
  641. endif
  642. endif
  643. # ---------------------------------------------------------------------------------------------------------------------