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.

346 lines
10KB

  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. ifneq ($(MACOS_OR_WIN32),true)
  119. HAVE_FFMPEG = $(shell pkg-config --exists libavcodec libavformat libavutil && echo true)
  120. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  121. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  122. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  123. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  124. ifeq ($(LINUX),true)
  125. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  126. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  127. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  128. endif
  129. endif
  130. ifeq ($(CARLA_SAMPLERS_SUPPORT),true)
  131. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  132. HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true)
  133. endif
  134. # --------------------------------------------------------------
  135. # Set Qt tools
  136. ifeq ($(HAVE_QT4),true)
  137. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  138. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  139. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  140. ifeq (,$(wildcard $(MOC_QT4)))
  141. HAVE_QT4=false
  142. endif
  143. endif
  144. ifeq ($(HAVE_QT5),true)
  145. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  146. ifeq ($(MACOS),true)
  147. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  148. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  149. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  150. else # MACOS
  151. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  152. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  153. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  154. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  155. else
  156. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  157. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  158. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  159. endif
  160. endif # MACOS
  161. ifeq (,$(wildcard $(MOC_QT5)))
  162. HAVE_QT5=false
  163. endif
  164. endif
  165. # --------------------------------------------------------------
  166. # Set default Qt used in frontend
  167. ifeq ($(HAVE_QT4),true)
  168. DEFAULT_QT ?= 4
  169. else
  170. DEFAULT_QT ?= 5
  171. endif
  172. # --------------------------------------------------------------
  173. # Check for optional libs (required by internal plugins)
  174. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  175. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  176. # --------------------------------------------------------------
  177. # Set base defines
  178. ifeq ($(HAVE_X11),true)
  179. BASE_FLAGS += -DHAVE_X11
  180. endif
  181. # --------------------------------------------------------------
  182. # Set libs stuff (part 1)
  183. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  184. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  185. ifeq ($(HAVE_FLUIDSYNTH),true)
  186. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  187. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  188. endif
  189. ifeq ($(HAVE_LINUXSAMPLER),true)
  190. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -Wno-unused-parameter
  191. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  192. endif
  193. ifeq ($(HAVE_X11),true)
  194. X11_FLAGS = $(shell pkg-config --cflags x11)
  195. X11_LIBS = $(shell pkg-config --libs x11)
  196. endif
  197. # --------------------------------------------------------------
  198. # Set libs stuff (part 2)
  199. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  200. ifeq ($(DEBUG),true)
  201. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  202. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  203. endif
  204. ifneq ($(HAIKU),true)
  205. RTMEMPOOL_LIBS = -lpthread
  206. endif
  207. ifeq ($(LINUX),true)
  208. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  209. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  210. LILV_LIBS = -ldl -lm -lrt
  211. ifeq ($(HAVE_ALSA),true)
  212. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  213. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  214. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  215. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  216. endif
  217. ifeq ($(HAVE_PULSEAUDIO),true)
  218. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  219. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  220. endif
  221. endif
  222. ifeq ($(MACOS),true)
  223. JACKBRIDGE_LIBS = -ldl -lpthread
  224. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  225. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  226. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  227. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  228. JUCE_CORE_LIBS = -framework AppKit
  229. JUCE_EVENTS_LIBS = -framework AppKit
  230. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  231. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  232. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  233. LILV_LIBS = -ldl -lm
  234. endif
  235. ifeq ($(WIN32),true)
  236. JACKBRIDGE_LIBS = -lpthread
  237. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  238. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  239. # JUCE_EVENTS_LIBS = -lole32
  240. JUCE_GRAPHICS_LIBS = -lgdi32
  241. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  242. LILV_LIBS = -lm
  243. endif
  244. # --------------------------------------------------------------
  245. # Set libs stuff (part 3)
  246. ifeq ($(HAVE_ZYN_DEPS),true)
  247. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX
  248. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  249. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  250. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX_UI
  251. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  252. endif
  253. endif
  254. # --------------------------------------------------------------
  255. # Set app extension
  256. ifeq ($(WIN32),true)
  257. APP_EXT = .exe
  258. endif
  259. # --------------------------------------------------------------
  260. # Set shared lib extension
  261. LIB_EXT = .so
  262. ifeq ($(MACOS),true)
  263. LIB_EXT = .dylib
  264. endif
  265. ifeq ($(WIN32),true)
  266. LIB_EXT = .dll
  267. endif
  268. # --------------------------------------------------------------
  269. # Set static libs start & end
  270. ifneq ($(MACOS),true)
  271. LIBS_START = -Wl,--start-group
  272. LIBS_END = -Wl,--end-group
  273. endif
  274. # --------------------------------------------------------------
  275. # Set shared library CLI arg
  276. ifeq ($(MACOS),true)
  277. SHARED = -dynamiclib
  278. else
  279. SHARED = -shared
  280. endif
  281. # --------------------------------------------------------------