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.

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