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