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.

499 lines
14KB

  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. # Support for LADSPA, DSSI, LV2, VST and AU plugins
  9. CARLA_PLUGIN_SUPPORT = true
  10. # Support for csound files (version 6, not ready yet)
  11. CARLA_CSOUND_SUPPORT = false
  12. # Support for GIG, SF2 and SFZ sample banks (through fluidsynth and linuxsampler)
  13. CARLA_SAMPLERS_SUPPORT = true
  14. # Use the free vestige header instead of the official VST SDK
  15. CARLA_VESTIGE_HEADER = true
  16. # --------------------------------------------------------------
  17. # DO NOT MODIFY PAST THIS POINT!
  18. AR ?= ar
  19. RM ?= rm -f
  20. CC ?= gcc
  21. CXX ?= g++
  22. # --------------------------------------------------------------
  23. # Fallback to Linux if no other OS defined
  24. ifneq ($(HAIKU),true)
  25. ifneq ($(MACOS),true)
  26. ifneq ($(WIN32),true)
  27. LINUX=true
  28. endif
  29. endif
  30. endif
  31. # --------------------------------------------------------------
  32. # Set MACOS_OR_WIN32
  33. ifeq ($(MACOS),true)
  34. MACOS_OR_WIN32=true
  35. endif
  36. ifeq ($(WIN32),true)
  37. MACOS_OR_WIN32=true
  38. endif
  39. # --------------------------------------------------------------
  40. # Common build and link flags
  41. BASE_FLAGS = -Wall -Wextra -pipe -DREAL_BUILD
  42. BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse -fdata-sections -ffunction-sections
  43. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections
  44. # -Wl,--strip-all
  45. ifeq ($(MACOS),true)
  46. # MacOS linker flags
  47. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  48. endif
  49. ifeq ($(RASPPI),true)
  50. # Raspberry-Pi optimization flags
  51. BASE_OPTS = -O2 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard
  52. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  53. endif
  54. ifneq ($(WIN32),true)
  55. # not needed for Windows
  56. BASE_FLAGS += -fPIC -DPIC
  57. endif
  58. ifeq ($(DEBUG),true)
  59. BASE_FLAGS += -DDEBUG -O0 -g
  60. LINK_OPTS =
  61. else
  62. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  63. CXXFLAGS += -fvisibility-inlines-hidden
  64. endif
  65. 32BIT_FLAGS = -m32
  66. 64BIT_FLAGS = -m64
  67. BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -std=gnu99 $(CFLAGS)
  68. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x -std=gnu++0x $(CXXFLAGS)
  69. LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS)
  70. ifeq ($(MACOS),true)
  71. # No C++11 support
  72. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS)
  73. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  74. endif
  75. # --------------------------------------------------------------
  76. # Strict test build
  77. ifeq ($(TESTBUILD),true)
  78. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  79. ifneq ($(CC),clang)
  80. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  81. endif
  82. ifneq ($(MACOS),true)
  83. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  84. ifneq ($(CC),clang)
  85. BASE_FLAGS += -Wlogical-op
  86. endif
  87. endif
  88. CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  89. CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
  90. ifeq ($(LINUX),true)
  91. CFLAGS += -isystem /opt/kxstudio/include
  92. CXXFLAGS += -isystem /opt/kxstudio/include -isystem /usr/include/qt5
  93. endif
  94. ifeq ($(MACOS),true)
  95. CFLAGS += -isystem /opt/kxstudio/include
  96. CXXFLAGS += -isystem /opt/kxstudio/include -isystem /opt/kxstudio/include/qt5
  97. endif
  98. ifeq ($(WIN32),true)
  99. CFLAGS += -isystem /opt/mingw32/include
  100. CXXFLAGS += -isystem /opt/mingw32/include -isystem /opt/mingw32/include/qt4
  101. endif
  102. endif
  103. # --------------------------------------------------------------
  104. # Check for qt, set default version
  105. HAVE_QT4 = $(shell pkg-config --exists QtCore QtXml && echo true)
  106. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Xml && echo true)
  107. ifeq ($(MACOS_OR_WIN32),true)
  108. DEFAULT_QT ?= 5
  109. else
  110. DEFAULT_QT ?= 4
  111. endif
  112. # --------------------------------------------------------------
  113. # Set Qt tools
  114. ifeq ($(HAVE_QT4),true)
  115. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  116. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  117. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  118. ifeq (,$(wildcard $(MOC_QT4)))
  119. HAVE_QT4=false
  120. endif
  121. endif
  122. ifeq ($(HAVE_QT5),true)
  123. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  124. ifeq ($(MACOS),true)
  125. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  126. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  127. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  128. else # MACOS
  129. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  130. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  131. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  132. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  133. else
  134. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  135. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  136. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  137. endif
  138. endif # MACOS
  139. ifeq (,$(wildcard $(MOC_QT5)))
  140. HAVE_QT5=false
  141. endif
  142. endif
  143. # --------------------------------------------------------------
  144. # Fail if prefered Qt is not found
  145. ifeq ($(DEFAULT_QT),4)
  146. ifneq ($(HAVE_QT4),true)
  147. $(error Qt4 missing, cannot continue)
  148. endif
  149. else
  150. ifneq ($(HAVE_QT5),true)
  151. $(error Qt5 missing, cannot continue)
  152. endif
  153. endif
  154. # --------------------------------------------------------------
  155. # Check for required libs
  156. ifneq ($(shell pkg-config --exists liblo && echo true),true)
  157. $(error liblo missing, cannot continue)
  158. endif
  159. # --------------------------------------------------------------
  160. # Check for dgl support
  161. ifeq ($(HAIKU),true)
  162. HAVE_DGL = false
  163. endif
  164. ifeq ($(LINUX),true)
  165. HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true)
  166. endif
  167. ifeq ($(MACOS),true)
  168. HAVE_DGL = true
  169. endif
  170. ifeq ($(WIN32),true)
  171. HAVE_DGL = true
  172. endif
  173. # --------------------------------------------------------------
  174. # Check for juce support
  175. ifeq ($(HAIKU),true)
  176. HAVE_JUCE = false
  177. endif
  178. ifeq ($(LINUX),true)
  179. HAVE_JUCE = $(shell pkg-config --exists x11 xinerama xext xcursor freetype2 && echo true)
  180. endif
  181. ifeq ($(MACOS),true)
  182. HAVE_JUCE = true
  183. endif
  184. ifeq ($(WIN32),true)
  185. HAVE_JUCE = true
  186. endif
  187. # --------------------------------------------------------------
  188. # Check for optional libs (required by backend or bridges)
  189. ifneq ($(MACOS_OR_WIN32),true)
  190. HAVE_FFMPEG = $(shell pkg-config --exists libavcodec libavformat libavutil && echo true)
  191. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  192. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  193. ifeq ($(HAVE_QT4),true)
  194. HAVE_QTGUI4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  195. endif
  196. ifeq ($(HAVE_QT5),true)
  197. HAVE_QTGUI5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  198. endif
  199. HAVE_WAYLAND = $(shell pkg-config --exists wayland-client && echo true)
  200. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  201. endif
  202. ifeq ($(LINUX),true)
  203. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  204. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  205. endif
  206. ifeq ($(CARLA_CSOUND_SUPPORT),true)
  207. ifeq ($(HAVE_JUCE),true)
  208. HAVE_CSOUND = $(shell pkg-config --exists sndfile && echo true)
  209. endif
  210. endif
  211. ifeq ($(CARLA_SAMPLERS_SUPPORT),true)
  212. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  213. HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true)
  214. endif
  215. # --------------------------------------------------------------
  216. # Check for optional libs (required by internal plugins)
  217. HAVE_AF_DEPS = $(shell pkg-config --exists sndfile && echo true)
  218. HAVE_MF_DEPS = $(shell pkg-config --exists smf && echo true)
  219. HAVE_PM_DEPS = $(shell pkg-config --exists libprojectM && echo true)
  220. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  221. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  222. # --------------------------------------------------------------
  223. # Force some features on MacOS and Windows
  224. ifeq ($(MACOS_OR_WIN32),true)
  225. CARLA_VESTIGE_HEADER = false
  226. endif
  227. # --------------------------------------------------------------
  228. # Set base defines
  229. ifeq ($(HAVE_DGL),true)
  230. BASE_FLAGS += -DHAVE_DGL
  231. endif
  232. ifeq ($(HAVE_FFMPEG),true)
  233. BASE_FLAGS += -DHAVE_FFMPEG
  234. endif
  235. ifeq ($(HAVE_JUCE),true)
  236. BASE_FLAGS += -DHAVE_JUCE
  237. endif
  238. ifeq ($(HAVE_WAYLAND),true)
  239. BASE_FLAGS += -DHAVE_WAYLAND
  240. endif
  241. ifeq ($(HAVE_X11),true)
  242. BASE_FLAGS += -DHAVE_X11
  243. endif
  244. # --------------------------------------------------------------
  245. # Set libs stuff (part 1)
  246. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  247. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  248. ifeq ($(DEFAULT_QT),4)
  249. QTCORE_FLAGS = $(shell pkg-config --cflags QtCore)
  250. QTCORE_LIBS = $(shell pkg-config --libs QtCore)
  251. QTXML_FLAGS = $(shell pkg-config --cflags QtXml)
  252. QTXML_LIBS = $(shell pkg-config --libs QtXml)
  253. else
  254. QTCORE_FLAGS = $(shell pkg-config --cflags Qt5Core)
  255. QTCORE_LIBS = $(shell pkg-config --libs Qt5Core)
  256. QTXML_FLAGS = $(shell pkg-config --cflags Qt5Xml)
  257. QTXML_LIBS = $(shell pkg-config --libs Qt5Xml)
  258. endif
  259. ifeq ($(HAVE_CSOUND),true)
  260. CSOUND_FLAGS = -DUSE_DOUBLE=1
  261. CSOUND_LIBS = $(shell pkg-config --libs sndfile) -lcsound64
  262. endif
  263. ifeq ($(HAVE_FLUIDSYNTH),true)
  264. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  265. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  266. endif
  267. ifeq ($(HAVE_LINUXSAMPLER),true)
  268. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -Wno-unused-parameter
  269. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  270. endif
  271. ifeq ($(HAVE_WAYLAND),true)
  272. WAYLAND_FLAGS = $(shell pkg-config --cflags wayland-client)
  273. WAYLAND_LIBS = $(shell pkg-config --libs wayland-client)
  274. endif
  275. ifeq ($(HAVE_X11),true)
  276. X11_FLAGS = $(shell pkg-config --cflags x11)
  277. X11_LIBS = $(shell pkg-config --libs x11)
  278. endif
  279. # --------------------------------------------------------------
  280. # Set libs stuff (part 2)
  281. ifeq ($(HAVE_AF_DEPS),true)
  282. AUDIO_DECODER_FLAGS = $(shell pkg-config --cflags sndfile)
  283. AUDIO_DECODER_LIBS = $(shell pkg-config --libs sndfile)
  284. ifeq ($(HAVE_FFMPEG),true)
  285. AUDIO_DECODER_FLAGS += $(shell pkg-config --cflags libavcodec libavformat libavutil)
  286. AUDIO_DECODER_LIBS += $(shell pkg-config --libs libavcodec libavformat libavutil)
  287. endif
  288. endif
  289. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  290. ifeq ($(DEBUG),true)
  291. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  292. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  293. endif
  294. ifneq ($(HAIKU),true)
  295. RTMEMPOOL_LIBS = -lpthread
  296. endif
  297. ifeq ($(LINUX),true)
  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. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  303. ifeq ($(HAVE_JUCE),true)
  304. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  305. JUCE_EVENTS_FLAGS = $(shell pkg-config --cflags x11)
  306. JUCE_EVENTS_LIBS = $(shell pkg-config --libs x11)
  307. JUCE_GRAPHICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext freetype2)
  308. JUCE_GRAPHICS_LIBS = $(shell pkg-config --libs x11 xinerama xext freetype2)
  309. JUCE_GUI_BASICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext xcursor)
  310. JUCE_GUI_BASICS_LIBS = $(shell pkg-config --libs x11 xinerama xext xcursor)
  311. endif
  312. LILV_LIBS = -ldl -lm -lrt
  313. ifeq ($(HAVE_ALSA),true)
  314. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  315. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  316. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  317. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  318. endif
  319. ifeq ($(HAVE_PULSEAUDIO),true)
  320. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  321. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  322. endif
  323. endif
  324. ifeq ($(MACOS),true)
  325. DGL_LIBS = -framework OpenGL -framework Cocoa
  326. JACKBRIDGE_LIBS = -ldl -lpthread
  327. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  328. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  329. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  330. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  331. JUCE_CORE_LIBS = -framework AppKit
  332. JUCE_EVENTS_LIBS = -framework AppKit
  333. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  334. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  335. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  336. LILV_LIBS = -ldl -lm
  337. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  338. RTAUDIO_LIBS += -framework CoreAudio -framework CoreFoundation -lpthread
  339. RTMIDI_FLAGS += -D__MACOSX_CORE__
  340. RTMIDI_LIBS += -framework CoreAudio -framework CoreMIDI -framework CoreFoundation
  341. endif
  342. ifeq ($(WIN32),true)
  343. DGL_LIBS = -lopengl32 -lgdi32
  344. JACKBRIDGE_LIBS = -lpthread
  345. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  346. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  347. # JUCE_EVENTS_LIBS = -lole32
  348. JUCE_GRAPHICS_LIBS = -lgdi32
  349. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  350. LILV_LIBS = -lm
  351. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__
  352. RTAUDIO_LIBS += -ldsound -lpthread
  353. RTMIDI_FLAGS += -D__WINDOWS_MM__
  354. endif
  355. # --------------------------------------------------------------
  356. # Set libs stuff (part 3)
  357. ifeq ($(HAVE_DGL),true)
  358. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  359. endif
  360. ifeq ($(HAVE_AF_DEPS),true)
  361. NATIVE_PLUGINS_FLAGS += -DWANT_AUDIOFILE
  362. NATIVE_PLUGINS_LIBS += $(AUDIO_DECODER_LIBS)
  363. endif
  364. ifeq ($(HAVE_MF_DEPS),true)
  365. NATIVE_PLUGINS_FLAGS += -DWANT_MIDIFILE
  366. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs smf)
  367. endif
  368. ifeq ($(HAVE_PM_DEPS),true)
  369. NATIVE_PLUGINS_FLAGS += -DWANT_PROJECTM
  370. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs libprojectM)
  371. endif
  372. ifeq ($(HAVE_ZYN_DEPS),true)
  373. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX
  374. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  375. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  376. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX_UI
  377. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  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. # --------------------------------------------------------------