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.

361 lines
9.4KB

  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. ifeq ($(USING_CUSTOM_DPF),true)
  154. BASE_FLAGS += -DDISTRHO_UI_FILE_BROWSER=0
  155. endif
  156. ifneq ($(DGL_NAMESPACE),)
  157. BASE_FLAGS += -DDGL_NAMESPACE=$(DGL_NAMESPACE)
  158. else
  159. BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL
  160. endif
  161. endif
  162. ifneq ($(USING_CUSTOM_DPF),true)
  163. BASE_FLAGS += -DDGL_FILE_BROWSER_DISABLED
  164. BASE_FLAGS += -DDGL_NO_SHARED_RESOURCES
  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 ($(HAVE_YSFX),true)
  202. BASE_FLAGS += -DHAVE_YSFX
  203. endif
  204. ifeq ($(USING_RTAUDIO),true)
  205. BASE_FLAGS += -DUSING_RTAUDIO
  206. endif
  207. ifeq ($(STATIC_PLUGIN_TARGET),true)
  208. BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
  209. endif
  210. # ---------------------------------------------------------------------------------------------------------------------
  211. # Allow custom namespace
  212. ifneq ($(CARLA_BACKEND_NAMESPACE),)
  213. BASE_FLAGS += -DCARLA_BACKEND_NAMESPACE=$(CARLA_BACKEND_NAMESPACE)
  214. endif
  215. # ---------------------------------------------------------------------------------------------------------------------
  216. # Set app extension
  217. ifeq ($(WASM),true)
  218. APP_EXT = .html
  219. else ifeq ($(WINDOWS),true)
  220. APP_EXT = .exe
  221. endif
  222. # ---------------------------------------------------------------------------------------------------------------------
  223. # Set shared lib extension
  224. ifeq ($(MACOS),true)
  225. LIB_EXT = .dylib
  226. else ifeq ($(WASM),true)
  227. LIB_EXT = .js
  228. else ifeq ($(WINDOWS),true)
  229. LIB_EXT = .dll
  230. else
  231. LIB_EXT = .so
  232. endif
  233. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  234. # ---------------------------------------------------------------------------------------------------------------------
  235. # Set static libs start & end
  236. ifneq ($(MACOS),true)
  237. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  238. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  239. endif
  240. # ---------------------------------------------------------------------------------------------------------------------
  241. # Handle the verbosity switch
  242. SILENT =
  243. ifeq ($(VERBOSE),1)
  244. else ifeq ($(VERBOSE),y)
  245. else ifeq ($(VERBOSE),yes)
  246. else ifeq ($(VERBOSE),true)
  247. else
  248. SILENT = @
  249. endif
  250. # ---------------------------------------------------------------------------------------------------------------------
  251. # Set shared library CLI arg
  252. ifeq ($(MACOS),true)
  253. SHARED = -dynamiclib
  254. else ifeq ($(WASM),true)
  255. SHARED = -sMAIN_MODULE=2
  256. else
  257. SHARED = -shared
  258. endif
  259. # ---------------------------------------------------------------------------------------------------------------------
  260. # Set arguments used for inline 'sed'
  261. ifeq ($(BSD),true)
  262. SED_ARGS=-i '' -e
  263. else
  264. SED_ARGS=-i -e
  265. endif
  266. # ---------------------------------------------------------------------------------------------------------------------
  267. # Set command used for file symlinking
  268. LINK := ln -sf
  269. # ---------------------------------------------------------------------------------------------------------------------
  270. # Check if we can generate ttl files
  271. ifneq ($(BUILDING_FOR_WINE),true)
  272. ifeq ($(CROSS_COMPILING),true)
  273. ifeq ($(WINDOWS),true)
  274. NEEDS_WINE = true
  275. endif
  276. endif
  277. endif
  278. ifneq ($(CROSS_COMPILING),true)
  279. CAN_GENERATE_LV2_TTL = true
  280. else ifeq ($(NEEDS_WINE),true)
  281. ifneq ($(EXE_WRAPPER),)
  282. CAN_GENERATE_LV2_TTL = true
  283. endif
  284. endif
  285. # ---------------------------------------------------------------------------------------------------------------------
  286. # Check if we should build the external plugins
  287. ifeq ($(EXTERNAL_PLUGINS),true)
  288. ifneq ($(DEBUG),true)
  289. ifneq ($(TESTBUILD),true)
  290. ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
  291. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  292. include $(CWD)/native-plugins/external/Makefile.mk
  293. endif
  294. endif
  295. endif
  296. endif
  297. # ---------------------------------------------------------------------------------------------------------------------