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.

512 lines
14KB

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