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.

353 lines
9.1KB

  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_OR_WIN32),true)
  71. ifneq ($(BSD),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 += -DHAVE_OPENGL
  154. BASE_FLAGS += -DDGL_OPENGL
  155. BASE_FLAGS += -DDONT_SET_USING_DGL_NAMESPACE
  156. ifneq ($(USING_CUSTOM_DPF),true)
  157. BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL
  158. BASE_FLAGS += -DDGL_FILE_BROWSER_DISABLED
  159. BASE_FLAGS += -DDGL_NO_SHARED_RESOURCES
  160. else
  161. BASE_FLAGS += -DDISTRHO_UI_FILE_BROWSER=0
  162. endif
  163. endif
  164. ifeq ($(HAVE_FLUIDSYNTH),true)
  165. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  166. ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
  167. BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
  168. endif
  169. endif
  170. ifeq ($(HAVE_FFMPEG),true)
  171. BASE_FLAGS += -DHAVE_FFMPEG
  172. endif
  173. ifeq ($(HAVE_HYLIA),true)
  174. BASE_FLAGS += -DHAVE_HYLIA
  175. endif
  176. ifeq ($(HAVE_LIBLO),true)
  177. BASE_FLAGS += -DHAVE_LIBLO
  178. endif
  179. ifeq ($(HAVE_LIBMAGIC),true)
  180. BASE_FLAGS += -DHAVE_LIBMAGIC
  181. endif
  182. ifeq ($(HAVE_PYQT),true)
  183. BASE_FLAGS += -DHAVE_PYQT
  184. endif
  185. ifeq ($(HAVE_SNDFILE),true)
  186. BASE_FLAGS += -DHAVE_SNDFILE
  187. endif
  188. ifeq ($(HAVE_X11),true)
  189. BASE_FLAGS += -DHAVE_X11
  190. endif
  191. ifeq ($(USING_JUCE),true)
  192. BASE_FLAGS += -DUSING_JUCE
  193. BASE_FLAGS += -DJUCE_APP_CONFIG_HEADER='"AppConfig.h"'
  194. ifeq ($(WIN32),true)
  195. BASE_FLAGS += -D_WIN32_WINNT=0x0600
  196. endif
  197. endif
  198. ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
  199. BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
  200. endif
  201. ifeq ($(USING_RTAUDIO),true)
  202. BASE_FLAGS += -DUSING_RTAUDIO
  203. endif
  204. ifeq ($(STATIC_PLUGIN_TARGET),true)
  205. BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
  206. endif
  207. # ---------------------------------------------------------------------------------------------------------------------
  208. # Allow custom namespace
  209. ifneq ($(CARLA_BACKEND_NAMESPACE),)
  210. BASE_FLAGS += -DCARLA_BACKEND_NAMESPACE=$(CARLA_BACKEND_NAMESPACE)
  211. endif
  212. # ---------------------------------------------------------------------------------------------------------------------
  213. # Set app extension
  214. ifeq ($(WIN32),true)
  215. APP_EXT = .exe
  216. endif
  217. # ---------------------------------------------------------------------------------------------------------------------
  218. # Set shared lib extension
  219. LIB_EXT = .so
  220. ifeq ($(MACOS),true)
  221. LIB_EXT = .dylib
  222. endif
  223. ifeq ($(WIN32),true)
  224. LIB_EXT = .dll
  225. endif
  226. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  227. # ---------------------------------------------------------------------------------------------------------------------
  228. # Set static libs start & end
  229. ifneq ($(MACOS),true)
  230. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  231. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  232. endif
  233. # ---------------------------------------------------------------------------------------------------------------------
  234. # Handle the verbosity switch
  235. SILENT =
  236. ifeq ($(VERBOSE),1)
  237. else ifeq ($(VERBOSE),y)
  238. else ifeq ($(VERBOSE),yes)
  239. else ifeq ($(VERBOSE),true)
  240. else
  241. SILENT = @
  242. endif
  243. # ---------------------------------------------------------------------------------------------------------------------
  244. # Set shared library CLI arg
  245. ifeq ($(MACOS),true)
  246. SHARED = -dynamiclib
  247. else
  248. SHARED = -shared
  249. endif
  250. # ---------------------------------------------------------------------------------------------------------------------
  251. # Set arguments used for inline 'sed'
  252. ifeq ($(BSD),true)
  253. SED_ARGS=-i '' -e
  254. else
  255. SED_ARGS=-i -e
  256. endif
  257. # ---------------------------------------------------------------------------------------------------------------------
  258. # Set command used for file symlinking
  259. LINK := ln -sf
  260. # ---------------------------------------------------------------------------------------------------------------------
  261. # Check if we can generate ttl files
  262. ifneq ($(BUILDING_FOR_WINE),true)
  263. ifeq ($(CROSS_COMPILING),true)
  264. ifeq ($(WIN32),true)
  265. NEEDS_WINE = true
  266. endif
  267. endif
  268. endif
  269. ifneq ($(CROSS_COMPILING),true)
  270. CAN_GENERATE_LV2_TTL = true
  271. else ifeq ($(NEEDS_WINE),true)
  272. CAN_GENERATE_LV2_TTL = true
  273. endif
  274. # ---------------------------------------------------------------------------------------------------------------------
  275. # Check if we should build the external plugins
  276. ifeq ($(EXTERNAL_PLUGINS),true)
  277. ifneq ($(DEBUG),true)
  278. ifneq ($(TESTBUILD),true)
  279. ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
  280. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  281. include $(CWD)/native-plugins/external/Makefile.mk
  282. endif
  283. endif
  284. endif
  285. endif
  286. # ---------------------------------------------------------------------------------------------------------------------