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.

495 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. HAVE_QTGUI4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  194. HAVE_QTGUI5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  195. HAVE_WAYLAND = $(shell pkg-config --exists wayland-client && echo true)
  196. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  197. endif
  198. ifeq ($(LINUX),true)
  199. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  200. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  201. endif
  202. ifeq ($(CARLA_CSOUND_SUPPORT),true)
  203. ifeq ($(HAVE_JUCE),true)
  204. HAVE_CSOUND = $(shell pkg-config --exists sndfile && echo true)
  205. endif
  206. endif
  207. ifeq ($(CARLA_SAMPLERS_SUPPORT),true)
  208. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  209. HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true)
  210. endif
  211. # --------------------------------------------------------------
  212. # Check for optional libs (required by internal plugins)
  213. HAVE_AF_DEPS = $(shell pkg-config --exists sndfile && echo true)
  214. HAVE_MF_DEPS = $(shell pkg-config --exists smf && echo true)
  215. HAVE_PM_DEPS = $(shell pkg-config --exists libprojectM && echo true)
  216. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  217. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  218. # --------------------------------------------------------------
  219. # Force some features on MacOS and Windows
  220. ifeq ($(MACOS_OR_WIN32),true)
  221. CARLA_VESTIGE_HEADER = false
  222. endif
  223. # --------------------------------------------------------------
  224. # Set base defines
  225. ifeq ($(HAVE_DGL),true)
  226. BASE_FLAGS += -DHAVE_DGL
  227. endif
  228. ifeq ($(HAVE_FFMPEG),true)
  229. BASE_FLAGS += -DHAVE_FFMPEG
  230. endif
  231. ifeq ($(HAVE_JUCE),true)
  232. BASE_FLAGS += -DHAVE_JUCE
  233. endif
  234. ifeq ($(HAVE_WAYLAND),true)
  235. BASE_FLAGS += -DHAVE_WAYLAND
  236. endif
  237. ifeq ($(HAVE_X11),true)
  238. BASE_FLAGS += -DHAVE_X11
  239. endif
  240. # --------------------------------------------------------------
  241. # Set libs stuff (part 1)
  242. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  243. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  244. ifeq ($(DEFAULT_QT),4)
  245. QTCORE_FLAGS = $(shell pkg-config --cflags QtCore)
  246. QTCORE_LIBS = $(shell pkg-config --libs QtCore)
  247. QTXML_FLAGS = $(shell pkg-config --cflags QtXml)
  248. QTXML_LIBS = $(shell pkg-config --libs QtXml)
  249. else
  250. QTCORE_FLAGS = $(shell pkg-config --cflags Qt5Core)
  251. QTCORE_LIBS = $(shell pkg-config --libs Qt5Core)
  252. QTXML_FLAGS = $(shell pkg-config --cflags Qt5Xml)
  253. QTXML_LIBS = $(shell pkg-config --libs Qt5Xml)
  254. endif
  255. ifeq ($(HAVE_CSOUND),true)
  256. CSOUND_FLAGS = -DUSE_DOUBLE=1
  257. CSOUND_LIBS = $(shell pkg-config --libs sndfile) -lcsound64
  258. endif
  259. ifeq ($(HAVE_FLUIDSYNTH),true)
  260. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  261. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  262. endif
  263. ifeq ($(HAVE_LINUXSAMPLER),true)
  264. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -Wno-unused-parameter
  265. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  266. endif
  267. ifeq ($(HAVE_WAYLAND),true)
  268. WAYLAND_FLAGS = $(shell pkg-config --cflags wayland-client)
  269. WAYLAND_LIBS = $(shell pkg-config --libs wayland-client)
  270. endif
  271. ifeq ($(HAVE_X11),true)
  272. X11_FLAGS = $(shell pkg-config --cflags x11)
  273. X11_LIBS = $(shell pkg-config --libs x11)
  274. endif
  275. # --------------------------------------------------------------
  276. # Set libs stuff (part 2)
  277. ifeq ($(HAVE_AF_DEPS),true)
  278. AUDIO_DECODER_FLAGS = $(shell pkg-config --cflags sndfile)
  279. AUDIO_DECODER_LIBS = $(shell pkg-config --libs sndfile)
  280. ifeq ($(HAVE_FFMPEG),true)
  281. AUDIO_DECODER_FLAGS += $(shell pkg-config --cflags libavcodec libavformat libavutil)
  282. AUDIO_DECODER_LIBS += $(shell pkg-config --libs libavcodec libavformat libavutil)
  283. endif
  284. endif
  285. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  286. ifeq ($(DEBUG),true)
  287. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  288. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  289. endif
  290. ifneq ($(HAIKU),true)
  291. RTMEMPOOL_LIBS = -lpthread
  292. endif
  293. ifeq ($(LINUX),true)
  294. ifeq ($(HAVE_DGL),true)
  295. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  296. DGL_LIBS = $(shell pkg-config --libs gl x11)
  297. endif
  298. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  299. ifeq ($(HAVE_JUCE),true)
  300. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  301. JUCE_EVENTS_FLAGS = $(shell pkg-config --cflags x11)
  302. JUCE_EVENTS_LIBS = $(shell pkg-config --libs x11)
  303. JUCE_GRAPHICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext freetype2)
  304. JUCE_GRAPHICS_LIBS = $(shell pkg-config --libs x11 xinerama xext freetype2)
  305. JUCE_GUI_BASICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext xcursor)
  306. JUCE_GUI_BASICS_LIBS = $(shell pkg-config --libs x11 xinerama xext xcursor)
  307. endif
  308. LILV_LIBS = -ldl -lm -lrt
  309. ifeq ($(HAVE_ALSA),true)
  310. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  311. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  312. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  313. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  314. endif
  315. ifeq ($(HAVE_PULSEAUDIO),true)
  316. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  317. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  318. endif
  319. endif
  320. ifeq ($(MACOS),true)
  321. DGL_LIBS = -framework OpenGL -framework Cocoa
  322. JACKBRIDGE_LIBS = -ldl -lpthread
  323. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  324. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  325. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  326. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  327. JUCE_CORE_LIBS = -framework AppKit
  328. JUCE_EVENTS_LIBS = -framework AppKit
  329. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  330. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  331. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  332. LILV_LIBS = -ldl -lm
  333. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  334. RTAUDIO_LIBS += -framework CoreAudio -framework CoreFoundation -lpthread
  335. RTMIDI_FLAGS += -D__MACOSX_CORE__
  336. RTMIDI_LIBS += -framework CoreAudio -framework CoreMIDI -framework CoreFoundation
  337. endif
  338. ifeq ($(WIN32),true)
  339. DGL_LIBS = -lopengl32 -lgdi32
  340. JACKBRIDGE_LIBS = -lpthread
  341. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  342. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  343. # JUCE_EVENTS_LIBS = -lole32
  344. JUCE_GRAPHICS_LIBS = -lgdi32
  345. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  346. LILV_LIBS = -lm
  347. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__
  348. RTAUDIO_LIBS += -ldsound -lpthread
  349. RTMIDI_FLAGS += -D__WINDOWS_MM__
  350. endif
  351. # --------------------------------------------------------------
  352. # Set libs stuff (part 3)
  353. ifeq ($(HAVE_DGL),true)
  354. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  355. endif
  356. ifeq ($(HAVE_AF_DEPS),true)
  357. NATIVE_PLUGINS_FLAGS += -DWANT_AUDIOFILE
  358. NATIVE_PLUGINS_LIBS += $(AUDIO_DECODER_LIBS)
  359. endif
  360. ifeq ($(HAVE_MF_DEPS),true)
  361. NATIVE_PLUGINS_FLAGS += -DWANT_MIDIFILE
  362. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs smf)
  363. endif
  364. ifeq ($(HAVE_PM_DEPS),true)
  365. NATIVE_PLUGINS_FLAGS += -DWANT_PROJECTM
  366. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs libprojectM)
  367. endif
  368. ifeq ($(HAVE_ZYN_DEPS),true)
  369. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX
  370. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  371. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  372. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX_UI
  373. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  374. endif
  375. endif
  376. # --------------------------------------------------------------
  377. # Set app extension
  378. ifeq ($(WIN32),true)
  379. APP_EXT = .exe
  380. endif
  381. # --------------------------------------------------------------
  382. # Set shared lib extension
  383. LIB_EXT = .so
  384. ifeq ($(MACOS),true)
  385. LIB_EXT = .dylib
  386. endif
  387. ifeq ($(WIN32),true)
  388. LIB_EXT = .dll
  389. endif
  390. # --------------------------------------------------------------
  391. # Set static libs start & end
  392. ifneq ($(MACOS),true)
  393. LIBS_START = -Wl,--start-group
  394. LIBS_END = -Wl,--end-group
  395. endif
  396. # --------------------------------------------------------------
  397. # Set shared library CLI arg
  398. ifeq ($(MACOS),true)
  399. SHARED = -dynamiclib
  400. else
  401. SHARED = -shared
  402. endif
  403. # --------------------------------------------------------------