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.

433 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_PM_DEPS = $(shell pkg-config --exists libprojectM && echo true)
  170. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  171. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  172. # --------------------------------------------------------------
  173. # Force some features on MacOS and Windows
  174. ifeq ($(MACOS),true)
  175. FORCE_FEATURES = true
  176. endif
  177. ifeq ($(WIN32),true)
  178. FORCE_FEATURES = true
  179. endif
  180. ifeq ($(FORCE_FEATURES),true)
  181. CARLA_VESTIGE_HEADER = false
  182. HAVE_WAYLAND = false
  183. HAVE_X11 = false
  184. endif
  185. # --------------------------------------------------------------
  186. # Set base defines
  187. ifeq ($(HAVE_DGL),true)
  188. BASE_FLAGS += -DHAVE_DGL
  189. endif
  190. ifeq ($(HAVE_FFMPEG),true)
  191. BASE_FLAGS += -DHAVE_FFMPEG
  192. endif
  193. ifeq ($(HAVE_JUCE),true)
  194. BASE_FLAGS += -DHAVE_JUCE
  195. endif
  196. ifeq ($(HAVE_WAYLAND),true)
  197. BASE_FLAGS += -DHAVE_WAYLAND
  198. endif
  199. ifeq ($(HAVE_X11),true)
  200. BASE_FLAGS += -DHAVE_X11
  201. endif
  202. # --------------------------------------------------------------
  203. # Set libs stuff (part 1)
  204. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  205. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  206. ifeq ($(DEFAULT_QT),5)
  207. QTCORE_FLAGS = $(shell pkg-config --cflags Qt5Core)
  208. QTCORE_LIBS = $(shell pkg-config --libs Qt5Core)
  209. QTXML_FLAGS = $(shell pkg-config --cflags Qt5Xml)
  210. QTXML_LIBS = $(shell pkg-config --libs Qt5Xml)
  211. else
  212. QTCORE_FLAGS = $(shell pkg-config --cflags QtCore)
  213. QTCORE_LIBS = $(shell pkg-config --libs QtCore)
  214. QTXML_FLAGS = $(shell pkg-config --cflags QtXml)
  215. QTXML_LIBS = $(shell pkg-config --libs QtXml)
  216. endif
  217. ifeq ($(HAVE_CSOUND),true)
  218. CSOUND_FLAGS = -DUSE_DOUBLE=1
  219. CSOUND_LIBS = $(shell pkg-config --libs sndfile) -lcsound64
  220. endif
  221. ifeq ($(HAVE_FLUIDSYNTH),true)
  222. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  223. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  224. endif
  225. ifeq ($(HAVE_LINUXSAMPLER),true)
  226. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -Wno-unused-parameter
  227. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  228. endif
  229. ifeq ($(HAVE_WAYLAND),true)
  230. WAYLAND_FLAGS = $(shell pkg-config --cflags wayland-client)
  231. WAYLAND_LIBS = $(shell pkg-config --libs wayland-client)
  232. endif
  233. ifeq ($(HAVE_X11),true)
  234. X11_FLAGS = $(shell pkg-config --cflags x11)
  235. X11_LIBS = $(shell pkg-config --libs x11)
  236. endif
  237. # --------------------------------------------------------------
  238. # Set libs stuff (part 2)
  239. ifeq ($(HAVE_AF_DEPS),true)
  240. AUDIO_DECODER_FLAGS = $(shell pkg-config --cflags sndfile)
  241. AUDIO_DECODER_LIBS = $(shell pkg-config --libs sndfile)
  242. ifeq ($(HAVE_FFMPEG),true)
  243. AUDIO_DECODER_FLAGS += $(shell pkg-config --cflags libavcodec libavformat libavutil)
  244. AUDIO_DECODER_LIBS += $(shell pkg-config --libs libavcodec libavformat libavutil)
  245. endif
  246. endif
  247. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  248. ifeq ($(DEBUG),true)
  249. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  250. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  251. endif
  252. ifneq ($(HAIKU),true)
  253. RTMEMPOOL_LIBS = -lpthread
  254. endif
  255. ifeq ($(LINUX),true)
  256. ifeq ($(HAVE_DGL),true)
  257. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  258. DGL_LIBS = $(shell pkg-config --libs gl x11)
  259. endif
  260. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  261. ifeq ($(HAVE_JUCE),true)
  262. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  263. JUCE_EVENTS_FLAGS = $(shell pkg-config --cflags x11)
  264. JUCE_EVENTS_LIBS = $(shell pkg-config --libs x11)
  265. JUCE_GRAPHICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext freetype2)
  266. JUCE_GRAPHICS_LIBS = $(shell pkg-config --libs x11 xinerama xext freetype2)
  267. JUCE_GUI_BASICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext xcursor)
  268. JUCE_GUI_BASICS_LIBS = $(shell pkg-config --libs x11 xinerama xext xcursor) -ldl
  269. endif
  270. LILV_LIBS = -ldl -lm -lrt
  271. ifeq ($(HAVE_ALSA),true)
  272. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  273. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  274. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  275. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  276. endif
  277. ifeq ($(HAVE_PULSEAUDIO),true)
  278. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  279. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  280. endif
  281. endif
  282. ifeq ($(MACOS),true)
  283. DGL_LIBS = -framework OpenGL -framework Cocoa
  284. JACKBRIDGE_LIBS = -ldl -lpthread
  285. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  286. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  287. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  288. JUCE_AUDIO_PROCESSORS_LIBS = -framework Cocoa -framework Carbon
  289. JUCE_CORE_LIBS = -framework AppKit
  290. JUCE_EVENTS_LIBS = -framework AppKit
  291. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  292. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  293. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  294. LILV_LIBS = -ldl -lm
  295. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  296. RTAUDIO_LIBS += -framework CoreAudio -framework CoreFoundation -lpthread
  297. RTMIDI_FLAGS += -D__MACOSX_CORE__
  298. RTMIDI_LIBS += -framework CoreAudio -framework CoreMIDI -framework CoreFoundation
  299. endif
  300. ifeq ($(WIN32),true)
  301. DGL_LIBS = -lopengl32 -lgdi32
  302. JACKBRIDGE_LIBS = -lpthread
  303. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  304. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  305. # JUCE_EVENTS_LIBS = -lole32
  306. JUCE_GRAPHICS_LIBS = -lgdi32
  307. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  308. LILV_LIBS = -lm
  309. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__
  310. RTAUDIO_LIBS += -ldsound -lpthread
  311. RTMIDI_FLAGS += -D__WINDOWS_MM__
  312. endif
  313. # --------------------------------------------------------------
  314. # Set libs stuff (part 3)
  315. NATIVE_PLUGINS_LIBS = $(AUDIO_DECODER_LIBS)
  316. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  317. ifeq ($(HAVE_MF_DEPS),true)
  318. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs smf)
  319. endif
  320. ifeq ($(HAVE_PM_DEPS),true)
  321. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs libprojectM)
  322. endif
  323. ifeq ($(HAVE_ZYN_DEPS),true)
  324. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  325. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  326. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  327. endif
  328. endif
  329. # --------------------------------------------------------------
  330. # Set Qt tools
  331. ifeq ($(HAVE_QT4),true)
  332. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  333. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  334. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  335. endif
  336. ifeq ($(HAVE_QT5),true)
  337. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  338. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  339. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  340. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  341. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  342. else
  343. ifeq ($(MACOS),true)
  344. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  345. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  346. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  347. else
  348. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  349. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  350. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  351. endif
  352. endif
  353. endif
  354. # --------------------------------------------------------------