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.

390 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. # Support for LADSPA, DSSI, LV2, VST and AU plugins
  9. CARLA_PLUGIN_SUPPORT = true
  10. # Support for csound files (version 6, not ready yet)
  11. CARLA_CSOUND_SUPPORT = false
  12. # Support for GIG, SF2 and SFZ sample banks (through fluidsynth and linuxsampler)
  13. CARLA_SAMPLERS_SUPPORT = true
  14. # Use the free vestige header instead of the official VST SDK
  15. CARLA_VESTIGE_HEADER = true
  16. # --------------------------------------------------------------
  17. # DO NOT MODIFY PAST THIS POINT!
  18. AR ?= ar
  19. RM ?= rm -f
  20. CC ?= gcc
  21. CXX ?= g++
  22. # --------------------------------------------------------------
  23. # Fallback to Linux if no other OS defined
  24. ifneq ($(HAIKU),true)
  25. ifneq ($(MACOS),true)
  26. ifneq ($(WIN32),true)
  27. LINUX=true
  28. endif
  29. endif
  30. endif
  31. # --------------------------------------------------------------
  32. # Use the real VSTSDK in MacOS and Windows
  33. ifeq ($(MACOS),true)
  34. CARLA_VESTIGE_HEADER = false
  35. endif
  36. ifeq ($(WIN32),true)
  37. CARLA_VESTIGE_HEADER = false
  38. endif
  39. # --------------------------------------------------------------
  40. # Common build and link flags
  41. BASE_FLAGS = -Wall -Wextra -pipe -DREAL_BUILD
  42. BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse -fdata-sections -ffunction-sections
  43. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections
  44. ifeq ($(TESTBUILD),true)
  45. BASE_FLAGS += -Werror -Wcast-align -Wcast-qual -Wconversion -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wunsafe-loop-optimizations -Wwrite-strings
  46. CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  47. CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
  48. ifeq ($(LINUX),true)
  49. CFLAGS += -isystem /opt/kxstudio/include
  50. CXXFLAGS += -isystem /opt/kxstudio/include -isystem /usr/include/qt4
  51. endif
  52. ifeq ($(MACOS),true)
  53. CFLAGS += -isystem /opt/local/include/
  54. CXXFLAGS += -isystem /opt/local/include/
  55. endif
  56. ifeq ($(WIN32),true)
  57. CFLAGS += -isystem /opt/mingw32/include
  58. CXXFLAGS += -isystem /opt/mingw32/include -isystem /opt/mingw32/include/qt4
  59. endif
  60. endif
  61. ifneq ($(MACOS),true)
  62. BASE_FLAGS += -Wlogical-op
  63. ifeq ($(TESTBUILD),true)
  64. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  65. # -Wsuggest-attribute=noreturn
  66. endif
  67. endif
  68. ifeq ($(WIN32),true)
  69. BASE_FLAGS += -msse -msse2
  70. else
  71. BASE_FLAGS += -fPIC -DPIC
  72. endif
  73. ifeq ($(RASPPI),true)
  74. # Raspberry-Pi optimization flags
  75. BASE_OPTS = -O3 -ffast-math -march=armv6 -mfpu=vfp -mfloat-abi=hard
  76. LINK_OPTS =
  77. endif
  78. ifeq ($(DEBUG),true)
  79. BASE_FLAGS += -DDEBUG -O0 -g
  80. LINK_OPTS =
  81. else
  82. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  83. CXXFLAGS += -fvisibility-inlines-hidden
  84. LINK_OPTS += -Wl,-O1 -Wl,--strip-all
  85. endif
  86. 32BIT_FLAGS = -m32
  87. 64BIT_FLAGS = -m64
  88. BUILD_C_FLAGS = $(BASE_FLAGS) -std=c99 -std=gnu99 $(CFLAGS)
  89. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=c++0x -std=gnu++0x $(CXXFLAGS)
  90. LINK_FLAGS = $(LINK_OPTS) -Wl,--no-undefined $(LDFLAGS)
  91. ifeq ($(MACOS),true)
  92. # No C++11 support; force 32bit per default
  93. BUILD_C_FLAGS += $(32BIT_FLAGS)
  94. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(32BIT_FLAGS) $(CXXFLAGS)
  95. LINK_FLAGS = $(32BIT_FLAGS) $(LDFLAGS)
  96. # Set target
  97. BUILD_CXX_FLAGS += -DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_5
  98. BUILD_CXX_FLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_10_5
  99. endif
  100. # --------------------------------------------------------------
  101. # Check for qt, set default version (prefer qt4)
  102. HAVE_QT4 = $(shell pkg-config --exists QtCore QtGui QtXml && echo true)
  103. HAVE_QT5 = $(shell pkg-config --exists Qt5Core Qt5Gui Qt5Xml Qt5Widgets && echo true)
  104. ifeq ($(HAVE_QT5),true)
  105. DEFAULT_QT=5
  106. endif
  107. ifeq ($(HAVE_QT4),true)
  108. DEFAULT_QT=4
  109. endif
  110. # --------------------------------------------------------------
  111. # Check for required libs
  112. ifneq ($(shell pkg-config --exists liblo && echo true),true)
  113. $(error liblo missing, cannot continue)
  114. endif
  115. ifneq ($(HAVE_QT4),true)
  116. ifneq ($(HAVE_QT5),true)
  117. $(error Qt missing, cannot continue)
  118. endif
  119. endif
  120. # --------------------------------------------------------------
  121. # Check for dgl support
  122. ifeq ($(HAIKU),true)
  123. HAVE_DGL = false
  124. endif
  125. ifeq ($(LINUX),true)
  126. HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true)
  127. endif
  128. ifeq ($(MACOS),true)
  129. HAVE_DGL = true
  130. endif
  131. ifeq ($(WIN32),true)
  132. HAVE_DGL = true
  133. endif
  134. # --------------------------------------------------------------
  135. # Check for juce support
  136. ifeq ($(HAIKU),true)
  137. HAVE_JUCE = false
  138. endif
  139. ifeq ($(LINUX),true)
  140. HAVE_JUCE = $(shell pkg-config --exists x11 xinerama xext xcursor freetype2 && echo true)
  141. endif
  142. ifeq ($(MACOS),true)
  143. HAVE_JUCE = true
  144. endif
  145. ifeq ($(WIN32),true)
  146. HAVE_JUCE = true
  147. endif
  148. # --------------------------------------------------------------
  149. # Check for optional libs (required by backend or bridges)
  150. HAVE_FFMPEG = $(shell pkg-config --exists libavcodec libavformat libavutil && echo true)
  151. HAVE_GTK2 = $(shell pkg-config --exists gtk+-2.0 && echo true)
  152. HAVE_GTK3 = $(shell pkg-config --exists gtk+-3.0 && echo true)
  153. HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
  154. ifeq ($(LINUX),true)
  155. HAVE_ALSA = $(shell pkg-config --exists alsa && echo true)
  156. HAVE_PULSEAUDIO = $(shell pkg-config --exists libpulse-simple && echo true)
  157. endif
  158. ifeq ($(CARLA_CSOUND_SUPPORT),true)
  159. ifeq ($(HAVE_JUCE),true)
  160. HAVE_CSOUND = $(shell pkg-config --exists sndfile && echo true)
  161. endif
  162. endif
  163. ifeq ($(CARLA_SAMPLERS_SUPPORT),true)
  164. HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
  165. HAVE_LINUXSAMPLER = $(shell pkg-config --exists linuxsampler && echo true)
  166. endif
  167. # --------------------------------------------------------------
  168. # Check for optional libs (needed by internal plugins)
  169. HAVE_AF_DEPS = $(shell pkg-config --exists sndfile && echo true)
  170. HAVE_MF_DEPS = $(shell pkg-config --exists smf && echo true)
  171. HAVE_ZYN_DEPS = $(shell pkg-config --exists fftw3 mxml zlib && echo true)
  172. HAVE_ZYN_UI_DEPS = $(shell pkg-config --exists ntk_images ntk && echo true)
  173. # --------------------------------------------------------------
  174. # Set base stuff
  175. ifeq ($(HAVE_DGL),true)
  176. BASE_FLAGS += -DHAVE_DGL
  177. endif
  178. ifeq ($(HAVE_FFMPEG),true)
  179. BASE_FLAGS += -DHAVE_FFMPEG
  180. endif
  181. ifeq ($(HAVE_JUCE),true)
  182. BASE_FLAGS += -DHAVE_JUCE
  183. endif
  184. ifeq ($(HAVE_X11),true)
  185. BASE_FLAGS += -DHAVE_X11
  186. endif
  187. # --------------------------------------------------------------
  188. # Set libs stuff (part 1)
  189. LIBLO_FLAGS = $(shell pkg-config --cflags liblo)
  190. LIBLO_LIBS = $(shell pkg-config --libs liblo)
  191. ifeq ($(DEFAULT_QT),5)
  192. QTCORE_FLAGS = $(shell pkg-config --cflags Qt5Core)
  193. QTCORE_LIBS = $(shell pkg-config --libs Qt5Core)
  194. QTXML_FLAGS = $(shell pkg-config --cflags Qt5Xml)
  195. QTXML_LIBS = $(shell pkg-config --libs Qt5Xml)
  196. else
  197. QTCORE_FLAGS = $(shell pkg-config --cflags QtCore)
  198. QTCORE_LIBS = $(shell pkg-config --libs QtCore)
  199. QTXML_FLAGS = $(shell pkg-config --cflags QtXml)
  200. QTXML_LIBS = $(shell pkg-config --libs QtXml)
  201. endif
  202. ifeq ($(HAVE_CSOUND),true)
  203. CSOUND_FLAGS = $(shell pkg-config --cflags sndfile) -DUSE_DOUBLE=1
  204. CSOUND_LIBS = $(shell pkg-config --libs sndfile) -lcsound64
  205. endif
  206. ifeq ($(HAVE_FLUIDSYNTH),true)
  207. FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
  208. FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
  209. endif
  210. ifeq ($(HAVE_LINUXSAMPLER),true)
  211. LINUXSAMPLER_FLAGS = $(shell pkg-config --cflags linuxsampler) -Wno-unused-parameter
  212. LINUXSAMPLER_LIBS = $(shell pkg-config --libs linuxsampler)
  213. endif
  214. ifeq ($(HAVE_X11),true)
  215. X11_FLAGS = $(shell pkg-config --cflags x11)
  216. X11_LIBS = $(shell pkg-config --libs x11)
  217. endif
  218. ifneq ($(HAIKU),true)
  219. RTMEMPOOL_LIBS = -lpthread
  220. endif
  221. # --------------------------------------------------------------
  222. # Set libs stuff (part 2)
  223. ifeq ($(HAVE_AF_DEPS),true)
  224. AUDIO_DECODER_FLAGS = $(shell pkg-config --cflags sndfile)
  225. AUDIO_DECODER_LIBS = $(shell pkg-config --libs sndfile)
  226. ifeq ($(HAVE_FFMPEG),true)
  227. AUDIO_DECODER_FLAGS += $(shell pkg-config --cflags libavcodec libavformat libavutil)
  228. AUDIO_DECODER_LIBS += $(shell pkg-config --libs libavcodec libavformat libavutil)
  229. endif
  230. endif
  231. RTAUDIO_FLAGS = -DHAVE_GETTIMEOFDAY -D__UNIX_JACK__
  232. ifeq ($(DEBUG),true)
  233. RTAUDIO_FLAGS += -D__RTAUDIO_DEBUG__
  234. RTMIDI_FLAGS += -D__RTMIDI_DEBUG__
  235. endif
  236. ifeq ($(LINUX),true)
  237. ifeq ($(HAVE_DGL),true)
  238. DGL_FLAGS = $(shell pkg-config --cflags gl x11)
  239. DGL_LIBS = $(shell pkg-config --libs gl x11)
  240. endif
  241. JACKBRIDGE_LIBS = -ldl -lpthread -lrt
  242. ifeq ($(HAVE_JUCE),true)
  243. JUCE_CORE_LIBS = -ldl -lpthread -lrt
  244. JUCE_EVENTS_FLAGS = $(shell pkg-config --cflags x11)
  245. JUCE_EVENTS_LIBS = $(shell pkg-config --libs x11)
  246. JUCE_GRAPHICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext freetype2)
  247. JUCE_GRAPHICS_LIBS = $(shell pkg-config --libs x11 xinerama xext freetype2)
  248. JUCE_GUI_BASICS_FLAGS = $(shell pkg-config --cflags x11 xinerama xext xcursor)
  249. JUCE_GUI_BASICS_LIBS = $(shell pkg-config --libs x11 xinerama xext xcursor) -ldl
  250. endif
  251. LILV_LIBS = -ldl -lm -lrt
  252. ifeq ($(HAVE_ALSA),true)
  253. RTAUDIO_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSA__
  254. RTAUDIO_LIBS += $(shell pkg-config --libs alsa) -lpthread
  255. RTMIDI_FLAGS += $(shell pkg-config --cflags alsa) -D__LINUX_ALSASEQ__
  256. RTMIDI_LIBS += $(shell pkg-config --libs alsa)
  257. endif
  258. ifeq ($(HAVE_PULSEAUDIO),true)
  259. RTAUDIO_FLAGS += $(shell pkg-config --cflags libpulse-simple) -D__LINUX_PULSE__
  260. RTAUDIO_LIBS += $(shell pkg-config --libs libpulse-simple)
  261. endif
  262. endif
  263. ifeq ($(MACOS),true)
  264. DGL_LIBS = -framework OpenGL -framework Cocoa
  265. JACKBRIDGE_LIBS = -ldl -lpthread
  266. JUCE_AUDIO_BASICS_LIBS = -framework Accelerate
  267. JUCE_AUDIO_DEVICES_LIBS = -framework AudioToolbox -framework CoreAudio -framework CoreMIDI -framework DiscRecording
  268. JUCE_AUDIO_FORMATS_LIBS = -framework CoreAudio -framework CoreMIDI -framework QuartzCore -framework AudioToolbox
  269. JUCE_CORE_LIBS = -framework Cocoa -framework IOKit
  270. JUCE_GRAPHICS_LIBS = -framework Cocoa -framework QuartzCore
  271. JUCE_GUI_BASICS_LIBS = -framework Cocoa -framework Carbon -framework QuartzCore
  272. LILV_LIBS = -ldl -lm
  273. RTAUDIO_FLAGS += -D__MACOSX_CORE__
  274. RTAUDIO_LIBS += -lpthread
  275. RTMIDI_FLAGS += -D__MACOSX_CORE__
  276. endif
  277. ifeq ($(WIN32),true)
  278. DGL_LIBS = -lopengl32 -lgdi32
  279. JACKBRIDGE_LIBS = -lpthread
  280. JUCE_AUDIO_DEVICES_LIBS = -lwinmm -lole32
  281. JUCE_CORE_LIBS = -luuid -lwsock32 -lwininet -lversion -lole32 -lws2_32 -loleaut32 -limm32 -lcomdlg32 -lshlwapi -lrpcrt4 -lwinmm
  282. JUCE_EVENTS_LIBS = -lole32
  283. JUCE_GRAPHICS_LIBS = -lgdi32
  284. JUCE_GUI_BASICS_LIBS = -lgdi32 -limm32 -lcomdlg32 -lole32
  285. LILV_LIBS = -lm
  286. RTAUDIO_FLAGS += -D__WINDOWS_ASIO__ -D__WINDOWS_DS__
  287. RTAUDIO_LIBS += -ldsound -lpthread
  288. RTMIDI_FLAGS += -D__WINDOWS_MM__
  289. endif
  290. # --------------------------------------------------------------
  291. # Set libs stuff (part 3)
  292. NATIVE_PLUGINS_LIBS = $(AUDIO_DECODER_LIBS)
  293. NATIVE_PLUGINS_LIBS += $(DGL_LIBS)
  294. ifeq ($(HAVE_MF_DEPS),true)
  295. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs smf)
  296. endif
  297. ifeq ($(HAVE_ZYN_DEPS),true)
  298. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs fftw3 mxml zlib)
  299. ifeq ($(HAVE_ZYN_UI_DEPS),true)
  300. NATIVE_PLUGINS_LIBS += $(shell pkg-config --libs ntk_images ntk)
  301. endif
  302. endif
  303. # --------------------------------------------------------------
  304. # Set Qt tools
  305. ifeq ($(HAVE_QT4),true)
  306. MOC_QT4 ?= $(shell pkg-config --variable=moc_location QtCore)
  307. RCC_QT4 ?= $(shell pkg-config --variable=rcc_location QtCore)
  308. UIC_QT4 ?= $(shell pkg-config --variable=uic_location QtCore)
  309. endif
  310. ifeq ($(HAVE_QT5),true)
  311. MOC_QT5 ?= $(shell pkg-config --variable=libdir Qt5Core)/qt5/bin/moc
  312. RCC_QT5 ?= $(shell pkg-config --variable=libdir Qt5Core)/qt5/bin/rcc
  313. UIC_QT5 ?= $(shell pkg-config --variable=libdir Qt5Core)/qt5/bin/uic
  314. endif
  315. # --------------------------------------------------------------