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.

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