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.

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