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.

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