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.

439 lines
11KB

  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. # --------------------------------------------------------------
  103. # Strict test build
  104. ifeq ($(TESTBUILD),true)
  105. BASE_FLAGS += -Werror -Wabi -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-declarations
  106. BASE_FLAGS += -Woverlength-strings -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wundef -Wuninitialized -Wunused
  107. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  108. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  109. CFLAGS += -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings
  110. CXXFLAGS += -Wc++0x-compat -Wc++11-compat -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wzero-as-null-pointer-constant
  111. ifeq ($(LINUX),true)
  112. BASE_FLAGS += -isystem /opt/kxstudio/include
  113. CXXFLAGS += -isystem /usr/include/glib-2.0
  114. CXXFLAGS += -isystem /usr/include/glib-2.0/glib
  115. CXXFLAGS += -isystem /usr/include/gtk-2.0
  116. CXXFLAGS += -isystem /usr/include/gtk-2.0/gio
  117. ifeq ($(DEFAULT_QT),4)
  118. CXXFLAGS += -isystem /usr/include/qt4
  119. else
  120. CXXFLAGS += -isystem /usr/include/qt5
  121. endif
  122. endif
  123. ifeq ($(MACOS),true)
  124. BASE_FLAGS += -isystem /opt/kxstudio/include
  125. CXXFLAGS += -isystem /System/Library/Frameworks
  126. endif
  127. ifeq ($(WIN64),true)
  128. BASE_FLAGS += -isystem /opt/mingw64/include
  129. else
  130. ifeq ($(WIN32),true)
  131. BASE_FLAGS += -isystem /opt/mingw32/include
  132. endif
  133. endif
  134. endif
  135. # --------------------------------------------------------------
  136. # Check for optional libs (required by backend or bridges)
  137. ifneq ($(MACOS_OR_WIN32),true)
  138. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  139. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  140. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  141. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  142. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  143. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  144. endif
  145. ifeq ($(MACOS),true)
  146. HAVE_HYLIA = true
  147. endif
  148. ifeq ($(LINUX),true)
  149. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  150. HAVE_HYLIA = true
  151. endif
  152. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  153. HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true)
  154. HAVE_LINUXSAMPLER = $(shell pkg-config --atleast-version=1.0.0.svn41 linuxsampler && echo true)
  155. # --------------------------------------------------------------
  156. # Check for optional libs (special non-pkgconfig unix tests)
  157. ifeq ($(UNIX),true)
  158. # libmagic doesn't have a pkg-config file, so we need to call the compiler to test it
  159. HAVE_LIBMAGIC = $(shell echo '\#include <magic.h>' | $(CC) $(CFLAGS) -x c -w -c - -o .libmagic-tmp 2>/dev/null && echo true)
  160. endif
  161. # --------------------------------------------------------------
  162. # Set Qt tools
  163. ifeq ($(HAVE_QT4),true)
  164. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  165. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  166. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  167. ifeq (,$(wildcard $(MOC_QT4)))
  168. HAVE_QT4=false
  169. endif
  170. endif
  171. ifeq ($(HAVE_QT5),true)
  172. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  173. ifeq ($(MACOS),true)
  174. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  175. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  176. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  177. else # MACOS
  178. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  179. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  180. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  181. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  182. else
  183. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  184. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  185. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  186. endif
  187. endif # MACOS
  188. ifeq (,$(wildcard $(MOC_QT5)))
  189. HAVE_QT5=false
  190. endif
  191. endif
  192. ifeq ($(HAVE_QT4),true)
  193. HAVE_QT=true
  194. endif
  195. ifeq ($(HAVE_QT5),true)
  196. HAVE_QT=true
  197. endif
  198. ifeq ($(WIN32),true)
  199. HAVE_QT=true
  200. endif
  201. # --------------------------------------------------------------
  202. # Set PyQt tools
  203. PYUIC4 ?= /usr/bin/pyuic4
  204. PYUIC5 ?= /usr/bin/pyuic5
  205. ifneq (,$(wildcard $(PYUIC4)))
  206. HAVE_PYQT=true
  207. HAVE_PYQT4=true
  208. else
  209. HAVE_PYQT4=false
  210. endif
  211. ifneq (,$(wildcard $(PYUIC5)))
  212. HAVE_PYQT=true
  213. HAVE_PYQT5=true
  214. else
  215. HAVE_PYQT5=false
  216. endif
  217. # --------------------------------------------------------------
  218. # Set default Qt used in frontend
  219. ifeq ($(HAVE_PYQT4),true)
  220. DEFAULT_QT ?= 4
  221. else
  222. DEFAULT_QT ?= 5
  223. endif
  224. # --------------------------------------------------------------
  225. # Set base defines
  226. ifeq ($(HAVE_PYQT),true)
  227. BASE_FLAGS += -DHAVE_PYQT
  228. endif
  229. ifeq ($(HAVE_FLUIDSYNTH),true)
  230. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  231. endif
  232. ifeq ($(HAVE_HYLIA),true)
  233. BASE_FLAGS += -DHAVE_HYLIA
  234. endif
  235. ifeq ($(HAVE_LIBLO),true)
  236. BASE_FLAGS += -DHAVE_LIBLO
  237. endif
  238. ifeq ($(HAVE_LIBMAGIC),true)
  239. BASE_FLAGS += -DHAVE_LIBMAGIC
  240. endif
  241. ifeq ($(HAVE_LINUXSAMPLER),true)
  242. BASE_FLAGS += -DHAVE_LINUXSAMPLER
  243. endif
  244. ifeq ($(HAVE_X11),true)
  245. BASE_FLAGS += -DHAVE_X11
  246. endif
  247. # --------------------------------------------------------------
  248. # Set libs stuff (part 1)
  249. ifeq ($(HAVE_LIBLO),true)
  250. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  251. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  252. endif
  253. ifeq ($(HAVE_FLUIDSYNTH),true)
  254. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  255. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  256. endif
  257. ifeq ($(HAVE_LINUXSAMPLER),true)
  258. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -DIS_CPP11=1 -Wno-non-virtual-dtor -Wno-shadow -Wno-unused-parameter
  259. ifeq ($(LINUX),true)
  260. LINUXSAMPLER_LIBS = -Wl,-rpath=$(shell pkg-config --variable=libdir gig):$(shell pkg-config --variable=libdir linuxsampler)
  261. endif
  262. LINUXSAMPLER_LIBS += $(shell pkg-config --libs linuxsampler)
  263. ifeq ($(WIN32),true)
  264. LINUXSAMPLER_LIBS += -lws2_32
  265. endif
  266. endif
  267. ifeq ($(HAVE_X11),true)
  268. X11_FLAGS = $(shell pkg-config --cflags x11)
  269. X11_LIBS = $(shell pkg-config --libs x11)
  270. endif
  271. ifeq ($(HAVE_LIBMAGIC),true)
  272. MAGIC_LIBS += -lmagic
  273. endif
  274. # --------------------------------------------------------------
  275. # Set libs stuff (part 2)
  276. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY
  277. ifeq ($(DEBUG),true)
  278. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  279. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  280. endif
  281. ifneq ($(HAIKU),true)
  282. RTMEMPOOL_LIBS = -lpthread
  283. endif
  284. ifeq ($(UNIX),true)
  285. HYLIA_FLAGS +=
  286. RTAUDIO_FLAGS += -D__UNIX_JACK__
  287. endif
  288. ifeq ($(LINUX),true)
  289. HYLIA_FLAGS = -DLINK_PLATFORM_LINUX=1
  290. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  291. LILV_LIBS = -ldl -lm -lrt
  292. WATER_LIBS = -ldl -lpthread -lrt
  293. ifeq ($(HAVE_ALSA),true)
  294. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  295. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  296. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  297. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  298. endif
  299. ifeq ($(HAVE_PULSEAUDIO),true)
  300. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  301. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  302. endif
  303. endif
  304. ifeq ($(MACOS),true)
  305. HYLIA_FLAGS = -DLINK_PLATFORM_MACOSX=1
  306. JACKBRIDGE_LIBS = -ldl -lpthread
  307. LILV_LIBS = -ldl -lm
  308. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  309. RTMIDI_FLAGS += -D__MACOSX_CORE__
  310. WATER_LIBS = -framework AppKit
  311. endif
  312. ifeq ($(WIN32),true)
  313. HYLIA_FLAGS = -DLINK_PLATFORM_WINDOWS=1
  314. JACKBRIDGE_LIBS = -lpthread
  315. LILV_LIBS = -lm
  316. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__ -D__WINDOWS_WASAPI__
  317. RTAUDIO_LIBS += -ldsound -luuid -lksuser -lwinmm
  318. RTMIDI_FLAGS += -D__WINDOWS_MM__
  319. WATER_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  320. endif
  321. # --------------------------------------------------------------
  322. # Set app extension
  323. ifeq ($(WIN32),true)
  324. APP_EXT = .exe
  325. endif
  326. # --------------------------------------------------------------
  327. # Set shared lib extension
  328. LIB_EXT = .so
  329. ifeq ($(MACOS),true)
  330. LIB_EXT = .dylib
  331. endif
  332. ifeq ($(WIN32),true)
  333. LIB_EXT = .dll
  334. endif
  335. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  336. # --------------------------------------------------------------
  337. # Set static libs start & end
  338. ifneq ($(MACOS),true)
  339. LIBS_START = -Wl,--start-group
  340. LIBS_END = -Wl,--end-group
  341. endif
  342. # --------------------------------------------------------------
  343. # Set shared library CLI arg
  344. ifeq ($(MACOS),true)
  345. SHARED = -dynamiclib
  346. else
  347. SHARED = -shared
  348. endif
  349. # --------------------------------------------------------------
  350. ifeq ($(EXTERNAL_PLUGINS),true)
  351. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  352. include $(CWD)/native-plugins/external/Makefile.mk
  353. endif
  354. # --------------------------------------------------------------