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.

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