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.

348 lines
9.0KB

  1. #!/usr/bin/make -f
  2. # Makefile for Carla C++ code #
  3. # --------------------------- #
  4. # Created by falkTX
  5. #
  6. # ---------------------------------------------------------------------------------------------------------------------
  7. # Base environment vars
  8. AR ?= ar
  9. CC ?= gcc
  10. CXX ?= g++
  11. WINECC ?= winegcc
  12. # ---------------------------------------------------------------------------------------------------------------------
  13. # Internationalization
  14. I18N_LANGUAGES :=
  15. # ---------------------------------------------------------------------------------------------------------------------
  16. # Base definitions for dependencies and system type
  17. include $(CWD)/Makefile.deps.mk
  18. # ---------------------------------------------------------------------------------------------------------------------
  19. # Set build and link flags
  20. BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MD -MP -fno-common
  21. BASE_OPTS = -O3 -ffast-math -fdata-sections -ffunction-sections
  22. ifeq ($(CPU_I386_OR_X86_64),true)
  23. BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse
  24. endif
  25. ifeq ($(CPU_ARM),true)
  26. ifneq ($(CPU_ARM64),true)
  27. BASE_OPTS += -mfpu=neon-vfpv4 -mfloat-abi=hard
  28. endif
  29. endif
  30. ifeq ($(MACOS),true)
  31. # MacOS linker flags
  32. BASE_FLAGS += -Wno-deprecated-declarations
  33. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  34. ifneq ($(SKIP_STRIPPING),true)
  35. LINK_OPTS += -Wl,-x
  36. endif
  37. else
  38. # Common linker flags
  39. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed
  40. ifneq ($(SKIP_STRIPPING),true)
  41. LINK_OPTS += -Wl,--strip-all
  42. endif
  43. endif
  44. ifeq ($(NOOPT),true)
  45. # No CPU-specific optimization flags
  46. BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections -DBUILDING_CARLA_NOOPT
  47. endif
  48. ifeq ($(WIN32),true)
  49. # Assume we want posix
  50. BASE_FLAGS += -posix
  51. # Needed for windows, see https://github.com/falkTX/Carla/issues/855
  52. BASE_FLAGS += -mstackrealign
  53. ifeq ($(BUILDING_FOR_WINE),true)
  54. BASE_FLAGS += -DBUILDING_CARLA_FOR_WINE
  55. endif
  56. else
  57. # Not needed for Windows
  58. BASE_FLAGS += -fPIC -DPIC
  59. endif
  60. ifeq ($(CLANG),true)
  61. BASE_FLAGS += -Wabsolute-value
  62. endif
  63. ifeq ($(DEBUG),true)
  64. BASE_FLAGS += -DDEBUG -O0 -g
  65. LINK_OPTS =
  66. else
  67. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  68. CXXFLAGS += -fvisibility-inlines-hidden
  69. endif
  70. ifneq ($(MACOS),true)
  71. ifneq ($(WIN32),true)
  72. BASE_FLAGS += -fno-gnu-unique
  73. endif
  74. endif
  75. ifeq ($(WITH_LTO),true)
  76. BASE_FLAGS += -fno-strict-aliasing -flto
  77. LINK_OPTS += -fno-strict-aliasing -flto -Werror=odr -Werror=lto-type-mismatch
  78. endif
  79. 32BIT_FLAGS = -m32
  80. 64BIT_FLAGS = -m64
  81. ARM32_FLAGS = -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad
  82. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  83. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
  84. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  85. ifneq ($(MACOS),true)
  86. # Not available on MacOS
  87. LINK_FLAGS += -Wl,--no-undefined
  88. endif
  89. ifeq ($(MACOS_OLD),true)
  90. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
  91. endif
  92. ifeq ($(STATIC_BINARIES),true)
  93. LINK_FLAGS += -static
  94. endif
  95. # ---------------------------------------------------------------------------------------------------------------------
  96. # Strict test build
  97. ifeq ($(TESTBUILD),true)
  98. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wdisabled-optimization
  99. BASE_FLAGS += -Wdouble-promotion -Wfloat-equal -Wpointer-arith -Wsign-conversion
  100. BASE_FLAGS += -Wformat=2 -Woverlength-strings
  101. BASE_FLAGS += -Wmissing-declarations -Wredundant-decls
  102. BASE_FLAGS += -Wshadow -Wundef -Wuninitialized -Wunused
  103. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  104. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  105. BASE_FLAGS += -Wnull-dereference
  106. ifneq ($(CLANG),true)
  107. BASE_FLAGS += -Wabi=98 -Wclobbered -Wlogical-op
  108. BASE_FLAGS += -Wformat-truncation=2 -Wformat-overflow=2
  109. BASE_FLAGS += -Wstringop-overflow=4 -Wstringop-truncation
  110. BASE_FLAGS += -Wduplicated-branches -Wduplicated-cond
  111. endif
  112. CFLAGS += -Winit-self -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wwrite-strings
  113. ifneq ($(CLANG),true)
  114. CFLAGS += -Wjump-misses-init
  115. endif
  116. CXXFLAGS += -Wc++0x-compat -Wc++11-compat
  117. CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
  118. # CXXFLAGS += -Wold-style-cast -Wuseless-cast
  119. CXXFLAGS += -Wzero-as-null-pointer-constant
  120. ifneq ($(DEBUG),true)
  121. CXXFLAGS += -Weffc++
  122. endif
  123. ifeq ($(LINUX),true)
  124. BASE_FLAGS += -isystem /opt/kxstudio/include
  125. endif
  126. ifeq ($(MACOS),true)
  127. CXXFLAGS += -isystem /System/Library/Frameworks
  128. endif
  129. ifeq ($(WIN32),true)
  130. BASE_FLAGS += -isystem /opt/mingw32/include
  131. endif
  132. ifeq ($(WIN64),true)
  133. BASE_FLAGS += -isystem /opt/mingw64/include
  134. endif
  135. # TODO
  136. ifeq ($(CLANG),true)
  137. BASE_FLAGS += -Wno-double-promotion
  138. BASE_FLAGS += -Wno-format-nonliteral
  139. BASE_FLAGS += -Wno-tautological-pointer-compare
  140. endif
  141. endif
  142. # ---------------------------------------------------------------------------------------------------------------------
  143. # Set base defines
  144. ifeq ($(JACKBRIDGE_DIRECT),true)
  145. ifeq ($(HAVE_JACK),true)
  146. BASE_FLAGS += -DJACKBRIDGE_DIRECT
  147. else
  148. $(error jackbridge direct mode requested, but jack not available)
  149. endif
  150. endif
  151. ifeq ($(HAVE_DGL),true)
  152. BASE_FLAGS += -DHAVE_DGL
  153. BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL
  154. BASE_FLAGS += -DDGL_OPENGL
  155. BASE_FLAGS += -DDGL_FILE_BROWSER_DISABLED
  156. BASE_FLAGS += -DDGL_NO_SHARED_RESOURCES
  157. BASE_FLAGS += -DDONT_SET_USING_DGL_NAMESPACE
  158. endif
  159. ifeq ($(HAVE_FLUIDSYNTH),true)
  160. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  161. ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
  162. BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
  163. endif
  164. endif
  165. ifeq ($(HAVE_FFMPEG),true)
  166. BASE_FLAGS += -DHAVE_FFMPEG
  167. endif
  168. ifeq ($(HAVE_HYLIA),true)
  169. BASE_FLAGS += -DHAVE_HYLIA
  170. endif
  171. ifeq ($(HAVE_LIBLO),true)
  172. BASE_FLAGS += -DHAVE_LIBLO
  173. endif
  174. ifeq ($(HAVE_LIBMAGIC),true)
  175. BASE_FLAGS += -DHAVE_LIBMAGIC
  176. endif
  177. ifeq ($(HAVE_PYQT),true)
  178. BASE_FLAGS += -DHAVE_PYQT
  179. endif
  180. ifeq ($(HAVE_SNDFILE),true)
  181. BASE_FLAGS += -DHAVE_SNDFILE
  182. endif
  183. ifeq ($(HAVE_X11),true)
  184. BASE_FLAGS += -DHAVE_X11
  185. endif
  186. ifeq ($(USING_JUCE),true)
  187. BASE_FLAGS += -DUSING_JUCE
  188. BASE_FLAGS += -DJUCE_APP_CONFIG_HEADER='"AppConfig.h"'
  189. ifeq ($(WIN32),true)
  190. BASE_FLAGS += -D_WIN32_WINNT=0x0600
  191. endif
  192. endif
  193. ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
  194. BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
  195. endif
  196. ifeq ($(USING_RTAUDIO),true)
  197. BASE_FLAGS += -DUSING_RTAUDIO
  198. endif
  199. ifeq ($(STATIC_PLUGIN_TARGET),true)
  200. BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
  201. endif
  202. # ---------------------------------------------------------------------------------------------------------------------
  203. # Allow custom namespace
  204. ifneq ($(CARLA_BACKEND_NAMESPACE),)
  205. BASE_FLAGS += -DCARLA_BACKEND_NAMESPACE=$(CARLA_BACKEND_NAMESPACE)
  206. endif
  207. # ---------------------------------------------------------------------------------------------------------------------
  208. # Set app extension
  209. ifeq ($(WIN32),true)
  210. APP_EXT = .exe
  211. endif
  212. # ---------------------------------------------------------------------------------------------------------------------
  213. # Set shared lib extension
  214. LIB_EXT = .so
  215. ifeq ($(MACOS),true)
  216. LIB_EXT = .dylib
  217. endif
  218. ifeq ($(WIN32),true)
  219. LIB_EXT = .dll
  220. endif
  221. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  222. # ---------------------------------------------------------------------------------------------------------------------
  223. # Set static libs start & end
  224. ifneq ($(MACOS),true)
  225. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  226. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  227. endif
  228. # ---------------------------------------------------------------------------------------------------------------------
  229. # Handle the verbosity switch
  230. SILENT =
  231. ifeq ($(VERBOSE),1)
  232. else ifeq ($(VERBOSE),y)
  233. else ifeq ($(VERBOSE),yes)
  234. else ifeq ($(VERBOSE),true)
  235. else
  236. SILENT = @
  237. endif
  238. # ---------------------------------------------------------------------------------------------------------------------
  239. # Set shared library CLI arg
  240. ifeq ($(MACOS),true)
  241. SHARED = -dynamiclib
  242. else
  243. SHARED = -shared
  244. endif
  245. # ---------------------------------------------------------------------------------------------------------------------
  246. # Set arguments used for inline 'sed'
  247. ifeq ($(BSD),true)
  248. SED_ARGS=-i '' -e
  249. else
  250. SED_ARGS=-i -e
  251. endif
  252. # ---------------------------------------------------------------------------------------------------------------------
  253. # Set command used for file symlinking
  254. LINK := ln -sf
  255. # ---------------------------------------------------------------------------------------------------------------------
  256. # Check if we can generate ttl files
  257. ifneq ($(BUILDING_FOR_WINE),true)
  258. ifeq ($(CROSS_COMPILING),true)
  259. ifeq ($(WIN32),true)
  260. NEEDS_WINE = true
  261. endif
  262. endif
  263. endif
  264. ifneq ($(CROSS_COMPILING),true)
  265. CAN_GENERATE_LV2_TTL = true
  266. else ifeq ($(NEEDS_WINE),true)
  267. CAN_GENERATE_LV2_TTL = true
  268. endif
  269. # ---------------------------------------------------------------------------------------------------------------------
  270. # Check if we should build the external plugins
  271. ifeq ($(EXTERNAL_PLUGINS),true)
  272. ifneq ($(DEBUG),true)
  273. ifneq ($(TESTBUILD),true)
  274. ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
  275. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  276. include $(CWD)/native-plugins/external/Makefile.mk
  277. endif
  278. endif
  279. endif
  280. endif
  281. # ---------------------------------------------------------------------------------------------------------------------