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.

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