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.

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