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.

416 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. # 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. CC ?= gcc
  14. CXX ?= g++
  15. # --------------------------------------------------------------
  16. # Fallback to Linux if no other OS defined
  17. ifneq ($(HAIKU),true)
  18. ifneq ($(MACOS),true)
  19. ifneq ($(WIN32),true)
  20. LINUX=true
  21. endif
  22. endif
  23. endif
  24. # --------------------------------------------------------------
  25. # Set MACOS_OR_WIN32
  26. ifeq ($(MACOS),true)
  27. MACOS_OR_WIN32=true
  28. endif
  29. ifeq ($(WIN32),true)
  30. MACOS_OR_WIN32=true
  31. endif
  32. # --------------------------------------------------------------
  33. # Set UNIX
  34. ifeq ($(LINUX),true)
  35. UNIX=true
  36. endif
  37. ifeq ($(MACOS),true)
  38. UNIX=true
  39. endif
  40. # --------------------------------------------------------------
  41. # Force some features on MacOS and Windows
  42. ifeq ($(MACOS_OR_WIN32),true)
  43. CARLA_VESTIGE_HEADER = false
  44. endif
  45. # --------------------------------------------------------------
  46. # Common build and link flags
  47. BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MMD
  48. BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -fdata-sections -ffunction-sections
  49. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections
  50. LINK_OPTS += -Wl,--strip-all
  51. ifneq ($(MACOS),true)
  52. # MacOS doesn't support this
  53. BASE_OPTS += -mfpmath=sse
  54. else
  55. # MacOS linker flags
  56. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  57. endif
  58. ifeq ($(RASPPI),true)
  59. # Raspberry-Pi optimization flags
  60. BASE_OPTS = -O2 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard
  61. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  62. endif
  63. ifeq ($(PANDORA),true)
  64. # OpenPandora flags
  65. BASE_OPTS = -O2 -ffast-math -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
  66. LINK_OPTS = -Wl,-O1 -Wl,--as-needed -Wl,--strip-all
  67. endif
  68. ifneq ($(WIN32),true)
  69. # not needed for Windows
  70. BASE_FLAGS += -fPIC -DPIC
  71. endif
  72. ifeq ($(DEBUG),true)
  73. BASE_FLAGS += -DDEBUG -O0 -g
  74. ifeq ($(WIN32),true)
  75. BASE_FLAGS += -msse -msse2
  76. endif
  77. LINK_OPTS =
  78. else
  79. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  80. CXXFLAGS += -fvisibility-inlines-hidden
  81. endif
  82. 32BIT_FLAGS = -m32
  83. 64BIT_FLAGS = -m64
  84. BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -std=gnu99 $(CFLAGS)
  85. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x -std=gnu++0x $(CXXFLAGS)
  86. LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS)
  87. ifeq ($(MACOS),true)
  88. # No C++11 support
  89. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS)
  90. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  91. endif
  92. # --------------------------------------------------------------
  93. # Strict test build
  94. ifeq ($(TESTBUILD),true)
  95. BASE_FLAGS += -Werror -Wabi -Wcast-qual -Wclobbered -Wconversion -Wdisabled-optimization -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-declarations
  96. BASE_FLAGS += -Woverlength-strings -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wundef -Wuninitialized -Wunused
  97. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  98. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  99. CFLAGS += -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings
  100. CXXFLAGS += -Wc++0x-compat -Wc++11-compat -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual -Wzero-as-null-pointer-constant
  101. ifeq ($(LINUX),true)
  102. BASE_FLAGS += -isystem /opt/kxstudio/include
  103. CXXFLAGS += -isystem /opt/kxstudio/include/ntk
  104. CXXFLAGS += -isystem /usr/include/qt4
  105. endif
  106. ifeq ($(MACOS),true)
  107. BASE_FLAGS += -isystem /opt/kxstudio/include
  108. CXXFLAGS += -isystem /System/Library/Frameworks
  109. endif
  110. ifeq ($(WIN64),true)
  111. BASE_FLAGS += -isystem /opt/mingw64/include
  112. else
  113. ifeq ($(WIN32),true)
  114. BASE_FLAGS += -isystem /opt/mingw32/include
  115. endif
  116. endif
  117. endif
  118. # --------------------------------------------------------------
  119. # Check for required libs
  120. ifeq ($(LINUX),true)
  121. ifeq (,$(wildcard /usr/include/magic.h))
  122. $(error libmagic missing, cannot continue)
  123. endif
  124. endif
  125. # --------------------------------------------------------------
  126. # Check for optional libs (required by backend or bridges)
  127. ifeq ($(MACOS_OR_WIN32),true)
  128. HAVE_DGL = true
  129. else
  130. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  131. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  132. ifeq ($(LINUX),true)
  133. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  134. HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true)
  135. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  136. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  137. endif
  138. endif
  139. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui && echo true)
  140. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Widgets && echo true)
  141. HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true)
  142. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  143. HAVE_LINUXSAMPLER = $(shell pkg-config --atleast-version=1.0.0.svn41 linuxsampler && echo true)
  144. # --------------------------------------------------------------
  145. # Set Qt tools
  146. ifeq ($(HAVE_QT4),true)
  147. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  148. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  149. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  150. ifeq (,$(wildcard $(MOC_QT4)))
  151. HAVE_QT4=false
  152. endif
  153. endif
  154. ifeq ($(HAVE_QT5),true)
  155. QT5_LIBDIR = $(shell pkg-config --variable=libdir Qt5Core)
  156. ifeq ($(MACOS),true)
  157. MOC_QT5 ?= $(QT5_LIBDIR)/../bin/moc
  158. RCC_QT5 ?= $(QT5_LIBDIR)/../bin/rcc
  159. UIC_QT5 ?= $(QT5_LIBDIR)/../bin/uic
  160. else # MACOS
  161. ifneq (,$(wildcard $(QT5_LIBDIR)/qt5/bin/moc))
  162. MOC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/moc
  163. RCC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/rcc
  164. UIC_QT5 ?= $(QT5_LIBDIR)/qt5/bin/uic
  165. else
  166. MOC_QT5 ?= $(QT5_LIBDIR)/qt/bin/moc
  167. RCC_QT5 ?= $(QT5_LIBDIR)/qt/bin/rcc
  168. UIC_QT5 ?= $(QT5_LIBDIR)/qt/bin/uic
  169. endif
  170. endif # MACOS
  171. ifeq (,$(wildcard $(MOC_QT5)))
  172. HAVE_QT5=false
  173. endif
  174. endif
  175. ifeq ($(HAVE_QT4),true)
  176. HAVE_QT=true
  177. endif
  178. ifeq ($(HAVE_QT5),true)
  179. HAVE_QT=true
  180. endif
  181. ifeq ($(WIN32),true)
  182. HAVE_QT=true
  183. endif
  184. # --------------------------------------------------------------
  185. # Set PyQt tools
  186. PYUIC4 ?= /usr/bin/pyuic4
  187. PYUIC5 ?= /usr/bin/pyuic5
  188. ifneq (,$(wildcard $(PYUIC4)))
  189. HAVE_PYQT=true
  190. HAVE_PYQT4=true
  191. else
  192. HAVE_PYQT4=false
  193. endif
  194. ifneq (,$(wildcard $(PYUIC5)))
  195. HAVE_PYQT=true
  196. HAVE_PYQT5=true
  197. else
  198. HAVE_PYQT5=false
  199. endif
  200. # --------------------------------------------------------------
  201. # Set default Qt used in frontend
  202. ifeq ($(HAVE_PYQT4),true)
  203. DEFAULT_QT ?= 4
  204. else
  205. DEFAULT_QT ?= 5
  206. endif
  207. # --------------------------------------------------------------
  208. # Check for optional libs (required by internal plugins)
  209. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  210. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  211. # --------------------------------------------------------------
  212. # Set base defines
  213. ifeq ($(HAVE_DGL),true)
  214. BASE_FLAGS += -DHAVE_DGL
  215. endif
  216. ifeq ($(HAVE_LIBLO),true)
  217. BASE_FLAGS += -DHAVE_LIBLO
  218. endif
  219. ifeq ($(HAVE_FLUIDSYNTH),true)
  220. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  221. endif
  222. ifeq ($(HAVE_LINUXSAMPLER),true)
  223. BASE_FLAGS += -DHAVE_LINUXSAMPLER
  224. endif
  225. ifeq ($(HAVE_X11),true)
  226. BASE_FLAGS += -DHAVE_X11
  227. endif
  228. ifeq ($(CARLA_VESTIGE_HEADER),true)
  229. BASE_FLAGS += -DVESTIGE_HEADER
  230. endif
  231. # --------------------------------------------------------------
  232. # Set libs stuff (part 1)
  233. ifeq ($(HAVE_LIBLO),true)
  234. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  235. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  236. endif
  237. ifeq ($(HAVE_FLUIDSYNTH),true)
  238. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  239. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  240. endif
  241. ifeq ($(HAVE_LINUXSAMPLER),true)
  242. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -DIS_CPP11=1 -Wno-non-virtual-dtor -Wno-shadow -Wno-unused-parameter
  243. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  244. endif
  245. ifeq ($(HAVE_X11),true)
  246. X11_FLAGS = $(shell pkg-config --cflags x11)
  247. X11_LIBS = $(shell pkg-config --libs x11)
  248. endif
  249. # --------------------------------------------------------------
  250. # Set libs stuff (part 2)
  251. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  252. ifeq ($(DEBUG),true)
  253. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  254. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  255. endif
  256. ifneq ($(HAIKU),true)
  257. RTMEMPOOL_LIBS = -lpthread
  258. endif
  259. ifeq ($(LINUX),true)
  260. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  261. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  262. LILV_LIBS = -ldl -lm -lrt
  263. ifeq ($(HAVE_DGL),true)
  264. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  265. DGL_LIBS = $(shell pkg-config --libs gl x11)
  266. endif
  267. ifeq ($(HAVE_ALSA),true)
  268. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  269. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  270. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  271. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  272. endif
  273. ifeq ($(HAVE_PULSEAUDIO),true)
  274. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  275. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  276. endif
  277. endif
  278. ifeq ($(MACOS),true)
  279. DGL_LIBS = -framework OpenGL -framework Cocoa
  280. JACKBRIDGE_LIBS = -ldl -lpthread
  281. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  282. JUCE_AUDIO_DEVICES_LIBS = -framework AppKit -framework AudioToolbox -framework CoreAudio -framework CoreMIDI
  283. JUCE_AUDIO_FORMATS_LIBS = -framework AudioToolbox -framework CoreFoundation
  284. JUCE_AUDIO_PROCESSORS_LIBS = -framework AudioToolbox -framework AudioUnit -framework CoreAudio -framework CoreAudioKit -framework Cocoa -framework Carbon
  285. JUCE_CORE_LIBS = -framework AppKit
  286. JUCE_EVENTS_LIBS = -framework AppKit
  287. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  288. JUCE_GUI_BASICS_LIBS = -framework Cocoa
  289. JUCE_GUI_EXTRA_LIBS = -framework Cocoa -framework IOKit
  290. LILV_LIBS = -ldl -lm
  291. endif
  292. ifeq ($(WIN32),true)
  293. DGL_LIBS = -lopengl32 -lgdi32
  294. JACKBRIDGE_LIBS = -lpthread
  295. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  296. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  297. # JUCE_EVENTS_LIBS = -lole32
  298. JUCE_GRAPHICS_LIBS = -lgdi32
  299. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  300. LILV_LIBS = -lm
  301. endif
  302. # --------------------------------------------------------------
  303. # Set libs stuff (part 3)
  304. ifeq ($(HAVE_ZYN_DEPS),true)
  305. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX
  306. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  307. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  308. NATIVE_PLUGINS_FLAGS += -DWANT_ZYNADDSUBFX_UI
  309. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  310. endif
  311. endif
  312. # --------------------------------------------------------------
  313. # Set app extension
  314. ifeq ($(WIN32),true)
  315. APP_EXT = .exe
  316. endif
  317. # --------------------------------------------------------------
  318. # Set shared lib extension
  319. LIB_EXT = .so
  320. ifeq ($(MACOS),true)
  321. LIB_EXT = .dylib
  322. endif
  323. ifeq ($(WIN32),true)
  324. LIB_EXT = .dll
  325. endif
  326. # --------------------------------------------------------------
  327. # Set static libs start & end
  328. ifneq ($(MACOS),true)
  329. LIBS_START = -Wl,--start-group
  330. LIBS_END = -Wl,--end-group
  331. endif
  332. # --------------------------------------------------------------
  333. # Set shared library CLI arg
  334. ifeq ($(MACOS),true)
  335. SHARED = -dynamiclib
  336. else
  337. SHARED = -shared
  338. endif
  339. # --------------------------------------------------------------