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.

415 lines
12KB

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