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.

367 lines
9.5KB

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