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.

493 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_DGL),true)
  241. BASE_FLAGS += -DHAVE_DGL
  242. endif
  243. ifeq ($(HAVE_FLUIDSYNTH),true)
  244. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  245. endif
  246. ifeq ($(HAVE_HYLIA),true)
  247. BASE_FLAGS += -DHAVE_HYLIA
  248. endif
  249. ifeq ($(HAVE_LIBLO),true)
  250. BASE_FLAGS += -DHAVE_LIBLO
  251. endif
  252. ifeq ($(HAVE_LIBMAGIC),true)
  253. BASE_FLAGS += -DHAVE_LIBMAGIC
  254. endif
  255. ifeq ($(HAVE_LINUXSAMPLER),true)
  256. BASE_FLAGS += -DHAVE_LINUXSAMPLER
  257. endif
  258. ifeq ($(HAVE_PROJECTM),true)
  259. BASE_FLAGS += -DHAVE_PROJECTM
  260. endif
  261. ifeq ($(HAVE_X11),true)
  262. BASE_FLAGS += -DHAVE_X11
  263. endif
  264. ifeq ($(CARLA_VESTIGE_HEADER),true)
  265. BASE_FLAGS += -DVESTIGE_HEADER
  266. endif
  267. # --------------------------------------------------------------
  268. # Set libs stuff (part 1)
  269. ifeq ($(HAVE_LIBLO),true)
  270. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  271. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  272. endif
  273. ifeq ($(HAVE_FLUIDSYNTH),true)
  274. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  275. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  276. endif
  277. ifeq ($(HAVE_LINUXSAMPLER),true)
  278. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -DIS_CPP11=1 -Wno-non-virtual-dtor -Wno-shadow -Wno-unused-parameter
  279. ifeq ($(LINUX),true)
  280. LINUXSAMPLER_LIBS = -Wl,-rpath=$(shell pkg-config --variable=libdir gig):$(shell pkg-config --variable=libdir linuxsampler)
  281. endif
  282. LINUXSAMPLER_LIBS += $(shell pkg-config --libs linuxsampler)
  283. endif
  284. ifeq ($(HAVE_PROJECTM),true)
  285. PROJECTM_FLAGS = $(shell pkg-config --cflags libprojectM)
  286. PROJECTM_LIBS = $(shell pkg-config --libs libprojectM)
  287. endif
  288. ifeq ($(HAVE_X11),true)
  289. X11_FLAGS = $(shell pkg-config --cflags x11)
  290. X11_LIBS = $(shell pkg-config --libs x11)
  291. endif
  292. # --------------------------------------------------------------
  293. # Set libs stuff (part 2)
  294. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  295. ifeq ($(DEBUG),true)
  296. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  297. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  298. endif
  299. ifneq ($(HAIKU),true)
  300. RTMEMPOOL_LIBS = -lpthread
  301. endif
  302. ifeq ($(UNIX),true)
  303. HYLIA_FLAGS +=
  304. endif
  305. ifeq ($(LINUX),true)
  306. HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1
  307. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  308. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  309. LILV_LIBS = -ldl -lm -lrt
  310. ifeq ($(HAVE_DGL),true)
  311. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  312. DGL_LIBS = $(shell pkg-config --libs gl x11)
  313. endif
  314. ifeq ($(HAVE_ALSA),true)
  315. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  316. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  317. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  318. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  319. endif
  320. ifeq ($(HAVE_PULSEAUDIO),true)
  321. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  322. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  323. endif
  324. endif
  325. ifeq ($(MACOS),true)
  326. DGL_LIBS = -framework OpenGL -framework Cocoa
  327. HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1
  328. JACKBRIDGE_LIBS = -ldl -lpthread
  329. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  330. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  331. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  332. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  333. JUCE_CORE_LIBS = -framework AppKit
  334. JUCE_EVENTS_LIBS = -framework AppKit
  335. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  336. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  337. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  338. LILV_LIBS = -ldl -lm
  339. endif
  340. ifeq ($(WIN32),true)
  341. DGL_LIBS = -lopengl32 -lgdi32
  342. HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1
  343. JACKBRIDGE_LIBS = -lpthread
  344. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  345. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  346. JUCE_GRAPHICS_LIBS = -lgdi32
  347. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  348. LILV_LIBS = -lm
  349. endif
  350. # --------------------------------------------------------------
  351. # Set libs stuff (part 3)
  352. HAVE_ZYN_DEPS = $(shell pkg-config --exists liblo fftw3 mxml zlib && echo true)
  353. ifeq ($(HAVE_FLTK),true)
  354. HAVE_ZYN_UI_DEPS = true
  355. endif
  356. ifeq ($(HAVE_NTK),true)
  357. HAVE_ZYN_UI_DEPS = true
  358. endif
  359. ifeq ($(HAVE_DGL),true)
  360. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  361. ifeq ($(HAVE_PROJECTM),true)
  362. NATIVE_PLUGINS_LIBS += $(PROJECTM_LIBS)
  363. endif
  364. endif
  365. ifeq ($(EXPERIMENTAL_PLUGINS),true)
  366. BASE_FLAGS += -DHAVE_EXPERIMENTAL_PLUGINS
  367. NATIVE_PLUGINS_LIBS += -lclthreads -lzita-convolver -lzita-resampler
  368. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3f)
  369. endif
  370. ifeq ($(HAVE_ZYN_DEPS),true)
  371. BASE_FLAGS += -DHAVE_ZYN_DEPS
  372. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs liblo fftw3 mxml zlib)
  373. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  374. BASE_FLAGS += -DHAVE_ZYN_UI_DEPS
  375. endif
  376. endif
  377. # --------------------------------------------------------------
  378. # Set app extension
  379. ifeq ($(WIN32),true)
  380. APP_EXT = .exe
  381. endif
  382. # --------------------------------------------------------------
  383. # Set shared lib extension
  384. LIB_EXT = .so
  385. ifeq ($(MACOS),true)
  386. LIB_EXT = .dylib
  387. endif
  388. ifeq ($(WIN32),true)
  389. LIB_EXT = .dll
  390. endif
  391. # --------------------------------------------------------------
  392. # Set static libs start & end
  393. ifneq ($(MACOS),true)
  394. LIBS_START = -Wl,--start-group
  395. LIBS_END = -Wl,--end-group
  396. endif
  397. # --------------------------------------------------------------
  398. # Set shared library CLI arg
  399. ifeq ($(MACOS),true)
  400. SHARED = -dynamiclib
  401. else
  402. SHARED = -shared
  403. endif
  404. # --------------------------------------------------------------