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.

373 lines
9.6KB

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