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.

439 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. # Use the free vestige header instead of the official VST SDK
  9. CARLA_VESTIGE_HEADER = true
  10. # Enable experimental plugins, don't complain if the build fails when using this!
  11. EXPERIMENTAL_PLUGINS = false
  12. # --------------------------------------------------------------
  13. # DO NOT MODIFY PAST THIS POINT!
  14. AR ?= ar
  15. CC ?= gcc
  16. CXX ?= g++
  17. # --------------------------------------------------------------
  18. # Fallback to Linux if no other OS defined
  19. ifneq ($(HAIKU),true)
  20. ifneq ($(MACOS),true)
  21. ifneq ($(WIN32),true)
  22. LINUX=true
  23. endif
  24. endif
  25. endif
  26. # --------------------------------------------------------------
  27. # Set MACOS_OR_WIN32
  28. ifeq ($(MACOS),true)
  29. MACOS_OR_WIN32=true
  30. endif
  31. ifeq ($(WIN32),true)
  32. MACOS_OR_WIN32=true
  33. endif
  34. # --------------------------------------------------------------
  35. # Set UNIX
  36. ifeq ($(LINUX),true)
  37. UNIX=true
  38. endif
  39. ifeq ($(MACOS),true)
  40. UNIX=true
  41. endif
  42. # --------------------------------------------------------------
  43. # Force some features on MacOS and Windows
  44. ifeq ($(MACOS_OR_WIN32),true)
  45. CARLA_VESTIGE_HEADER = false
  46. endif
  47. # --------------------------------------------------------------
  48. # Common build and link flags
  49. BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MMD
  50. BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -fdata-sections -ffunction-sections
  51. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections
  52. LINK_OPTS += -Wl,--strip-all
  53. ifneq ($(MACOS),true)
  54. # MacOS doesn't support this
  55. BASE_OPTS += -mfpmath=sse
  56. else
  57. # MacOS linker flags
  58. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  59. endif
  60. ifeq ($(RASPPI),true)
  61. # Raspberry-Pi optimization flags
  62. BASE_OPTS = -O2 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard
  63. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  64. endif
  65. ifeq ($(PANDORA),true)
  66. # OpenPandora flags
  67. BASE_OPTS = -O2 -ffast-math -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
  68. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  69. endif
  70. ifneq ($(WIN32),true)
  71. # not needed for Windows
  72. BASE_FLAGS += -fPIC -DPIC
  73. endif
  74. ifeq ($(DEBUG),true)
  75. BASE_FLAGS += -DDEBUG -O0 -g
  76. ifeq ($(WIN32),true)
  77. BASE_FLAGS += -msse -msse2
  78. endif
  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. # Strict test build
  96. ifeq ($(TESTBUILD),true)
  97. BASE_FLAGS += -Werror -Wabi -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-declarations
  98. BASE_FLAGS += -Woverlength-strings -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wundef -Wuninitialized -Wunused
  99. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  100. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  101. CFLAGS += -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings
  102. CXXFLAGS += -Wc++0x-compat -Wc++11-compat -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wzero-as-null-pointer-constant
  103. ifeq ($(LINUX),true)
  104. BASE_FLAGS += -isystem /opt/kxstudio/include
  105. CXXFLAGS += -isystem /opt/kxstudio/include/ntk
  106. CXXFLAGS += -isystem /usr/include/qt4
  107. endif
  108. ifeq ($(MACOS),true)
  109. BASE_FLAGS += -isystem /opt/kxstudio/include
  110. CXXFLAGS += -isystem /System/Library/Frameworks
  111. endif
  112. ifeq ($(WIN64),true)
  113. BASE_FLAGS += -isystem /opt/mingw64/include
  114. else
  115. ifeq ($(WIN32),true)
  116. BASE_FLAGS += -isystem /opt/mingw32/include
  117. endif
  118. endif
  119. endif
  120. # --------------------------------------------------------------
  121. # Check for optional libs (required by backend or bridges)
  122. ifeq ($(MACOS_OR_WIN32),true)
  123. HAVE_DGL = true
  124. else
  125. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  126. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  127. ifeq ($(LINUX),true)
  128. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  129. HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true)
  130. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  131. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  132. endif
  133. endif
  134. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  135. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  136. HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true)
  137. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  138. HAVE_LINUXSAMPLER = $(shell pkg-config --atleast-version=1.0.0.svn41 linuxsampler && echo true)
  139. HAVE_PROJECTM = $(shell pkg-config --exists libprojectM && echo true)
  140. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  141. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  142. ifeq ($(UNIX),true)
  143. # libmagic doesn't have a pkg-config file, so we need to call the compiler to test it
  144. HAVE_LIBMAGIC = $(shell echo '\#include <magic.h>' | $(CC) $(CFLAGS) -x c -w -c - -o .libmagic-tmp 2>/dev/null && echo true)
  145. endif
  146. # --------------------------------------------------------------
  147. # Set Qt tools
  148. ifeq ($(HAVE_QT4),true)
  149. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  150. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  151. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  152. ifeq (,$(wildcard $(MOC_QT4)))
  153. HAVE_QT4=false
  154. endif
  155. endif
  156. ifeq ($(HAVE_QT5),true)
  157. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  158. ifeq ($(MACOS),true)
  159. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  160. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  161. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  162. else # MACOS
  163. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  164. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  165. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  166. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  167. else
  168. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  169. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  170. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  171. endif
  172. endif # MACOS
  173. ifeq (,$(wildcard $(MOC_QT5)))
  174. HAVE_QT5=false
  175. endif
  176. endif
  177. ifeq ($(HAVE_QT4),true)
  178. HAVE_QT=true
  179. endif
  180. ifeq ($(HAVE_QT5),true)
  181. HAVE_QT=true
  182. endif
  183. ifeq ($(WIN32),true)
  184. HAVE_QT=true
  185. endif
  186. # --------------------------------------------------------------
  187. # Set PyQt tools
  188. PYUIC4 ?= /usr/bin/pyuic4
  189. PYUIC5 ?= /usr/bin/pyuic5
  190. ifneq (,$(wildcard $(PYUIC4)))
  191. HAVE_PYQT=true
  192. HAVE_PYQT4=true
  193. else
  194. HAVE_PYQT4=false
  195. endif
  196. ifneq (,$(wildcard $(PYUIC5)))
  197. HAVE_PYQT=true
  198. HAVE_PYQT5=true
  199. else
  200. HAVE_PYQT5=false
  201. endif
  202. # --------------------------------------------------------------
  203. # Set default Qt used in frontend
  204. ifeq ($(HAVE_PYQT4),true)
  205. DEFAULT_QT ?= 4
  206. else
  207. DEFAULT_QT ?= 5
  208. endif
  209. # --------------------------------------------------------------
  210. # Set base defines
  211. ifeq ($(HAVE_DGL),true)
  212. BASE_FLAGS += -DHAVE_DGL
  213. endif
  214. ifeq ($(HAVE_LIBLO),true)
  215. BASE_FLAGS += -DHAVE_LIBLO
  216. endif
  217. ifeq ($(HAVE_LIBMAGIC),true)
  218. BASE_FLAGS += -DHAVE_LIBMAGIC
  219. endif
  220. ifeq ($(HAVE_FLUIDSYNTH),true)
  221. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  222. endif
  223. ifeq ($(HAVE_LINUXSAMPLER),true)
  224. BASE_FLAGS += -DHAVE_LINUXSAMPLER
  225. endif
  226. ifeq ($(HAVE_PROJECTM),true)
  227. BASE_FLAGS += -DHAVE_PROJECTM
  228. endif
  229. ifeq ($(HAVE_X11),true)
  230. BASE_FLAGS += -DHAVE_X11
  231. endif
  232. ifeq ($(CARLA_VESTIGE_HEADER),true)
  233. BASE_FLAGS += -DVESTIGE_HEADER
  234. endif
  235. # --------------------------------------------------------------
  236. # Set libs stuff (part 1)
  237. ifeq ($(HAVE_LIBLO),true)
  238. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  239. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  240. endif
  241. ifeq ($(HAVE_FLUIDSYNTH),true)
  242. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  243. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  244. endif
  245. ifeq ($(HAVE_LINUXSAMPLER),true)
  246. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -DIS_CPP11=1 -Wno-non-virtual-dtor -Wno-shadow -Wno-unused-parameter
  247. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  248. endif
  249. ifeq ($(HAVE_PROJECTM),true)
  250. PROJECTM_FLAGS = $(shell pkg-config --cflags libprojectM)
  251. PROJECTM_LIBS = $(shell pkg-config --libs libprojectM)
  252. endif
  253. ifeq ($(HAVE_X11),true)
  254. X11_FLAGS = $(shell pkg-config --cflags x11)
  255. X11_LIBS = $(shell pkg-config --libs x11)
  256. endif
  257. # --------------------------------------------------------------
  258. # Set libs stuff (part 2)
  259. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  260. ifeq ($(DEBUG),true)
  261. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  262. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  263. endif
  264. ifneq ($(HAIKU),true)
  265. RTMEMPOOL_LIBS = -lpthread
  266. endif
  267. ifeq ($(LINUX),true)
  268. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  269. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  270. LILV_LIBS = -ldl -lm -lrt
  271. ifeq ($(HAVE_DGL),true)
  272. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  273. DGL_LIBS = $(shell pkg-config --libs gl x11)
  274. endif
  275. ifeq ($(HAVE_ALSA),true)
  276. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  277. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  278. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  279. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  280. endif
  281. ifeq ($(HAVE_PULSEAUDIO),true)
  282. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  283. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  284. endif
  285. endif
  286. ifeq ($(MACOS),true)
  287. DGL_LIBS = -framework OpenGL -framework Cocoa
  288. JACKBRIDGE_LIBS = -ldl -lpthread
  289. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  290. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  291. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  292. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  293. JUCE_CORE_LIBS = -framework AppKit
  294. JUCE_EVENTS_LIBS = -framework AppKit
  295. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  296. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  297. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  298. LILV_LIBS = -ldl -lm
  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. endif
  310. # --------------------------------------------------------------
  311. # Set libs stuff (part 3)
  312. ifeq ($(HAVE_DGL),true)
  313. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  314. ifeq ($(HAVE_PROJECTM),true)
  315. NATIVE_PLUGINS_LIBS += $(PROJECTM_LIBS)
  316. endif
  317. endif
  318. ifeq ($(EXPERIMENTAL_PLUGINS),true)
  319. NATIVE_PLUGINS_FLAGS += -DHAVE_EXPERIMENTAL_PLUGINS
  320. NATIVE_PLUGINS_LIBS += -lclxclient -lclthreads -lzita-convolver -lzita-resampler
  321. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs cairo fftw3f libpng12 x11 xft)
  322. endif
  323. ifeq ($(HAVE_ZYN_DEPS),true)
  324. NATIVE_PLUGINS_FLAGS += -DHAVE_ZYN_DEPS
  325. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  326. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  327. NATIVE_PLUGINS_FLAGS += -DHAVE_ZYN_UI_DEPS
  328. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  329. endif
  330. endif
  331. # --------------------------------------------------------------
  332. # Set app extension
  333. ifeq ($(WIN32),true)
  334. APP_EXT = .exe
  335. endif
  336. # --------------------------------------------------------------
  337. # Set shared lib extension
  338. LIB_EXT = .so
  339. ifeq ($(MACOS),true)
  340. LIB_EXT = .dylib
  341. endif
  342. ifeq ($(WIN32),true)
  343. LIB_EXT = .dll
  344. endif
  345. # --------------------------------------------------------------
  346. # Set static libs start & end
  347. ifneq ($(MACOS),true)
  348. LIBS_START = -Wl,--start-group
  349. LIBS_END = -Wl,--end-group
  350. endif
  351. # --------------------------------------------------------------
  352. # Set shared library CLI arg
  353. ifeq ($(MACOS),true)
  354. SHARED = -dynamiclib
  355. else
  356. SHARED = -shared
  357. endif
  358. # --------------------------------------------------------------