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.

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