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.

414 lines
11KB

  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. # --------------------------------------------------------------
  11. # DO NOT MODIFY PAST THIS POINT!
  12. AR ?= ar
  13. CC ?= gcc
  14. CXX ?= g++
  15. # --------------------------------------------------------------
  16. # Fallback to Linux if no other OS defined
  17. ifneq ($(HAIKU),true)
  18. ifneq ($(MACOS),true)
  19. ifneq ($(WIN32),true)
  20. LINUX=true
  21. endif
  22. endif
  23. endif
  24. # --------------------------------------------------------------
  25. # Set MACOS_OR_WIN32
  26. ifeq ($(MACOS),true)
  27. MACOS_OR_WIN32=true
  28. endif
  29. ifeq ($(WIN32),true)
  30. MACOS_OR_WIN32=true
  31. endif
  32. # --------------------------------------------------------------
  33. # Set UNIX
  34. ifeq ($(LINUX),true)
  35. UNIX=true
  36. endif
  37. ifeq ($(MACOS),true)
  38. UNIX=true
  39. endif
  40. # --------------------------------------------------------------
  41. # Force some features on MacOS and Windows
  42. ifeq ($(MACOS_OR_WIN32),true)
  43. CARLA_VESTIGE_HEADER = false
  44. endif
  45. # --------------------------------------------------------------
  46. # Common build and link flags
  47. BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MMD
  48. BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -fdata-sections -ffunction-sections
  49. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections
  50. LINK_OPTS += -Wl,--strip-all
  51. ifneq ($(MACOS),true)
  52. # MacOS doesn't support this
  53. BASE_OPTS += -mfpmath=sse
  54. else
  55. # MacOS linker flags
  56. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  57. endif
  58. ifeq ($(RASPPI),true)
  59. # Raspberry-Pi optimization flags
  60. BASE_OPTS = -O2 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard
  61. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  62. endif
  63. ifeq ($(PANDORA),true)
  64. # OpenPandora flags
  65. BASE_OPTS = -O2 -ffast-math -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
  66. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  67. endif
  68. ifneq ($(WIN32),true)
  69. # not needed for Windows
  70. BASE_FLAGS += -fPIC -DPIC
  71. endif
  72. ifeq ($(DEBUG),true)
  73. BASE_FLAGS += -DDEBUG -O0 -g
  74. ifeq ($(WIN32),true)
  75. BASE_FLAGS += -msse -msse2
  76. endif
  77. LINK_OPTS =
  78. else
  79. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  80. CXXFLAGS += -fvisibility-inlines-hidden
  81. endif
  82. 32BIT_FLAGS = -m32
  83. 64BIT_FLAGS = -m64
  84. BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -std=gnu99 $(CFLAGS)
  85. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x -std=gnu++0x $(CXXFLAGS)
  86. LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS)
  87. ifeq ($(MACOS),true)
  88. # No C++11 support
  89. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS)
  90. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  91. endif
  92. # --------------------------------------------------------------
  93. # Strict test build
  94. ifeq ($(TESTBUILD),true)
  95. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  96. BASE_FLAGS += -Wfloat-equal -Wpointer-arith -Wabi -Winit-self -Wuninitialized -Wunused-parameter #-Wstrict-overflow=5
  97. ifeq ($(CC),clang)
  98. # BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
  99. # BASE_FLAGS += -Weverything
  100. else
  101. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  102. endif
  103. ifneq ($(MACOS),true)
  104. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  105. ifneq ($(CC),clang)
  106. BASE_FLAGS += -Wlogical-op
  107. endif
  108. endif
  109. CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  110. CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
  111. ifeq ($(LINUX),true)
  112. CFLAGS += -isystem /opt/kxstudio/include
  113. CXXFLAGS += -isystem /opt/kxstudio/include
  114. CXXFLAGS += -isystem /opt/kxstudio/include/ntk
  115. CXXFLAGS += -isystem /opt/kxstudio-trusty/include/ntk
  116. CXXFLAGS += -isystem /usr/include/qt4
  117. endif
  118. ifeq ($(MACOS),true)
  119. CFLAGS += -isystem /opt/kxstudio/include
  120. CXXFLAGS += -isystem /opt/kxstudio/include
  121. CXXFLAGS += -isystem /System/Library/Frameworks
  122. endif
  123. ifeq ($(WIN64),true)
  124. CFLAGS += -isystem /opt/mingw64/include
  125. CXXFLAGS += -isystem /opt/mingw64/include
  126. else
  127. ifeq ($(WIN32),true)
  128. CFLAGS += -isystem /opt/mingw32/include
  129. CXXFLAGS += -isystem /opt/mingw32/include
  130. endif
  131. endif
  132. endif
  133. # --------------------------------------------------------------
  134. # Check for required libs
  135. ifneq ($(shell pkg-config --exists liblo && echo true),true)
  136. $(error liblo missing, cannot continue)
  137. endif
  138. ifeq ($(LINUX),true)
  139. ifeq (,$(wildcard /usr/include/magic.h))
  140. $(error libmagic missing, cannot continue)
  141. endif
  142. endif
  143. # --------------------------------------------------------------
  144. # Check for optional libs (required by backend or bridges)
  145. ifneq ($(MACOS_OR_WIN32),true)
  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_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  151. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  152. endif
  153. endif
  154. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  155. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  156. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  157. HAVE_LINUXSAMPLER = $(shell pkg-config --atleast-version=1.0.0.svn41 linuxsampler && echo true)
  158. # --------------------------------------------------------------
  159. # Set Qt tools
  160. ifeq ($(HAVE_QT4),true)
  161. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  162. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  163. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  164. ifeq (,$(wildcard $(MOC_QT4)))
  165. HAVE_QT4=false
  166. endif
  167. endif
  168. ifeq ($(HAVE_QT5),true)
  169. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  170. ifeq ($(MACOS),true)
  171. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  172. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  173. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  174. else # MACOS
  175. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  176. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  177. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  178. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  179. else
  180. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  181. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  182. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  183. endif
  184. endif # MACOS
  185. ifeq (,$(wildcard $(MOC_QT5)))
  186. HAVE_QT5=false
  187. endif
  188. endif
  189. ifeq ($(HAVE_QT4),true)
  190. HAVE_QT=true
  191. endif
  192. ifeq ($(HAVE_QT5),true)
  193. HAVE_QT=true
  194. endif
  195. ifeq ($(WIN32),true)
  196. HAVE_QT=true
  197. endif
  198. # --------------------------------------------------------------
  199. # Set PyQt tools
  200. PYUIC4 ?= /usr/bin/pyuic4
  201. PYUIC5 ?= /usr/bin/pyuic5
  202. ifneq (,$(wildcard $(PYUIC4)))
  203. HAVE_PYQT=true
  204. HAVE_PYQT4=true
  205. else
  206. HAVE_PYQT4=false
  207. endif
  208. ifneq (,$(wildcard $(PYUIC5)))
  209. HAVE_PYQT=true
  210. HAVE_PYQT5=true
  211. else
  212. HAVE_PYQT5=false
  213. endif
  214. # --------------------------------------------------------------
  215. # Set default Qt used in frontend
  216. ifeq ($(HAVE_PYQT4),true)
  217. DEFAULT_QT ?= 4
  218. else
  219. DEFAULT_QT ?= 5
  220. endif
  221. # --------------------------------------------------------------
  222. # Check for optional libs (required by internal plugins)
  223. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  224. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  225. # --------------------------------------------------------------
  226. # Set base defines
  227. ifeq ($(HAVE_FLUIDSYNTH),true)
  228. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  229. endif
  230. ifeq ($(HAVE_LINUXSAMPLER),true)
  231. BASE_FLAGS += -DHAVE_LINUXSAMPLER
  232. endif
  233. ifeq ($(HAVE_X11),true)
  234. BASE_FLAGS += -DHAVE_X11
  235. endif
  236. ifeq ($(CARLA_VESTIGE_HEADER),true)
  237. BASE_FLAGS += -DVESTIGE_HEADER
  238. endif
  239. # --------------------------------------------------------------
  240. # Set libs stuff (part 1)
  241. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  242. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  243. ifeq ($(HAVE_FLUIDSYNTH),true)
  244. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  245. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  246. endif
  247. ifeq ($(HAVE_LINUXSAMPLER),true)
  248. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -DIS_CPP11=1 -Wno-non-virtual-dtor -Wno-shadow -Wno-unused-parameter
  249. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  250. endif
  251. ifeq ($(HAVE_X11),true)
  252. X11_FLAGS = $(shell pkg-config --cflags x11)
  253. X11_LIBS = $(shell pkg-config --libs x11)
  254. endif
  255. # --------------------------------------------------------------
  256. # Set libs stuff (part 2)
  257. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  258. ifeq ($(DEBUG),true)
  259. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  260. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  261. endif
  262. ifneq ($(HAIKU),true)
  263. RTMEMPOOL_LIBS = -lpthread
  264. endif
  265. ifeq ($(LINUX),true)
  266. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  267. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  268. LILV_LIBS = -ldl -lm -lrt
  269. ifeq ($(HAVE_ALSA),true)
  270. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  271. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  272. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  273. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  274. endif
  275. ifeq ($(HAVE_PULSEAUDIO),true)
  276. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  277. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  278. endif
  279. endif
  280. ifeq ($(MACOS),true)
  281. JACKBRIDGE_LIBS = -ldl -lpthread
  282. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  283. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  284. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  285. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  286. JUCE_CORE_LIBS = -framework AppKit
  287. JUCE_EVENTS_LIBS = -framework AppKit
  288. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  289. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  290. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  291. LILV_LIBS = -ldl -lm
  292. endif
  293. ifeq ($(WIN32),true)
  294. JACKBRIDGE_LIBS = -lpthread
  295. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  296. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  297. # JUCE_EVENTS_LIBS = -lole32
  298. JUCE_GRAPHICS_LIBS = -lgdi32
  299. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  300. LILV_LIBS = -lm
  301. endif
  302. # --------------------------------------------------------------
  303. # Set libs stuff (part 3)
  304. ifeq ($(HAVE_ZYN_DEPS),true)
  305. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX
  306. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  307. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  308. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX_UI
  309. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  310. endif
  311. endif
  312. # --------------------------------------------------------------
  313. # Set app extension
  314. ifeq ($(WIN32),true)
  315. APP_EXT = .exe
  316. endif
  317. # --------------------------------------------------------------
  318. # Set shared lib extension
  319. LIB_EXT = .so
  320. ifeq ($(MACOS),true)
  321. LIB_EXT = .dylib
  322. endif
  323. ifeq ($(WIN32),true)
  324. LIB_EXT = .dll
  325. endif
  326. # --------------------------------------------------------------
  327. # Set static libs start & end
  328. ifneq ($(MACOS),true)
  329. LIBS_START = -Wl,--start-group
  330. LIBS_END = -Wl,--end-group
  331. endif
  332. # --------------------------------------------------------------
  333. # Set shared library CLI arg
  334. ifeq ($(MACOS),true)
  335. SHARED = -dynamiclib
  336. else
  337. SHARED = -shared
  338. endif
  339. # --------------------------------------------------------------