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.

798 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. ifneq ($(MACOS_OLD),true)
  363. ifeq ($(HAVE_PYQT),true)
  364. HAVE_THEME = true
  365. MOC_QT5 ?= moc
  366. RCC_QT5 ?= rcc
  367. UIC_QT5 ?= uic
  368. endif
  369. endif
  370. endif
  371. endif
  372. # ---------------------------------------------------------------------------------------------------------------------
  373. # Set USING_JUCE
  374. ifeq ($(MACOS_OR_WIN32),true)
  375. ifneq ($(MACOS_OLD),true)
  376. USING_JUCE = true
  377. USING_JUCE_AUDIO_DEVICES = true
  378. endif
  379. endif
  380. ifeq ($(HAVE_JUCE_LINUX_DEPS),true)
  381. USING_JUCE = true
  382. endif
  383. ifeq ($(USING_JUCE),true)
  384. ifeq ($(LINUX_OR_MACOS),true)
  385. USING_JUCE_GUI_EXTRA = true
  386. endif
  387. endif
  388. # ---------------------------------------------------------------------------------------------------------------------
  389. # Set base defines
  390. ifeq ($(JACKBRIDGE_DIRECT),true)
  391. ifeq ($(HAVE_JACK),true)
  392. BASE_FLAGS += -DJACKBRIDGE_DIRECT
  393. else
  394. $(error jackbridge direct mode requested, but jack not available)
  395. endif
  396. endif
  397. ifeq ($(HAVE_DGL),true)
  398. BASE_FLAGS += -DHAVE_DGL
  399. BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL -DDGL_FILE_BROWSER_DISABLED -DDGL_NO_SHARED_RESOURCES
  400. endif
  401. ifeq ($(HAVE_FLUIDSYNTH),true)
  402. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  403. ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
  404. BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
  405. endif
  406. endif
  407. ifeq ($(HAVE_FFMPEG),true)
  408. BASE_FLAGS += -DHAVE_FFMPEG
  409. endif
  410. ifeq ($(HAVE_HYLIA),true)
  411. BASE_FLAGS += -DHAVE_HYLIA
  412. endif
  413. ifeq ($(HAVE_LIBLO),true)
  414. BASE_FLAGS += -DHAVE_LIBLO
  415. endif
  416. ifeq ($(HAVE_LIBMAGIC),true)
  417. BASE_FLAGS += -DHAVE_LIBMAGIC
  418. endif
  419. ifeq ($(HAVE_PYQT),true)
  420. BASE_FLAGS += -DHAVE_PYQT
  421. endif
  422. ifeq ($(HAVE_SNDFILE),true)
  423. BASE_FLAGS += -DHAVE_SNDFILE
  424. endif
  425. ifeq ($(HAVE_X11),true)
  426. BASE_FLAGS += -DHAVE_X11
  427. endif
  428. ifeq ($(USING_JUCE),true)
  429. BASE_FLAGS += -DUSING_JUCE
  430. endif
  431. ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
  432. BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
  433. endif
  434. ifeq ($(USING_JUCE_GUI_EXTRA),true)
  435. BASE_FLAGS += -DUSING_JUCE_GUI_EXTRA
  436. endif
  437. # ---------------------------------------------------------------------------------------------------------------------
  438. # Set libs stuff (part 1)
  439. ifeq ($(LINUX_OR_MACOS),true)
  440. LIBDL_LIBS = -ldl
  441. endif
  442. ifeq ($(WIN32),true)
  443. PKG_CONFIG_FLAGS = --static
  444. endif
  445. ifeq ($(HAVE_DGL),true)
  446. ifeq ($(MACOS),true)
  447. DGL_LIBS = -framework OpenGL -framework Cocoa
  448. endif
  449. ifeq ($(WIN32),true)
  450. DGL_LIBS = -lopengl32 -lgdi32
  451. endif
  452. ifneq ($(MACOS_OR_WIN32),true)
  453. DGL_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags gl x11)
  454. DGL_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs gl x11)
  455. endif
  456. endif
  457. ifeq ($(HAVE_LIBLO),true)
  458. LIBLO_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags liblo)
  459. LIBLO_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs liblo)
  460. endif
  461. ifeq ($(HAVE_LIBMAGIC),true)
  462. MAGIC_LIBS += -lmagic
  463. ifeq ($(LINUX_OR_MACOS),true)
  464. MAGIC_LIBS += -lz
  465. endif
  466. endif
  467. ifeq ($(HAVE_FFMPEG),true)
  468. FFMPEG_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libavcodec libavformat libavutil)
  469. FFMPEG_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libavcodec libavformat libavutil)
  470. endif
  471. ifeq ($(HAVE_FLUIDSYNTH),true)
  472. FLUIDSYNTH_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags fluidsynth)
  473. FLUIDSYNTH_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs fluidsynth)
  474. endif
  475. ifeq ($(HAVE_JACK),true)
  476. JACK_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags jack)
  477. JACK_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs jack)
  478. JACK_LIBDIR = $(shell $(PKG_CONFIG) --variable=libdir jack)/jack
  479. endif
  480. ifeq ($(HAVE_QT5),true)
  481. QT5_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags Qt5Core Qt5Gui Qt5Widgets)
  482. QT5_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs Qt5Core Qt5Gui Qt5Widgets)
  483. endif
  484. ifeq ($(HAVE_SNDFILE),true)
  485. SNDFILE_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags sndfile)
  486. SNDFILE_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs sndfile)
  487. endif
  488. ifeq ($(HAVE_X11),true)
  489. X11_FLAGS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags x11)
  490. X11_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11)
  491. endif
  492. # ---------------------------------------------------------------------------------------------------------------------
  493. # Set libs stuff (part 2)
  494. ifneq ($(USING_JUCE_AUDIO_DEVICES),true)
  495. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY
  496. RTMIDI_FLAGS =
  497. ifeq ($(DEBUG),true)
  498. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  499. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  500. endif
  501. ifeq ($(LINUX),true)
  502. ifeq ($(HAVE_ALSA),true)
  503. RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags alsa) -D__LINUX_ALSA__
  504. RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa) -lpthread
  505. RTMIDI_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags alsa) -D__LINUX_ALSA__
  506. RTMIDI_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa)
  507. endif
  508. endif
  509. ifeq ($(MACOS),true)
  510. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  511. RTAUDIO_LIBS += -framework CoreAudio
  512. RTMIDI_FLAGS += -D__MACOSX_CORE__
  513. RTMIDI_LIBS += -framework CoreMIDI
  514. endif
  515. ifeq ($(UNIX),true)
  516. RTAUDIO_FLAGS += -D__UNIX_JACK__
  517. ifeq ($(HAVE_PULSEAUDIO),true)
  518. RTAUDIO_FLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags libpulse-simple) -D__UNIX_PULSE__
  519. RTAUDIO_LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs libpulse-simple)
  520. endif
  521. endif
  522. ifeq ($(WIN32),true)
  523. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__ -D__WINDOWS_WASAPI__
  524. RTAUDIO_LIBS += -ldsound -luuid -lksuser -lwinmm
  525. RTMIDI_FLAGS += -D__WINDOWS_MM__
  526. endif
  527. endif # USING_JUCE_AUDIO_DEVICES
  528. ifeq ($(BSD),true)
  529. JACKBRIDGE_LIBS = -lpthread -lrt
  530. LILV_LIBS = -lm -lrt
  531. RTMEMPOOL_LIBS = -lpthread
  532. WATER_LIBS = -lpthread -lrt
  533. endif
  534. ifeq ($(HAIKU),true)
  535. JACKBRIDGE_LIBS = -lpthread
  536. LILV_LIBS = -lm
  537. RTMEMPOOL_LIBS = -lpthread
  538. WATER_LIBS = -lpthread
  539. endif
  540. ifeq ($(HURD),true)
  541. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  542. LILV_LIBS = -ldl -lm -lrt
  543. RTMEMPOOL_LIBS = -lpthread -lrt
  544. WATER_LIBS = -ldl -lpthread -lrt
  545. endif
  546. ifeq ($(LINUX),true)
  547. HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1
  548. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  549. LILV_LIBS = -ldl -lm -lrt
  550. RTMEMPOOL_LIBS = -lpthread -lrt
  551. WATER_LIBS = -ldl -lpthread -lrt
  552. ifeq ($(USING_JUCE),true)
  553. JUCE_AUDIO_DEVICES_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs alsa)
  554. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  555. JUCE_EVENTS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11)
  556. JUCE_GRAPHICS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs freetype2)
  557. JUCE_GUI_BASICS_LIBS = $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs x11 xext)
  558. endif # USING_JUCE
  559. endif # LINUX
  560. ifeq ($(MACOS),true)
  561. HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1
  562. JACKBRIDGE_LIBS = -ldl -lpthread
  563. LILV_LIBS = -ldl -lm
  564. RTMEMPOOL_LIBS = -lpthread
  565. WATER_LIBS = -framework AppKit
  566. ifeq ($(USING_JUCE),true)
  567. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  568. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  569. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  570. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  571. JUCE_CORE_LIBS = -framework AppKit
  572. JUCE_EVENTS_LIBS = -framework AppKit
  573. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  574. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  575. JUCE_GUI_EXTRA_LIBS = -framework IOKit
  576. endif # USING_JUCE
  577. endif # MACOS
  578. ifeq ($(WIN32),true)
  579. HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1
  580. HYLIA_LIBS = -liphlpapi
  581. JACKBRIDGE_LIBS = -lpthread
  582. LILV_LIBS = -lm
  583. RTMEMPOOL_LIBS = -lpthread
  584. WATER_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  585. ifeq ($(USING_JUCE),true)
  586. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  587. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  588. JUCE_GRAPHICS_LIBS = -lgdi32
  589. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  590. endif # USING_JUCE
  591. endif # WIN32
  592. # ---------------------------------------------------------------------------------------------------------------------
  593. AUDIO_DECODER_LIBS = $(FFMPEG_LIBS)
  594. AUDIO_DECODER_LIBS += $(SNDFILE_LIBS)
  595. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  596. NATIVE_PLUGINS_LIBS += $(FFMPEG_LIBS)
  597. NATIVE_PLUGINS_LIBS += $(SNDFILE_LIBS)
  598. # ---------------------------------------------------------------------------------------------------------------------
  599. # Set app extension
  600. ifeq ($(WIN32),true)
  601. APP_EXT = .exe
  602. endif
  603. # ---------------------------------------------------------------------------------------------------------------------
  604. # Set shared lib extension
  605. LIB_EXT = .so
  606. ifeq ($(MACOS),true)
  607. LIB_EXT = .dylib
  608. endif
  609. ifeq ($(WIN32),true)
  610. LIB_EXT = .dll
  611. endif
  612. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  613. # ---------------------------------------------------------------------------------------------------------------------
  614. # Set static libs start & end
  615. ifneq ($(MACOS),true)
  616. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  617. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  618. endif
  619. # ---------------------------------------------------------------------------------------------------------------------
  620. # Set shared library CLI arg
  621. ifeq ($(MACOS),true)
  622. SHARED = -dynamiclib
  623. else
  624. SHARED = -shared
  625. endif
  626. # ---------------------------------------------------------------------------------------------------------------------
  627. # Set arguments used for inline 'sed'
  628. ifeq ($(BSD),true)
  629. SED_ARGS=-i '' -e
  630. else
  631. SED_ARGS=-i -e
  632. endif
  633. # ---------------------------------------------------------------------------------------------------------------------
  634. # Set command used for file symlinking
  635. LINK := ln -sf
  636. # ---------------------------------------------------------------------------------------------------------------------
  637. # Check if we can generate ttl files
  638. ifneq ($(BUILDING_FOR_WINE),true)
  639. ifeq ($(CROSS_COMPILING),true)
  640. ifeq ($(WIN32),true)
  641. NEEDS_WINE = true
  642. endif
  643. endif
  644. endif
  645. ifneq ($(CROSS_COMPILING),true)
  646. CAN_GENERATE_LV2_TTL = true
  647. else ifeq ($(NEEDS_WINE),true)
  648. CAN_GENERATE_LV2_TTL = true
  649. endif
  650. # ---------------------------------------------------------------------------------------------------------------------
  651. # Check if we should build the external plugins
  652. ifeq ($(EXTERNAL_PLUGINS),true)
  653. ifneq ($(DEBUG),true)
  654. ifneq ($(TESTBUILD),true)
  655. ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
  656. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  657. include $(CWD)/native-plugins/external/Makefile.mk
  658. endif
  659. endif
  660. endif
  661. endif
  662. # ---------------------------------------------------------------------------------------------------------------------