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.

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