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.

Makefile.mk 13KB

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