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.

Makefile.mk 22KB

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