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.

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