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.

445 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. # 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/qt4
  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. ifneq ($(HAVE_QT5),true)
  110. $(error Qt5 missing, cannot continue)
  111. endif
  112. else
  113. DEFAULT_QT=4
  114. ifneq ($(HAVE_QT4),true)
  115. $(error Qt4 missing, cannot continue)
  116. endif
  117. endif
  118. # --------------------------------------------------------------
  119. # Check for required libs
  120. ifneq ($(shell pkg-config --exists liblo && echo true),true)
  121. $(error liblo missing, cannot continue)
  122. endif
  123. # --------------------------------------------------------------
  124. # Check for dgl support
  125. ifeq ($(HAIKU),true)
  126. HAVE_DGL = false
  127. endif
  128. ifeq ($(LINUX),true)
  129. HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true)
  130. endif
  131. ifeq ($(MACOS),true)
  132. HAVE_DGL = true
  133. endif
  134. ifeq ($(WIN32),true)
  135. HAVE_DGL = true
  136. endif
  137. # --------------------------------------------------------------
  138. # Check for juce support
  139. ifeq ($(HAIKU),true)
  140. HAVE_JUCE = false
  141. endif
  142. ifeq ($(LINUX),true)
  143. HAVE_JUCE = $(shell pkg-config --exists x11 xinerama xext xcursor freetype2 && echo true)
  144. endif
  145. ifeq ($(MACOS),true)
  146. HAVE_JUCE = true
  147. endif
  148. ifeq ($(WIN32),true)
  149. HAVE_JUCE = true
  150. endif
  151. # --------------------------------------------------------------
  152. # Check for optional libs (required by backend or bridges)
  153. ifneq ($(MACOS_OR_WIN32),true)
  154. HAVE_FFMPEG = $(shell pkg-config --exists libavcodec libavformat libavutil && echo true)
  155. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  156. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  157. HAVE_QTGUI4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  158. HAVE_QTGUI5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  159. HAVE_WAYLAND = $(shell pkg-config --exists wayland-client && echo true)
  160. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  161. endif
  162. ifeq ($(LINUX),true)
  163. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  164. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  165. endif
  166. ifeq ($(CARLA_CSOUND_SUPPORT),true)
  167. ifeq ($(HAVE_JUCE),true)
  168. HAVE_CSOUND = $(shell pkg-config --exists sndfile && echo true)
  169. endif
  170. endif
  171. ifeq ($(CARLA_SAMPLERS_SUPPORT),true)
  172. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  173. HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true)
  174. endif
  175. # --------------------------------------------------------------
  176. # Check for optional libs (required by internal plugins)
  177. HAVE_AF_DEPS = $(shell pkg-config --exists sndfile && echo true)
  178. HAVE_MF_DEPS = $(shell pkg-config --exists smf && echo true)
  179. HAVE_PM_DEPS = $(shell pkg-config --exists libprojectM && echo true)
  180. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  181. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  182. # --------------------------------------------------------------
  183. # Force some features on MacOS and Windows
  184. ifeq ($(MACOS_OR_WIN32),true)
  185. CARLA_VESTIGE_HEADER = false
  186. endif
  187. # --------------------------------------------------------------
  188. # Set base defines
  189. ifeq ($(HAVE_DGL),true)
  190. BASE_FLAGS += -DHAVE_DGL
  191. endif
  192. ifeq ($(HAVE_FFMPEG),true)
  193. BASE_FLAGS += -DHAVE_FFMPEG
  194. endif
  195. ifeq ($(HAVE_JUCE),true)
  196. BASE_FLAGS += -DHAVE_JUCE
  197. endif
  198. ifeq ($(HAVE_WAYLAND),true)
  199. BASE_FLAGS += -DHAVE_WAYLAND
  200. endif
  201. ifeq ($(HAVE_X11),true)
  202. BASE_FLAGS += -DHAVE_X11
  203. endif
  204. # --------------------------------------------------------------
  205. # Set libs stuff (part 1)
  206. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  207. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  208. ifeq ($(DEFAULT_QT),5)
  209. QTCORE_FLAGS = $(shell pkg-config --cflags Qt5Core)
  210. QTCORE_LIBS = $(shell pkg-config --libs Qt5Core)
  211. QTXML_FLAGS = $(shell pkg-config --cflags Qt5Xml)
  212. QTXML_LIBS = $(shell pkg-config --libs Qt5Xml)
  213. else
  214. QTCORE_FLAGS = $(shell pkg-config --cflags QtCore)
  215. QTCORE_LIBS = $(shell pkg-config --libs QtCore)
  216. QTXML_FLAGS = $(shell pkg-config --cflags QtXml)
  217. QTXML_LIBS = $(shell pkg-config --libs QtXml)
  218. endif
  219. ifeq ($(HAVE_CSOUND),true)
  220. CSOUND_FLAGS = -DUSE_DOUBLE=1
  221. CSOUND_LIBS = $(shell pkg-config --libs sndfile) -lcsound64
  222. endif
  223. ifeq ($(HAVE_FLUIDSYNTH),true)
  224. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  225. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  226. endif
  227. ifeq ($(HAVE_LINUXSAMPLER),true)
  228. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -Wno-unused-parameter
  229. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  230. endif
  231. ifeq ($(HAVE_WAYLAND),true)
  232. WAYLAND_FLAGS = $(shell pkg-config --cflags wayland-client)
  233. WAYLAND_LIBS = $(shell pkg-config --libs wayland-client)
  234. endif
  235. ifeq ($(HAVE_X11),true)
  236. X11_FLAGS = $(shell pkg-config --cflags x11)
  237. X11_LIBS = $(shell pkg-config --libs x11)
  238. endif
  239. # --------------------------------------------------------------
  240. # Set libs stuff (part 2)
  241. ifeq ($(HAVE_AF_DEPS),true)
  242. AUDIO_DECODER_FLAGS = $(shell pkg-config --cflags sndfile)
  243. AUDIO_DECODER_LIBS = $(shell pkg-config --libs sndfile)
  244. ifeq ($(HAVE_FFMPEG),true)
  245. AUDIO_DECODER_FLAGS += $(shell pkg-config --cflags libavcodec libavformat libavutil)
  246. AUDIO_DECODER_LIBS += $(shell pkg-config --libs libavcodec libavformat libavutil)
  247. endif
  248. endif
  249. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  250. ifeq ($(DEBUG),true)
  251. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  252. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  253. endif
  254. ifneq ($(HAIKU),true)
  255. RTMEMPOOL_LIBS = -lpthread
  256. endif
  257. ifeq ($(LINUX),true)
  258. ifeq ($(HAVE_DGL),true)
  259. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  260. DGL_LIBS = $(shell pkg-config --libs gl x11)
  261. endif
  262. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  263. ifeq ($(HAVE_JUCE),true)
  264. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  265. JUCE_EVENTS_FLAGS = $(shell pkg-config --cflags x11)
  266. JUCE_EVENTS_LIBS = $(shell pkg-config --libs x11)
  267. JUCE_GRAPHICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext freetype2)
  268. JUCE_GRAPHICS_LIBS = $(shell pkg-config --libs x11 xinerama xext freetype2)
  269. JUCE_GUI_BASICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext xcursor)
  270. JUCE_GUI_BASICS_LIBS = $(shell pkg-config --libs x11 xinerama xext xcursor) -ldl
  271. endif
  272. LILV_LIBS = -ldl -lm -lrt
  273. ifeq ($(HAVE_ALSA),true)
  274. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  275. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  276. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  277. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  278. endif
  279. ifeq ($(HAVE_PULSEAUDIO),true)
  280. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  281. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  282. endif
  283. endif
  284. ifeq ($(MACOS),true)
  285. DGL_LIBS = -framework OpenGL -framework Cocoa
  286. JACKBRIDGE_LIBS = -ldl -lpthread
  287. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  288. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  289. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  290. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  291. JUCE_CORE_LIBS = -framework AppKit
  292. JUCE_EVENTS_LIBS = -framework AppKit
  293. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  294. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  295. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  296. LILV_LIBS = -ldl -lm
  297. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  298. RTAUDIO_LIBS += -framework CoreAudio -framework CoreFoundation -lpthread
  299. RTMIDI_FLAGS += -D__MACOSX_CORE__
  300. RTMIDI_LIBS += -framework CoreAudio -framework CoreMIDI -framework CoreFoundation
  301. endif
  302. ifeq ($(WIN32),true)
  303. DGL_LIBS = -lopengl32 -lgdi32
  304. JACKBRIDGE_LIBS = -lpthread
  305. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  306. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  307. # JUCE_EVENTS_LIBS = -lole32
  308. JUCE_GRAPHICS_LIBS = -lgdi32
  309. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  310. LILV_LIBS = -lm
  311. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__
  312. RTAUDIO_LIBS += -ldsound -lpthread
  313. RTMIDI_FLAGS += -D__WINDOWS_MM__
  314. endif
  315. # --------------------------------------------------------------
  316. # Set libs stuff (part 3)
  317. ifeq ($(HAVE_DGL),true)
  318. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  319. endif
  320. ifeq ($(HAVE_AF_DEPS),true)
  321. NATIVE_PLUGINS_FLAGS += -DWANT_AUDIOFILE
  322. NATIVE_PLUGINS_LIBS += $(AUDIO_DECODER_LIBS)
  323. endif
  324. ifeq ($(HAVE_MF_DEPS),true)
  325. NATIVE_PLUGINS_FLAGS += -DWANT_MIDIFILE
  326. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs smf)
  327. endif
  328. ifeq ($(HAVE_PM_DEPS),true)
  329. NATIVE_PLUGINS_FLAGS += -DWANT_PROJECTM
  330. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs libprojectM)
  331. endif
  332. ifeq ($(HAVE_ZYN_DEPS),true)
  333. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX
  334. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  335. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  336. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX_UI
  337. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  338. endif
  339. endif
  340. # --------------------------------------------------------------
  341. # Set Qt tools
  342. ifeq ($(HAVE_QT4),true)
  343. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  344. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  345. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  346. endif
  347. ifeq ($(HAVE_QT5),true)
  348. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  349. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  350. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  351. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  352. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  353. else
  354. ifeq ($(MACOS),true)
  355. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  356. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  357. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  358. else
  359. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  360. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  361. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  362. endif
  363. endif
  364. endif
  365. # --------------------------------------------------------------