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.

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