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.

464 lines
14KB

  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 GIG, SF2 and SFZ sample banks (through fluidsynth and linuxsampler)
  11. CARLA_SAMPLERS_SUPPORT = true
  12. # Use the free vestige header instead of the official VST SDK
  13. CARLA_VESTIGE_HEADER = true
  14. # --------------------------------------------------------------
  15. # DO NOT MODIFY PAST THIS POINT!
  16. AR ?= ar
  17. RM ?= rm -f
  18. CC ?= gcc
  19. CXX ?= g++
  20. # --------------------------------------------------------------
  21. # Fallback to Linux if no other OS defined
  22. ifneq ($(HAIKU),true)
  23. ifneq ($(MACOS),true)
  24. ifneq ($(WIN32),true)
  25. LINUX=true
  26. endif
  27. endif
  28. endif
  29. # --------------------------------------------------------------
  30. # Set MACOS_OR_WIN32
  31. ifeq ($(MACOS),true)
  32. MACOS_OR_WIN32=true
  33. endif
  34. ifeq ($(WIN32),true)
  35. MACOS_OR_WIN32=true
  36. endif
  37. # --------------------------------------------------------------
  38. # Force some features on MacOS and Windows
  39. ifeq ($(MACOS_OR_WIN32),true)
  40. CARLA_VESTIGE_HEADER = false
  41. endif
  42. # --------------------------------------------------------------
  43. # Common build and link flags
  44. BASE_FLAGS = -Wall -Wextra -pipe -DREAL_BUILD
  45. BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse -fdata-sections -ffunction-sections
  46. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections
  47. # -Wl,--strip-all
  48. ifeq ($(MACOS),true)
  49. # MacOS linker flags
  50. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  51. endif
  52. ifeq ($(RASPPI),true)
  53. # Raspberry-Pi optimization flags
  54. BASE_OPTS = -O2 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard
  55. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  56. endif
  57. ifeq ($(PANDORA),true)
  58. # OpenPandora flags
  59. BASE_OPTS = -O2 -ffast-math -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
  60. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  61. endif
  62. ifneq ($(WIN32),true)
  63. # not needed for Windows
  64. BASE_FLAGS += -fPIC -DPIC
  65. endif
  66. ifeq ($(DEBUG),true)
  67. BASE_FLAGS += -DDEBUG -O0 -g
  68. LINK_OPTS =
  69. else
  70. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  71. CXXFLAGS += -fvisibility-inlines-hidden
  72. endif
  73. 32BIT_FLAGS = -m32
  74. 64BIT_FLAGS = -m64
  75. BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -std=gnu99 $(CFLAGS)
  76. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x -std=gnu++0x $(CXXFLAGS)
  77. LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS)
  78. ifeq ($(MACOS),true)
  79. # No C++11 support
  80. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS)
  81. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  82. endif
  83. # --------------------------------------------------------------
  84. # Strict test build
  85. ifeq ($(TESTBUILD),true)
  86. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  87. ifneq ($(CC),clang)
  88. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  89. endif
  90. ifneq ($(MACOS),true)
  91. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  92. ifneq ($(CC),clang)
  93. BASE_FLAGS += -Wlogical-op
  94. endif
  95. endif
  96. CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  97. CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
  98. ifeq ($(LINUX),true)
  99. CFLAGS += -isystem /opt/kxstudio/include
  100. CXXFLAGS += -isystem /opt/kxstudio/include -isystem /usr/include/qt5
  101. endif
  102. ifeq ($(MACOS),true)
  103. CFLAGS += -isystem /opt/kxstudio/include
  104. CXXFLAGS += -isystem /opt/kxstudio/include -isystem /opt/kxstudio/include/qt5
  105. endif
  106. ifeq ($(WIN32),true)
  107. CFLAGS += -isystem /opt/mingw32/include
  108. CXXFLAGS += -isystem /opt/mingw32/include -isystem /opt/mingw32/include/qt4
  109. endif
  110. endif
  111. # --------------------------------------------------------------
  112. # Check for qt, set default version
  113. HAVE_QT4 = $(shell pkg-config --exists QtCore && echo true)
  114. HAVE_QT5 = $(shell pkg-config --exists Qt5Core && echo true)
  115. ifeq ($(MACOS_OR_WIN32),true)
  116. DEFAULT_QT ?= 5
  117. else
  118. DEFAULT_QT ?= 4
  119. endif
  120. # --------------------------------------------------------------
  121. # Set Qt tools
  122. # FIXME
  123. ifeq ($(HAVE_QT4),true)
  124. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  125. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  126. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  127. ifeq (,$(wildcard $(MOC_QT4)))
  128. HAVE_QT4=false
  129. endif
  130. endif
  131. ifeq ($(HAVE_QT5),true)
  132. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  133. ifeq ($(MACOS),true)
  134. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  135. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  136. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  137. else # MACOS
  138. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  139. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  140. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  141. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  142. else
  143. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  144. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  145. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  146. endif
  147. endif # MACOS
  148. ifeq (,$(wildcard $(MOC_QT5)))
  149. HAVE_QT5=false
  150. endif
  151. endif
  152. # --------------------------------------------------------------
  153. # Fail if prefered Qt is not found
  154. # FIXME
  155. ifeq ($(DEFAULT_QT),4)
  156. ifneq ($(HAVE_QT4),true)
  157. $(error Qt4 missing, cannot continue)
  158. endif
  159. else
  160. ifneq ($(HAVE_QT5),true)
  161. $(error Qt5 missing, cannot continue)
  162. endif
  163. endif
  164. # --------------------------------------------------------------
  165. # Check for required libs
  166. ifneq ($(shell pkg-config --exists liblo && echo true),true)
  167. $(error liblo missing, cannot continue)
  168. endif
  169. ifeq ($(LINUX),true)
  170. ifneq ($(shell pkg-config --exists x11 && echo true),true)
  171. $(error X11 missing, cannot continue)
  172. endif
  173. endif
  174. # --------------------------------------------------------------
  175. # Check for optional libs (required by backend or bridges)
  176. ifeq ($(MACOS_OR_WIN32),true)
  177. HAVE_DGL = true
  178. HAVE_JUCE_UI = true
  179. else
  180. HAVE_FFMPEG = $(shell pkg-config --exists libavcodec libavformat libavutil && echo true)
  181. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  182. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  183. HAVE_QTGUI4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  184. HAVE_QTGUI5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  185. ifeq ($(LINUX),true)
  186. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  187. HAVE_DGL = $(shell pkg-config --exists gl && echo true)
  188. HAVE_JUCE_UI = $(shell pkg-config --exists xinerama xext xcursor freetype2 TODO && echo true)
  189. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  190. HAVE_X11 = true
  191. endif
  192. endif
  193. ifeq ($(CARLA_SAMPLERS_SUPPORT),true)
  194. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  195. HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true)
  196. endif
  197. # --------------------------------------------------------------
  198. # Set Qt tools
  199. # TODO
  200. ifeq ($(HAVE_QTGUI4),true)
  201. ifeq (,$(wildcard $(MOC_QT4)))
  202. HAVE_QTGUI4=false
  203. endif
  204. endif
  205. ifeq ($(HAVE_QTGUI5),true)
  206. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  207. ifeq (,$(wildcard $(MOC_QT5)))
  208. HAVE_QTGUI5=false
  209. endif
  210. endif
  211. # --------------------------------------------------------------
  212. # Check for optional libs (required by internal plugins)
  213. HAVE_AF_DEPS = $(shell pkg-config --exists sndfile && echo true)
  214. HAVE_MF_DEPS = $(shell pkg-config --exists smf && echo true)
  215. HAVE_PM_DEPS = $(shell pkg-config --exists libprojectM && echo true)
  216. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  217. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  218. # --------------------------------------------------------------
  219. # Set base defines
  220. ifeq ($(HAVE_DGL),true)
  221. BASE_FLAGS += -DHAVE_DGL
  222. endif
  223. ifeq ($(HAVE_FFMPEG),true)
  224. BASE_FLAGS += -DHAVE_FFMPEG
  225. endif
  226. ifeq ($(HAVE_JUCE_UI),true)
  227. BASE_FLAGS += -DHAVE_JUCE_UI
  228. endif
  229. ifeq ($(HAVE_X11),true)
  230. BASE_FLAGS += -DHAVE_X11
  231. endif
  232. # --------------------------------------------------------------
  233. # Set libs stuff (part 1)
  234. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  235. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  236. ifeq ($(DEFAULT_QT),4)
  237. QTCORE_FLAGS = $(shell pkg-config --cflags QtCore)
  238. QTCORE_LIBS = $(shell pkg-config --libs QtCore)
  239. else
  240. QTCORE_FLAGS = $(shell pkg-config --cflags Qt5Core)
  241. QTCORE_LIBS = $(shell pkg-config --libs Qt5Core)
  242. endif
  243. ifeq ($(HAVE_FLUIDSYNTH),true)
  244. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  245. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  246. endif
  247. ifeq ($(HAVE_LINUXSAMPLER),true)
  248. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -Wno-unused-parameter
  249. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  250. endif
  251. ifeq ($(HAVE_X11),true)
  252. X11_FLAGS = $(shell pkg-config --cflags x11)
  253. X11_LIBS = $(shell pkg-config --libs x11)
  254. endif
  255. # --------------------------------------------------------------
  256. # Set libs stuff (part 2)
  257. ifeq ($(HAVE_AF_DEPS),true)
  258. AUDIO_DECODER_FLAGS = $(shell pkg-config --cflags sndfile)
  259. AUDIO_DECODER_LIBS = $(shell pkg-config --libs sndfile)
  260. ifeq ($(HAVE_FFMPEG),true)
  261. AUDIO_DECODER_FLAGS += $(shell pkg-config --cflags libavcodec libavformat libavutil)
  262. AUDIO_DECODER_LIBS += $(shell pkg-config --libs libavcodec libavformat libavutil)
  263. endif
  264. endif
  265. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  266. ifeq ($(DEBUG),true)
  267. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  268. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  269. endif
  270. ifneq ($(HAIKU),true)
  271. RTMEMPOOL_LIBS = -lpthread
  272. endif
  273. ifeq ($(LINUX),true)
  274. ifeq ($(HAVE_DGL),true)
  275. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  276. DGL_LIBS = $(shell pkg-config --libs gl x11)
  277. endif
  278. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  279. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  280. JUCE_EVENTS_FLAGS = $(shell pkg-config --cflags x11)
  281. JUCE_EVENTS_LIBS = $(shell pkg-config --libs x11)
  282. ifeq ($(HAVE_JUCE_UI),true)
  283. JUCE_GRAPHICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext freetype2)
  284. JUCE_GRAPHICS_LIBS = $(shell pkg-config --libs x11 xinerama xext freetype2)
  285. JUCE_GUI_BASICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext xcursor)
  286. JUCE_GUI_BASICS_LIBS = $(shell pkg-config --libs x11 xinerama xext xcursor)
  287. endif
  288. LILV_LIBS = -ldl -lm -lrt
  289. ifeq ($(HAVE_ALSA),true)
  290. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  291. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  292. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  293. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  294. endif
  295. ifeq ($(HAVE_PULSEAUDIO),true)
  296. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  297. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  298. endif
  299. endif
  300. ifeq ($(MACOS),true)
  301. DGL_LIBS = -framework OpenGL -framework Cocoa
  302. JACKBRIDGE_LIBS = -ldl -lpthread
  303. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  304. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  305. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  306. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  307. JUCE_CORE_LIBS = -framework AppKit
  308. JUCE_EVENTS_LIBS = -framework AppKit
  309. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  310. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  311. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  312. LILV_LIBS = -ldl -lm
  313. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  314. RTAUDIO_LIBS += -framework CoreAudio -framework CoreFoundation -lpthread
  315. RTMIDI_FLAGS += -D__MACOSX_CORE__
  316. RTMIDI_LIBS += -framework CoreAudio -framework CoreMIDI -framework CoreFoundation
  317. endif
  318. ifeq ($(WIN32),true)
  319. DGL_LIBS = -lopengl32 -lgdi32
  320. JACKBRIDGE_LIBS = -lpthread
  321. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  322. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  323. # JUCE_EVENTS_LIBS = -lole32
  324. JUCE_GRAPHICS_LIBS = -lgdi32
  325. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  326. LILV_LIBS = -lm
  327. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__
  328. RTAUDIO_LIBS += -ldsound -lpthread
  329. RTMIDI_FLAGS += -D__WINDOWS_MM__
  330. endif
  331. # --------------------------------------------------------------
  332. # Set libs stuff (part 3)
  333. ifeq ($(HAVE_DGL),true)
  334. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  335. endif
  336. ifeq ($(HAVE_AF_DEPS),true)
  337. NATIVE_PLUGINS_FLAGS += -DWANT_AUDIOFILE
  338. NATIVE_PLUGINS_LIBS += $(AUDIO_DECODER_LIBS)
  339. endif
  340. ifeq ($(HAVE_MF_DEPS),true)
  341. NATIVE_PLUGINS_FLAGS += -DWANT_MIDIFILE
  342. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs smf)
  343. endif
  344. ifeq ($(HAVE_PM_DEPS),true)
  345. NATIVE_PLUGINS_FLAGS += -DWANT_PROJECTM
  346. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs libprojectM)
  347. endif
  348. ifeq ($(HAVE_ZYN_DEPS),true)
  349. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX
  350. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  351. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  352. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX_UI
  353. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  354. endif
  355. endif
  356. # --------------------------------------------------------------
  357. # Set app extension
  358. ifeq ($(WIN32),true)
  359. APP_EXT = .exe
  360. endif
  361. # --------------------------------------------------------------
  362. # Set shared lib extension
  363. LIB_EXT = .so
  364. ifeq ($(MACOS),true)
  365. LIB_EXT = .dylib
  366. endif
  367. ifeq ($(WIN32),true)
  368. LIB_EXT = .dll
  369. endif
  370. # --------------------------------------------------------------
  371. # Set static libs start & end
  372. ifneq ($(MACOS),true)
  373. LIBS_START = -Wl,--start-group
  374. LIBS_END = -Wl,--end-group
  375. endif
  376. # --------------------------------------------------------------
  377. # Set shared library CLI arg
  378. ifeq ($(MACOS),true)
  379. SHARED = -dynamiclib
  380. else
  381. SHARED = -shared
  382. endif
  383. # --------------------------------------------------------------