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.

497 lines
13KB

  1. #!/usr/bin/make -f
  2. # Makefile for Carla C++ code #
  3. # --------------------------- #
  4. # Created by falkTX
  5. #
  6. # --------------------------------------------------------------
  7. # Modify to enable/disable specific features
  8. # Use the free vestige header instead of the official VST SDK
  9. CARLA_VESTIGE_HEADER = true
  10. # Enable experimental plugins, don't complain if the build fails when using this!
  11. EXPERIMENTAL_PLUGINS = false
  12. # --------------------------------------------------------------
  13. # DO NOT MODIFY PAST THIS POINT!
  14. AR ?= ar
  15. CC ?= gcc
  16. CXX ?= g++
  17. # --------------------------------------------------------------
  18. # Fallback to Linux if no other OS defined
  19. ifneq ($(HAIKU),true)
  20. ifneq ($(MACOS),true)
  21. ifneq ($(WIN32),true)
  22. LINUX=true
  23. endif
  24. endif
  25. endif
  26. # --------------------------------------------------------------
  27. # Set MACOS_OR_WIN32
  28. ifeq ($(MACOS),true)
  29. MACOS_OR_WIN32=true
  30. endif
  31. ifeq ($(WIN32),true)
  32. MACOS_OR_WIN32=true
  33. endif
  34. # --------------------------------------------------------------
  35. # Set UNIX
  36. ifeq ($(LINUX),true)
  37. UNIX=true
  38. endif
  39. ifeq ($(MACOS),true)
  40. UNIX=true
  41. endif
  42. # --------------------------------------------------------------
  43. # Force some features on MacOS and Windows
  44. ifeq ($(MACOS_OR_WIN32),true)
  45. CARLA_VESTIGE_HEADER = false
  46. EXPERIMENTAL_PLUGINS = false
  47. endif
  48. # --------------------------------------------------------------
  49. # Set build and link flags
  50. BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MD -MP
  51. BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse -fdata-sections -ffunction-sections
  52. ifeq ($(MACOS),true)
  53. # MacOS linker flags
  54. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  55. else
  56. # Common linker flags
  57. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed
  58. ifneq ($(SKIP_STRIPPING),true)
  59. LINK_OPTS += -Wl,--strip-all
  60. endif
  61. endif
  62. ifeq ($(RASPPI),true)
  63. # Raspberry-Pi optimization flags
  64. BASE_OPTS = -O2 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard
  65. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  66. endif
  67. ifeq ($(NOOPT),true)
  68. # No optimization flags
  69. BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
  70. endif
  71. ifneq ($(WIN32),true)
  72. # Not needed for Windows
  73. BASE_FLAGS += -fPIC -DPIC
  74. endif
  75. ifeq ($(CLANG),true)
  76. BASE_FLAGS += -Wabsolute-value
  77. endif
  78. ifeq ($(STOAT),true)
  79. CC = clang
  80. CXX = clang++
  81. BASE_FLAGS += -emit-llvm
  82. BASE_OPTS += -O0
  83. endif
  84. ifeq ($(DEBUG),true)
  85. BASE_FLAGS += -DDEBUG -O0 -g
  86. ifeq ($(WIN32),true)
  87. BASE_FLAGS += -msse -msse2
  88. endif
  89. LINK_OPTS =
  90. else
  91. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  92. CXXFLAGS += -fvisibility-inlines-hidden
  93. endif
  94. 32BIT_FLAGS = -m32
  95. 64BIT_FLAGS = -m64
  96. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  97. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++0x $(CXXFLAGS)
  98. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  99. ifneq ($(MACOS),true)
  100. # Not available on MacOS
  101. LINK_FLAGS += -Wl,--no-undefined
  102. endif
  103. # --------------------------------------------------------------
  104. # Strict test build
  105. ifeq ($(TESTBUILD),true)
  106. BASE_FLAGS += -Werror -Wabi -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-declarations
  107. BASE_FLAGS += -Woverlength-strings -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wundef -Wuninitialized -Wunused
  108. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  109. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  110. CFLAGS += -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings
  111. CXXFLAGS += -Wc++0x-compat -Wc++11-compat -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wzero-as-null-pointer-constant
  112. ifeq ($(LINUX),true)
  113. BASE_FLAGS += -isystem /opt/kxstudio/include
  114. CXXFLAGS += -isystem /opt/kxstudio/include/ntk
  115. CXXFLAGS += -isystem /usr/include/glib-2.0
  116. CXXFLAGS += -isystem /usr/include/glib-2.0/glib
  117. CXXFLAGS += -isystem /usr/include/gtk-2.0
  118. CXXFLAGS += -isystem /usr/include/gtk-2.0/gio
  119. ifeq ($(DEFAULT_QT),4)
  120. CXXFLAGS += -isystem /usr/include/qt4
  121. else
  122. CXXFLAGS += -isystem /usr/include/qt5
  123. endif
  124. endif
  125. ifeq ($(MACOS),true)
  126. BASE_FLAGS += -isystem /opt/kxstudio/include
  127. CXXFLAGS += -isystem /System/Library/Frameworks
  128. endif
  129. ifeq ($(WIN64),true)
  130. BASE_FLAGS += -isystem /opt/mingw64/include
  131. else
  132. ifeq ($(WIN32),true)
  133. BASE_FLAGS += -isystem /opt/mingw32/include
  134. endif
  135. endif
  136. endif
  137. # --------------------------------------------------------------
  138. # Check for optional libs (required by backend or bridges)
  139. ifeq ($(MACOS_OR_WIN32),true)
  140. HAVE_DGL = true
  141. HAVE_HYLIA = true
  142. else
  143. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  144. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  145. ifeq ($(LINUX),true)
  146. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  147. HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true)
  148. HAVE_HYLIA = true
  149. HAVE_NTK = $(shell pkg-config --exists ntk ntk_images && echo true)
  150. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  151. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  152. endif
  153. endif
  154. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  155. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  156. HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true)
  157. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  158. HAVE_LINUXSAMPLER = $(shell pkg-config --atleast-version=1.0.0.svn41 linuxsampler && echo true)
  159. HAVE_PROJECTM = $(shell pkg-config --exists libprojectM && echo true)
  160. # --------------------------------------------------------------
  161. # Check for optional libs (special non-pkgconfig unix tests)
  162. ifeq ($(UNIX),true)
  163. # libmagic doesn't have a pkg-config file, so we need to call the compiler to test it
  164. HAVE_LIBMAGIC = $(shell echo '\#include <magic.h>' | $(CC) $(CFLAGS) -x c -w -c - -o .libmagic-tmp 2>/dev/null && echo true)
  165. # fltk doesn't have a pkg-config file but has fltk-config instead.
  166. # Also, don't try looking for it if we already have NTK.
  167. ifneq ($(HAVE_NTK),true)
  168. ifeq ($(shell which fltk-config 1>/dev/null 2>/dev/null && echo true),true)
  169. ifeq ($(shell which fluid 1>/dev/null 2>/dev/null && echo true),true)
  170. HAVE_FLTK = true
  171. endif
  172. endif
  173. endif
  174. endif
  175. # --------------------------------------------------------------
  176. # Set Qt tools
  177. ifeq ($(HAVE_QT4),true)
  178. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  179. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  180. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  181. ifeq (,$(wildcard $(MOC_QT4)))
  182. HAVE_QT4=false
  183. endif
  184. endif
  185. ifeq ($(HAVE_QT5),true)
  186. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  187. ifeq ($(MACOS),true)
  188. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  189. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  190. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  191. else # MACOS
  192. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  193. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  194. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  195. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  196. else
  197. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  198. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  199. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  200. endif
  201. endif # MACOS
  202. ifeq (,$(wildcard $(MOC_QT5)))
  203. HAVE_QT5=false
  204. endif
  205. endif
  206. ifeq ($(HAVE_QT4),true)
  207. HAVE_QT=true
  208. endif
  209. ifeq ($(HAVE_QT5),true)
  210. HAVE_QT=true
  211. endif
  212. ifeq ($(WIN32),true)
  213. HAVE_QT=true
  214. endif
  215. # --------------------------------------------------------------
  216. # Set PyQt tools
  217. PYUIC4 ?= /usr/bin/pyuic4
  218. PYUIC5 ?= /usr/bin/pyuic5
  219. ifneq (,$(wildcard $(PYUIC4)))
  220. HAVE_PYQT=true
  221. HAVE_PYQT4=true
  222. else
  223. HAVE_PYQT4=false
  224. endif
  225. ifneq (,$(wildcard $(PYUIC5)))
  226. HAVE_PYQT=true
  227. HAVE_PYQT5=true
  228. else
  229. HAVE_PYQT5=false
  230. endif
  231. # --------------------------------------------------------------
  232. # Set default Qt used in frontend
  233. ifeq ($(HAVE_PYQT4),true)
  234. DEFAULT_QT ?= 4
  235. else
  236. DEFAULT_QT ?= 5
  237. endif
  238. # --------------------------------------------------------------
  239. # Set base defines
  240. ifeq ($(HAVE_PYQT),true)
  241. BASE_FLAGS += -DHAVE_PYQT
  242. endif
  243. ifeq ($(HAVE_DGL),true)
  244. BASE_FLAGS += -DHAVE_DGL
  245. endif
  246. ifeq ($(HAVE_FLUIDSYNTH),true)
  247. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  248. endif
  249. ifeq ($(HAVE_HYLIA),true)
  250. BASE_FLAGS += -DHAVE_HYLIA
  251. endif
  252. ifeq ($(HAVE_LIBLO),true)
  253. BASE_FLAGS += -DHAVE_LIBLO
  254. endif
  255. ifeq ($(HAVE_LIBMAGIC),true)
  256. BASE_FLAGS += -DHAVE_LIBMAGIC
  257. endif
  258. ifeq ($(HAVE_LINUXSAMPLER),true)
  259. BASE_FLAGS += -DHAVE_LINUXSAMPLER
  260. endif
  261. ifeq ($(HAVE_PROJECTM),true)
  262. BASE_FLAGS += -DHAVE_PROJECTM
  263. endif
  264. ifeq ($(HAVE_X11),true)
  265. BASE_FLAGS += -DHAVE_X11
  266. endif
  267. ifeq ($(CARLA_VESTIGE_HEADER),true)
  268. BASE_FLAGS += -DVESTIGE_HEADER
  269. endif
  270. # --------------------------------------------------------------
  271. # Set libs stuff (part 1)
  272. ifeq ($(HAVE_LIBLO),true)
  273. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  274. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  275. endif
  276. ifeq ($(HAVE_FLUIDSYNTH),true)
  277. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  278. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  279. endif
  280. ifeq ($(HAVE_LINUXSAMPLER),true)
  281. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -DIS_CPP11=1 -Wno-non-virtual-dtor -Wno-shadow -Wno-unused-parameter
  282. ifeq ($(LINUX),true)
  283. LINUXSAMPLER_LIBS = -Wl,-rpath=$(shell pkg-config --variable=libdir gig):$(shell pkg-config --variable=libdir linuxsampler)
  284. endif
  285. LINUXSAMPLER_LIBS += $(shell pkg-config --libs linuxsampler)
  286. endif
  287. ifeq ($(HAVE_PROJECTM),true)
  288. PROJECTM_FLAGS = $(shell pkg-config --cflags libprojectM)
  289. PROJECTM_LIBS = $(shell pkg-config --libs libprojectM)
  290. endif
  291. ifeq ($(HAVE_X11),true)
  292. X11_FLAGS = $(shell pkg-config --cflags x11)
  293. X11_LIBS = $(shell pkg-config --libs x11)
  294. endif
  295. # --------------------------------------------------------------
  296. # Set libs stuff (part 2)
  297. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  298. ifeq ($(DEBUG),true)
  299. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  300. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  301. endif
  302. ifneq ($(HAIKU),true)
  303. RTMEMPOOL_LIBS = -lpthread
  304. endif
  305. ifeq ($(UNIX),true)
  306. HYLIA_FLAGS +=
  307. endif
  308. ifeq ($(LINUX),true)
  309. HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1
  310. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  311. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  312. LILV_LIBS = -ldl -lm -lrt
  313. ifeq ($(HAVE_DGL),true)
  314. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  315. DGL_LIBS = $(shell pkg-config --libs gl x11)
  316. endif
  317. ifeq ($(HAVE_ALSA),true)
  318. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  319. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  320. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  321. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  322. endif
  323. ifeq ($(HAVE_PULSEAUDIO),true)
  324. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  325. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  326. endif
  327. endif
  328. ifeq ($(MACOS),true)
  329. DGL_LIBS = -framework OpenGL -framework Cocoa
  330. HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1
  331. JACKBRIDGE_LIBS = -ldl -lpthread
  332. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  333. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  334. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  335. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  336. JUCE_CORE_LIBS = -framework AppKit
  337. JUCE_EVENTS_LIBS = -framework AppKit
  338. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  339. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  340. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  341. LILV_LIBS = -ldl -lm
  342. endif
  343. ifeq ($(WIN32),true)
  344. DGL_LIBS = -lopengl32 -lgdi32
  345. HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1
  346. JACKBRIDGE_LIBS = -lpthread
  347. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  348. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  349. JUCE_GRAPHICS_LIBS = -lgdi32
  350. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  351. LILV_LIBS = -lm
  352. endif
  353. # --------------------------------------------------------------
  354. # Set libs stuff (part 3)
  355. HAVE_ZYN_DEPS = $(shell pkg-config --exists liblo fftw3 mxml zlib && echo true)
  356. ifeq ($(HAVE_FLTK),true)
  357. HAVE_ZYN_UI_DEPS = true
  358. endif
  359. ifeq ($(HAVE_NTK),true)
  360. HAVE_ZYN_UI_DEPS = true
  361. endif
  362. ifeq ($(HAVE_DGL),true)
  363. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  364. ifeq ($(HAVE_PROJECTM),true)
  365. NATIVE_PLUGINS_LIBS += $(PROJECTM_LIBS)
  366. endif
  367. endif
  368. ifeq ($(EXPERIMENTAL_PLUGINS),true)
  369. BASE_FLAGS += -DHAVE_EXPERIMENTAL_PLUGINS
  370. NATIVE_PLUGINS_LIBS += -lclthreads -lzita-convolver -lzita-resampler
  371. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3f)
  372. endif
  373. ifeq ($(HAVE_ZYN_DEPS),true)
  374. BASE_FLAGS += -DHAVE_ZYN_DEPS
  375. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs liblo fftw3 mxml zlib)
  376. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  377. BASE_FLAGS += -DHAVE_ZYN_UI_DEPS
  378. endif
  379. endif
  380. # --------------------------------------------------------------
  381. # Set app extension
  382. ifeq ($(WIN32),true)
  383. APP_EXT = .exe
  384. endif
  385. # --------------------------------------------------------------
  386. # Set shared lib extension
  387. LIB_EXT = .so
  388. ifeq ($(MACOS),true)
  389. LIB_EXT = .dylib
  390. endif
  391. ifeq ($(WIN32),true)
  392. LIB_EXT = .dll
  393. endif
  394. # --------------------------------------------------------------
  395. # Set static libs start & end
  396. ifneq ($(MACOS),true)
  397. LIBS_START = -Wl,--start-group
  398. LIBS_END = -Wl,--end-group
  399. endif
  400. # --------------------------------------------------------------
  401. # Set shared library CLI arg
  402. ifeq ($(MACOS),true)
  403. SHARED = -dynamiclib
  404. else
  405. SHARED = -shared
  406. endif
  407. # --------------------------------------------------------------