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.

472 lines
12KB

  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. # Build external plugins
  9. EXTERNAL_PLUGINS = true
  10. # Enable experimental plugins, don't complain if the build fails when using this!
  11. EXPERIMENTAL_PLUGINS = false
  12. # --------------------------------------------------------------
  13. # DO NOT MODIFY PAST THIS POINT!
  14. AR ?= ar
  15. CC ?= gcc
  16. CXX ?= g++
  17. # --------------------------------------------------------------
  18. # Fallback to Linux if no other OS defined
  19. ifneq ($(HAIKU),true)
  20. ifneq ($(MACOS),true)
  21. ifneq ($(WIN32),true)
  22. LINUX=true
  23. endif
  24. endif
  25. endif
  26. # --------------------------------------------------------------
  27. # Set MACOS_OR_WIN32
  28. ifeq ($(MACOS),true)
  29. MACOS_OR_WIN32=true
  30. endif
  31. ifeq ($(WIN32),true)
  32. MACOS_OR_WIN32=true
  33. endif
  34. # --------------------------------------------------------------
  35. # Set UNIX
  36. ifeq ($(LINUX),true)
  37. UNIX=true
  38. endif
  39. ifeq ($(MACOS),true)
  40. UNIX=true
  41. endif
  42. # --------------------------------------------------------------
  43. # Force some features on MacOS and Windows
  44. ifeq ($(MACOS_OR_WIN32),true)
  45. EXPERIMENTAL_PLUGINS = false
  46. endif
  47. # --------------------------------------------------------------
  48. # Set build and link flags
  49. BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MD -MP
  50. BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse -fdata-sections -ffunction-sections
  51. ifeq ($(MACOS),true)
  52. # MacOS linker flags
  53. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  54. else
  55. # Common linker flags
  56. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed
  57. ifneq ($(SKIP_STRIPPING),true)
  58. LINK_OPTS += -Wl,--strip-all
  59. endif
  60. endif
  61. ifeq ($(RASPPI),true)
  62. # Raspberry-Pi optimization flags
  63. BASE_OPTS = -O2 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard
  64. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  65. endif
  66. ifeq ($(NOOPT),true)
  67. # No optimization flags
  68. BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
  69. endif
  70. ifneq ($(WIN32),true)
  71. # Not needed for Windows
  72. BASE_FLAGS += -fPIC -DPIC
  73. endif
  74. ifeq ($(CLANG),true)
  75. BASE_FLAGS += -Wabsolute-value
  76. endif
  77. ifeq ($(STOAT),true)
  78. CC = clang
  79. CXX = clang++
  80. BASE_FLAGS += -emit-llvm
  81. BASE_OPTS += -O0
  82. endif
  83. ifeq ($(DEBUG),true)
  84. BASE_FLAGS += -DDEBUG -O0 -g
  85. ifeq ($(WIN32),true)
  86. BASE_FLAGS += -msse -msse2
  87. endif
  88. LINK_OPTS =
  89. else
  90. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  91. CXXFLAGS += -fvisibility-inlines-hidden
  92. endif
  93. 32BIT_FLAGS = -m32
  94. 64BIT_FLAGS = -m64
  95. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  96. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++0x $(CXXFLAGS)
  97. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  98. ifneq ($(MACOS),true)
  99. # Not available on MacOS
  100. LINK_FLAGS += -Wl,--no-undefined
  101. endif
  102. ifeq ($(MACOS_OLD),true)
  103. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS)
  104. endif
  105. # --------------------------------------------------------------
  106. # Strict test build
  107. ifeq ($(TESTBUILD),true)
  108. BASE_FLAGS += -Werror -Wabi -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-declarations
  109. BASE_FLAGS += -Woverlength-strings -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wundef -Wuninitialized -Wunused
  110. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  111. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  112. CFLAGS += -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings
  113. CXXFLAGS += -Wc++0x-compat -Wc++11-compat -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wzero-as-null-pointer-constant
  114. ifeq ($(LINUX),true)
  115. BASE_FLAGS += -isystem /opt/kxstudio/include
  116. CXXFLAGS += -isystem /usr/include/glib-2.0
  117. CXXFLAGS += -isystem /usr/include/glib-2.0/glib
  118. CXXFLAGS += -isystem /usr/include/gtk-2.0
  119. CXXFLAGS += -isystem /usr/include/gtk-2.0/gio
  120. ifeq ($(DEFAULT_QT),4)
  121. CXXFLAGS += -isystem /usr/include/qt4
  122. else
  123. CXXFLAGS += -isystem /usr/include/qt5
  124. endif
  125. endif
  126. ifeq ($(MACOS),true)
  127. BASE_FLAGS += -isystem /opt/kxstudio/include
  128. CXXFLAGS += -isystem /System/Library/Frameworks
  129. endif
  130. ifeq ($(WIN64),true)
  131. BASE_FLAGS += -isystem /opt/mingw64/include
  132. else
  133. ifeq ($(WIN32),true)
  134. BASE_FLAGS += -isystem /opt/mingw32/include
  135. endif
  136. endif
  137. endif
  138. # --------------------------------------------------------------
  139. # Check for optional libs (required by backend or bridges)
  140. ifneq ($(MACOS_OR_WIN32),true)
  141. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  142. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  143. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  144. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  145. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  146. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  147. endif
  148. ifeq ($(MACOS),true)
  149. ifneq ($(MACOS_OLD),true)
  150. HAVE_HYLIA = true
  151. endif
  152. endif
  153. ifeq ($(LINUX),true)
  154. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  155. HAVE_HYLIA = true
  156. endif
  157. HAVE_FFMPEG = $(shell pkg-config --exists libavcodec libavformat libavutil && echo true)
  158. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  159. HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true)
  160. HAVE_LINUXSAMPLER = $(shell pkg-config --atleast-version=1.0.0.svn41 linuxsampler && echo true)
  161. HAVE_SNDFILE = $(shell pkg-config --exists sndfile && echo true)
  162. # --------------------------------------------------------------
  163. # Check for optional libs (special non-pkgconfig unix tests)
  164. ifeq ($(UNIX),true)
  165. # libmagic doesn't have a pkg-config file, so we need to call the compiler to test it
  166. HAVE_LIBMAGIC = $(shell echo '\#include <magic.h>' | $(CC) $(CFLAGS) -x c -w -c - -o .libmagic-tmp 2>/dev/null && echo true)
  167. endif
  168. # --------------------------------------------------------------
  169. # Set Qt tools
  170. ifeq ($(HAVE_QT4),true)
  171. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  172. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  173. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  174. ifeq (,$(wildcard $(MOC_QT4)))
  175. HAVE_QT4=false
  176. endif
  177. endif
  178. ifeq ($(HAVE_QT5),true)
  179. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  180. ifeq ($(MACOS),true)
  181. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  182. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  183. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  184. else # MACOS
  185. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  186. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  187. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  188. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  189. else
  190. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  191. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  192. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  193. endif
  194. endif # MACOS
  195. ifeq (,$(wildcard $(MOC_QT5)))
  196. HAVE_QT5=false
  197. endif
  198. endif
  199. ifeq ($(HAVE_QT4),true)
  200. HAVE_QT=true
  201. endif
  202. ifeq ($(HAVE_QT5),true)
  203. HAVE_QT=true
  204. endif
  205. ifeq ($(WIN32),true)
  206. HAVE_QT=true
  207. endif
  208. # --------------------------------------------------------------
  209. # Set PyQt tools
  210. PYUIC4 ?= /usr/bin/pyuic4
  211. PYUIC5 ?= /usr/bin/pyuic5
  212. ifneq (,$(wildcard $(PYUIC4)))
  213. HAVE_PYQT=true
  214. HAVE_PYQT4=true
  215. else
  216. HAVE_PYQT4=false
  217. endif
  218. ifneq (,$(wildcard $(PYUIC5)))
  219. HAVE_PYQT=true
  220. HAVE_PYQT5=true
  221. else
  222. HAVE_PYQT5=false
  223. endif
  224. # --------------------------------------------------------------
  225. # Set default Qt used in frontend
  226. ifeq ($(HAVE_PYQT4),true)
  227. DEFAULT_QT ?= 4
  228. else
  229. DEFAULT_QT ?= 5
  230. endif
  231. # --------------------------------------------------------------
  232. # Set base defines
  233. ifeq ($(HAVE_PYQT),true)
  234. BASE_FLAGS += -DHAVE_PYQT
  235. endif
  236. ifeq ($(HAVE_FLUIDSYNTH),true)
  237. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  238. endif
  239. ifeq ($(HAVE_FFMPEG),true)
  240. BASE_FLAGS += -DHAVE_FFMPEG
  241. endif
  242. ifeq ($(HAVE_HYLIA),true)
  243. BASE_FLAGS += -DHAVE_HYLIA
  244. endif
  245. ifeq ($(HAVE_LIBLO),true)
  246. BASE_FLAGS += -DHAVE_LIBLO
  247. endif
  248. ifeq ($(HAVE_LIBMAGIC),true)
  249. BASE_FLAGS += -DHAVE_LIBMAGIC
  250. endif
  251. ifeq ($(HAVE_LINUXSAMPLER),true)
  252. BASE_FLAGS += -DHAVE_LINUXSAMPLER
  253. endif
  254. ifeq ($(HAVE_SNDFILE),true)
  255. BASE_FLAGS += -DHAVE_SNDFILE
  256. endif
  257. ifeq ($(HAVE_X11),true)
  258. BASE_FLAGS += -DHAVE_X11
  259. endif
  260. # --------------------------------------------------------------
  261. # Set libs stuff (part 1)
  262. ifeq ($(HAVE_LIBLO),true)
  263. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  264. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  265. endif
  266. ifeq ($(HAVE_FFMPEG),true)
  267. FFMPEG_FLAGS = $(shell pkg-config --cflags libavcodec libavformat libavutil)
  268. FFMPEG_LIBS = $(shell pkg-config --libs libavcodec libavformat libavutil)
  269. endif
  270. ifeq ($(HAVE_FLUIDSYNTH),true)
  271. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  272. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  273. endif
  274. ifeq ($(HAVE_LINUXSAMPLER),true)
  275. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -DIS_CPP11=1 -Wno-non-virtual-dtor -Wno-shadow -Wno-unused-parameter
  276. ifeq ($(LINUX),true)
  277. LINUXSAMPLER_LIBS = -Wl,-rpath=$(shell pkg-config --variable=libdir gig):$(shell pkg-config --variable=libdir linuxsampler)
  278. endif
  279. LINUXSAMPLER_LIBS += $(shell pkg-config --libs linuxsampler)
  280. ifeq ($(WIN32),true)
  281. LINUXSAMPLER_LIBS += -lws2_32
  282. endif
  283. endif
  284. ifeq ($(HAVE_SNDFILE),true)
  285. SNDFILE_FLAGS = $(shell pkg-config --cflags sndfile)
  286. SNDFILE_LIBS = $(shell pkg-config --libs sndfile)
  287. endif
  288. ifeq ($(HAVE_X11),true)
  289. X11_FLAGS = $(shell pkg-config --cflags x11)
  290. X11_LIBS = $(shell pkg-config --libs x11)
  291. endif
  292. ifeq ($(HAVE_LIBMAGIC),true)
  293. MAGIC_LIBS += -lmagic
  294. endif
  295. # --------------------------------------------------------------
  296. # Set libs stuff (part 2)
  297. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY
  298. ifeq ($(DEBUG),true)
  299. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  300. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  301. endif
  302. ifneq ($(HAIKU),true)
  303. RTMEMPOOL_LIBS = -lpthread
  304. endif
  305. ifeq ($(UNIX),true)
  306. HYLIA_FLAGS +=
  307. RTAUDIO_FLAGS += -D__UNIX_JACK__
  308. endif
  309. ifeq ($(LINUX),true)
  310. HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1
  311. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  312. LILV_LIBS = -ldl -lm -lrt
  313. WATER_LIBS = -ldl -lpthread -lrt
  314. ifeq ($(HAVE_ALSA),true)
  315. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  316. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  317. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  318. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  319. endif
  320. ifeq ($(HAVE_PULSEAUDIO),true)
  321. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  322. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  323. endif
  324. endif
  325. ifeq ($(MACOS),true)
  326. HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1
  327. JACKBRIDGE_LIBS = -ldl -lpthread
  328. LILV_LIBS = -ldl -lm
  329. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  330. RTAUDIO_LIBS += -framework CoreAudio
  331. RTMIDI_FLAGS += -D__MACOSX_CORE__
  332. RTMIDI_LIBS += -framework CoreMIDI
  333. WATER_LIBS = -framework AppKit
  334. endif
  335. ifeq ($(WIN32),true)
  336. HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1
  337. JACKBRIDGE_LIBS = -lpthread
  338. LILV_LIBS = -lm
  339. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__ -D__WINDOWS_WASAPI__
  340. RTAUDIO_LIBS += -ldsound -luuid -lksuser -lwinmm
  341. RTMIDI_FLAGS += -D__WINDOWS_MM__
  342. WATER_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  343. endif
  344. # ---------------------------------------------------------------------------------------------------------------------
  345. NATIVE_PLUGINS_LIBS += $(FFMPEG_LIBS)
  346. NATIVE_PLUGINS_LIBS += $(SNDFILE_LIBS)
  347. # ---------------------------------------------------------------------------------------------------------------------
  348. # Set app extension
  349. ifeq ($(WIN32),true)
  350. APP_EXT = .exe
  351. endif
  352. # ---------------------------------------------------------------------------------------------------------------------
  353. # Set shared lib extension
  354. LIB_EXT = .so
  355. ifeq ($(MACOS),true)
  356. LIB_EXT = .dylib
  357. endif
  358. ifeq ($(WIN32),true)
  359. LIB_EXT = .dll
  360. endif
  361. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  362. # --------------------------------------------------------------
  363. # Set static libs start & end
  364. ifneq ($(MACOS),true)
  365. LIBS_START = -Wl,--start-group
  366. LIBS_END = -Wl,--end-group
  367. endif
  368. # --------------------------------------------------------------
  369. # Set shared library CLI arg
  370. ifeq ($(MACOS),true)
  371. SHARED = -dynamiclib
  372. else
  373. SHARED = -shared
  374. endif
  375. # --------------------------------------------------------------
  376. ifeq ($(EXTERNAL_PLUGINS),true)
  377. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  378. include $(CWD)/native-plugins/external/Makefile.mk
  379. endif
  380. # --------------------------------------------------------------