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.

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