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.

365 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. LINK_OPTS =
  68. else
  69. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  70. CXXFLAGS += -fvisibility-inlines-hidden
  71. endif
  72. 32BIT_FLAGS = -m32
  73. 64BIT_FLAGS = -m64
  74. BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -std=gnu99 $(CFLAGS)
  75. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x -std=gnu++0x $(CXXFLAGS)
  76. LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS)
  77. ifeq ($(MACOS),true)
  78. # No C++11 support
  79. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS)
  80. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  81. endif
  82. # --------------------------------------------------------------
  83. # Strict test build
  84. ifeq ($(TESTBUILD),true)
  85. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  86. BASE_FLAGS += -Wfloat-equal -Wpointer-arith -Wabi -Winit-self -Wuninitialized #-Wstrict-overflow=5
  87. ifeq ($(CC),clang)
  88. # BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
  89. # BASE_FLAGS += -Weverything
  90. else
  91. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  92. endif
  93. ifneq ($(MACOS),true)
  94. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  95. ifneq ($(CC),clang)
  96. BASE_FLAGS += -Wlogical-op
  97. endif
  98. endif
  99. CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  100. CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
  101. ifeq ($(LINUX),true)
  102. CFLAGS += -isystem /opt/kxstudio/include
  103. CXXFLAGS += -isystem /opt/kxstudio/include
  104. CXXFLAGS += -isystem /opt/kxstudio/include/ntk
  105. CXXFLAGS += -isystem /usr/include/qt4
  106. endif
  107. ifeq ($(MACOS),true)
  108. CFLAGS += -isystem /opt/kxstudio/include
  109. CXXFLAGS += -isystem /opt/kxstudio/include
  110. endif
  111. ifeq ($(WIN32),true)
  112. CFLAGS += -isystem /opt/mingw32/include
  113. CXXFLAGS += -isystem /opt/mingw32/include
  114. endif
  115. endif
  116. # --------------------------------------------------------------
  117. # Check for required libs
  118. ifneq ($(shell pkg-config --exists liblo && echo true),true)
  119. $(error liblo missing, cannot continue)
  120. endif
  121. ifeq ($(LINUX),true)
  122. ifeq (,$(wildcard /usr/include/magic.h))
  123. $(error libmagic missing, cannot continue)
  124. endif
  125. endif
  126. # --------------------------------------------------------------
  127. # Check for optional libs (required by backend or bridges)
  128. ifneq ($(MACOS_OR_WIN32),true)
  129. HAVE_FFMPEG = $(shell pkg-config --exists libavcodec libavformat libavutil && echo true)
  130. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  131. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  132. ifeq ($(LINUX),true)
  133. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  134. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  135. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  136. endif
  137. endif
  138. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  139. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  140. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  141. HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true)
  142. # --------------------------------------------------------------
  143. # Set Qt tools
  144. ifeq ($(HAVE_QT4),true)
  145. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  146. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  147. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  148. ifeq (,$(wildcard $(MOC_QT4)))
  149. HAVE_QT4=false
  150. endif
  151. endif
  152. ifeq ($(HAVE_QT5),true)
  153. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  154. ifeq ($(MACOS),true)
  155. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  156. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  157. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  158. else # MACOS
  159. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  160. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  161. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  162. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  163. else
  164. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  165. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  166. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  167. endif
  168. endif # MACOS
  169. ifeq (,$(wildcard $(MOC_QT5)))
  170. HAVE_QT5=false
  171. endif
  172. endif
  173. # --------------------------------------------------------------
  174. # Set default Qt used in frontend
  175. ifeq ($(HAVE_QT4),true)
  176. DEFAULT_QT ?= 4
  177. else
  178. DEFAULT_QT ?= 5
  179. endif
  180. # --------------------------------------------------------------
  181. # Check for optional libs (required by internal plugins)
  182. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  183. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  184. # --------------------------------------------------------------
  185. # Set base defines
  186. ifeq ($(HAVE_FLUIDSYNTH),true)
  187. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  188. endif
  189. ifeq ($(HAVE_LINUXSAMPLER),true)
  190. BASE_FLAGS += -DHAVE_LINUXSAMPLER
  191. endif
  192. ifeq ($(HAVE_X11),true)
  193. BASE_FLAGS += -DHAVE_X11
  194. endif
  195. ifeq ($(CARLA_VESTIGE_HEADER),true)
  196. BASE_FLAGS += -DVESTIGE_HEADER
  197. endif
  198. # --------------------------------------------------------------
  199. # Set libs stuff (part 1)
  200. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  201. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  202. ifeq ($(HAVE_FLUIDSYNTH),true)
  203. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  204. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  205. endif
  206. ifeq ($(HAVE_LINUXSAMPLER),true)
  207. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -Wno-unused-parameter
  208. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  209. endif
  210. ifeq ($(HAVE_X11),true)
  211. X11_FLAGS = $(shell pkg-config --cflags x11)
  212. X11_LIBS = $(shell pkg-config --libs x11)
  213. endif
  214. # --------------------------------------------------------------
  215. # Set libs stuff (part 2)
  216. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  217. ifeq ($(DEBUG),true)
  218. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  219. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  220. endif
  221. ifneq ($(HAIKU),true)
  222. RTMEMPOOL_LIBS = -lpthread
  223. endif
  224. ifeq ($(LINUX),true)
  225. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  226. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  227. LILV_LIBS = -ldl -lm -lrt
  228. ifeq ($(HAVE_ALSA),true)
  229. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  230. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  231. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  232. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  233. endif
  234. ifeq ($(HAVE_PULSEAUDIO),true)
  235. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  236. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  237. endif
  238. endif
  239. ifeq ($(MACOS),true)
  240. JACKBRIDGE_LIBS = -ldl -lpthread
  241. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  242. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  243. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  244. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  245. JUCE_CORE_LIBS = -framework AppKit
  246. JUCE_EVENTS_LIBS = -framework AppKit
  247. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  248. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  249. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  250. LILV_LIBS = -ldl -lm
  251. endif
  252. ifeq ($(WIN32),true)
  253. JACKBRIDGE_LIBS = -lpthread
  254. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  255. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  256. # JUCE_EVENTS_LIBS = -lole32
  257. JUCE_GRAPHICS_LIBS = -lgdi32
  258. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  259. LILV_LIBS = -lm
  260. endif
  261. # --------------------------------------------------------------
  262. # Set libs stuff (part 3)
  263. ifeq ($(HAVE_ZYN_DEPS),true)
  264. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX
  265. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  266. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  267. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX_UI
  268. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  269. endif
  270. endif
  271. # --------------------------------------------------------------
  272. # Set app extension
  273. ifeq ($(WIN32),true)
  274. APP_EXT = .exe
  275. endif
  276. # --------------------------------------------------------------
  277. # Set shared lib extension
  278. LIB_EXT = .so
  279. ifeq ($(MACOS),true)
  280. LIB_EXT = .dylib
  281. endif
  282. ifeq ($(WIN32),true)
  283. LIB_EXT = .dll
  284. endif
  285. # --------------------------------------------------------------
  286. # Set static libs start & end
  287. ifneq ($(MACOS),true)
  288. LIBS_START = -Wl,--start-group
  289. LIBS_END = -Wl,--end-group
  290. endif
  291. # --------------------------------------------------------------
  292. # Set shared library CLI arg
  293. ifeq ($(MACOS),true)
  294. SHARED = -dynamiclib
  295. else
  296. SHARED = -shared
  297. endif
  298. # --------------------------------------------------------------