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.

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