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.

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