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.

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