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.

370 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. ifeq ($(WASM),true)
  72. LINK_OPTS += -sASSERTIONS=1
  73. endif
  74. else
  75. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  76. CXXFLAGS += -fvisibility-inlines-hidden
  77. endif
  78. ifneq ($(MACOS_OR_WASM_OR_WINDOWS),true)
  79. ifneq ($(BSD),true)
  80. BASE_FLAGS += -fno-gnu-unique
  81. endif
  82. endif
  83. ifeq ($(WITH_LTO),true)
  84. BASE_FLAGS += -fno-strict-aliasing -flto
  85. LINK_OPTS += -fno-strict-aliasing -flto -Werror=odr -Werror=lto-type-mismatch
  86. endif
  87. 32BIT_FLAGS = -m32
  88. 64BIT_FLAGS = -m64
  89. ARM32_FLAGS = -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad
  90. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  91. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
  92. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  93. ifeq ($(WASM),true)
  94. # Special flag for emscripten
  95. LINK_FLAGS += -sLLD_REPORT_UNDEFINED
  96. else ifneq ($(MACOS),true)
  97. # Not available on MacOS
  98. LINK_FLAGS += -Wl,--no-undefined
  99. endif
  100. ifeq ($(STATIC_BINARIES),true)
  101. LINK_FLAGS += -static
  102. endif
  103. # ---------------------------------------------------------------------------------------------------------------------
  104. # Strict test build
  105. ifeq ($(TESTBUILD),true)
  106. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wdisabled-optimization
  107. BASE_FLAGS += -Wdouble-promotion -Wfloat-equal -Wpointer-arith -Wsign-conversion
  108. BASE_FLAGS += -Wformat=2 -Woverlength-strings
  109. BASE_FLAGS += -Wmissing-declarations -Wredundant-decls
  110. BASE_FLAGS += -Wshadow -Wundef -Wuninitialized -Wunused
  111. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  112. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  113. BASE_FLAGS += -Wnull-dereference
  114. ifneq ($(CLANG),true)
  115. BASE_FLAGS += -Wabi=98 -Wclobbered -Wlogical-op
  116. BASE_FLAGS += -Wformat-truncation=2 -Wformat-overflow=2
  117. BASE_FLAGS += -Wstringop-overflow=4 -Wstringop-truncation
  118. BASE_FLAGS += -Wduplicated-branches -Wduplicated-cond
  119. endif
  120. CFLAGS += -Winit-self -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wwrite-strings
  121. ifneq ($(CLANG),true)
  122. CFLAGS += -Wjump-misses-init
  123. endif
  124. CXXFLAGS += -Wc++0x-compat -Wc++11-compat
  125. CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
  126. # CXXFLAGS += -Wold-style-cast -Wuseless-cast
  127. CXXFLAGS += -Wzero-as-null-pointer-constant
  128. ifneq ($(DEBUG),true)
  129. CXXFLAGS += -Weffc++
  130. endif
  131. ifeq ($(LINUX),true)
  132. BASE_FLAGS += -isystem /opt/kxstudio/include
  133. endif
  134. ifeq ($(MACOS),true)
  135. CXXFLAGS += -isystem /System/Library/Frameworks
  136. endif
  137. # TODO
  138. ifeq ($(CLANG),true)
  139. BASE_FLAGS += -Wno-double-promotion
  140. BASE_FLAGS += -Wno-format-nonliteral
  141. BASE_FLAGS += -Wno-tautological-pointer-compare
  142. endif
  143. endif
  144. # ---------------------------------------------------------------------------------------------------------------------
  145. # Set base defines
  146. ifeq ($(JACKBRIDGE_DIRECT),true)
  147. ifeq ($(HAVE_JACKLIB),true)
  148. BASE_FLAGS += -DJACKBRIDGE_DIRECT
  149. else
  150. $(error jackbridge direct mode requested, but jack not available)
  151. endif
  152. endif
  153. ifeq ($(HAVE_DGL),true)
  154. BASE_FLAGS += -DHAVE_DGL
  155. BASE_FLAGS += -DHAVE_OPENGL
  156. BASE_FLAGS += -DDGL_OPENGL
  157. BASE_FLAGS += -DDONT_SET_USING_DGL_NAMESPACE
  158. ifneq ($(USING_CUSTOM_DPF),true)
  159. BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL
  160. BASE_FLAGS += -DDGL_FILE_BROWSER_DISABLED
  161. BASE_FLAGS += -DDGL_NO_SHARED_RESOURCES
  162. else
  163. BASE_FLAGS += -DDISTRHO_UI_FILE_BROWSER=0
  164. ifneq ($(DGL_NAMESPACE),)
  165. BASE_FLAGS += -DDGL_NAMESPACE=$(DGL_NAMESPACE)
  166. endif
  167. endif
  168. endif
  169. ifeq ($(HAVE_FLUIDSYNTH),true)
  170. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  171. ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
  172. BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
  173. endif
  174. endif
  175. ifeq ($(HAVE_FFMPEG),true)
  176. BASE_FLAGS += -DHAVE_FFMPEG
  177. endif
  178. ifeq ($(HAVE_HYLIA),true)
  179. BASE_FLAGS += -DHAVE_HYLIA
  180. endif
  181. ifeq ($(HAVE_JACK),true)
  182. BASE_FLAGS += -DHAVE_JACK
  183. endif
  184. ifeq ($(HAVE_LIBLO),true)
  185. BASE_FLAGS += -DHAVE_LIBLO
  186. endif
  187. ifeq ($(HAVE_LIBMAGIC),true)
  188. BASE_FLAGS += -DHAVE_LIBMAGIC
  189. endif
  190. ifeq ($(HAVE_PYQT),true)
  191. BASE_FLAGS += -DHAVE_PYQT
  192. endif
  193. ifeq ($(HAVE_SDL2),true)
  194. BASE_FLAGS += -DHAVE_SDL -DHAVE_SDL2
  195. else ifeq ($(HAVE_SDL1),true)
  196. BASE_FLAGS += -DHAVE_SDL -DHAVE_SDL1
  197. endif
  198. ifeq ($(HAVE_SNDFILE),true)
  199. BASE_FLAGS += -DHAVE_SNDFILE
  200. endif
  201. ifeq ($(HAVE_X11),true)
  202. BASE_FLAGS += -DHAVE_X11
  203. endif
  204. ifeq ($(USING_JUCE),true)
  205. BASE_FLAGS += -DUSING_JUCE
  206. BASE_FLAGS += -DJUCE_APP_CONFIG_HEADER='"AppConfig.h"'
  207. ifeq ($(WINDOWS),true)
  208. BASE_FLAGS += -D_WIN32_WINNT=0x0600
  209. endif
  210. endif
  211. ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
  212. BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
  213. endif
  214. ifeq ($(USING_RTAUDIO),true)
  215. BASE_FLAGS += -DUSING_RTAUDIO
  216. endif
  217. ifeq ($(STATIC_PLUGIN_TARGET),true)
  218. BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
  219. endif
  220. # ---------------------------------------------------------------------------------------------------------------------
  221. # Allow custom namespace
  222. ifneq ($(CARLA_BACKEND_NAMESPACE),)
  223. BASE_FLAGS += -DCARLA_BACKEND_NAMESPACE=$(CARLA_BACKEND_NAMESPACE)
  224. endif
  225. # ---------------------------------------------------------------------------------------------------------------------
  226. # Set app extension
  227. ifeq ($(WASM),true)
  228. APP_EXT = .html
  229. else ifeq ($(WINDOWS),true)
  230. APP_EXT = .exe
  231. endif
  232. # ---------------------------------------------------------------------------------------------------------------------
  233. # Set shared lib extension
  234. ifeq ($(MACOS),true)
  235. LIB_EXT = .dylib
  236. else ifeq ($(WASM),true)
  237. LIB_EXT = .wasm
  238. else ifeq ($(WINDOWS),true)
  239. LIB_EXT = .dll
  240. else
  241. LIB_EXT = .so
  242. endif
  243. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  244. # ---------------------------------------------------------------------------------------------------------------------
  245. # Set static libs start & end
  246. ifneq ($(MACOS),true)
  247. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  248. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  249. endif
  250. # ---------------------------------------------------------------------------------------------------------------------
  251. # Handle the verbosity switch
  252. SILENT =
  253. ifeq ($(VERBOSE),1)
  254. else ifeq ($(VERBOSE),y)
  255. else ifeq ($(VERBOSE),yes)
  256. else ifeq ($(VERBOSE),true)
  257. else
  258. SILENT = @
  259. endif
  260. # ---------------------------------------------------------------------------------------------------------------------
  261. # Set shared library CLI arg
  262. ifeq ($(MACOS),true)
  263. SHARED = -dynamiclib
  264. else ifeq ($(WASM),true)
  265. SHARED = -sSIDE_MODULE=1
  266. else
  267. SHARED = -shared
  268. endif
  269. # ---------------------------------------------------------------------------------------------------------------------
  270. # Set arguments used for inline 'sed'
  271. ifeq ($(BSD),true)
  272. SED_ARGS=-i '' -e
  273. else
  274. SED_ARGS=-i -e
  275. endif
  276. # ---------------------------------------------------------------------------------------------------------------------
  277. # Set command used for file symlinking
  278. LINK := ln -sf
  279. # ---------------------------------------------------------------------------------------------------------------------
  280. # Check if we can generate ttl files
  281. ifneq ($(BUILDING_FOR_WINE),true)
  282. ifeq ($(CROSS_COMPILING),true)
  283. ifeq ($(WINDOWS),true)
  284. NEEDS_WINE = true
  285. endif
  286. endif
  287. endif
  288. ifneq ($(CROSS_COMPILING),true)
  289. CAN_GENERATE_LV2_TTL = true
  290. else ifeq ($(NEEDS_WINE),true)
  291. CAN_GENERATE_LV2_TTL = true
  292. endif
  293. # ---------------------------------------------------------------------------------------------------------------------
  294. # Check if we should build the external plugins
  295. ifeq ($(EXTERNAL_PLUGINS),true)
  296. ifneq ($(DEBUG),true)
  297. ifneq ($(TESTBUILD),true)
  298. ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
  299. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  300. include $(CWD)/native-plugins/external/Makefile.mk
  301. endif
  302. endif
  303. endif
  304. endif
  305. # ---------------------------------------------------------------------------------------------------------------------