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.

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