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.

366 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 -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_NAMESPACE=CarlaDGL
  155. BASE_FLAGS += -DDGL_FILE_BROWSER_DISABLED
  156. BASE_FLAGS += -DDGL_NO_SHARED_RESOURCES
  157. else
  158. BASE_FLAGS += -DDISTRHO_UI_FILE_BROWSER=0
  159. ifneq ($(DGL_NAMESPACE),)
  160. BASE_FLAGS += -DDGL_NAMESPACE=$(DGL_NAMESPACE)
  161. endif
  162. endif
  163. endif
  164. ifeq ($(HAVE_FLUIDSYNTH),true)
  165. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  166. ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
  167. BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
  168. endif
  169. endif
  170. ifeq ($(HAVE_FFMPEG),true)
  171. BASE_FLAGS += -DHAVE_FFMPEG
  172. endif
  173. ifeq ($(HAVE_HYLIA),true)
  174. BASE_FLAGS += -DHAVE_HYLIA
  175. endif
  176. ifeq ($(HAVE_JACK),true)
  177. BASE_FLAGS += -DHAVE_JACK
  178. endif
  179. ifeq ($(HAVE_LIBLO),true)
  180. BASE_FLAGS += -DHAVE_LIBLO
  181. endif
  182. ifeq ($(HAVE_LIBMAGIC),true)
  183. BASE_FLAGS += -DHAVE_LIBMAGIC
  184. endif
  185. ifeq ($(HAVE_PYQT),true)
  186. BASE_FLAGS += -DHAVE_PYQT
  187. endif
  188. ifeq ($(HAVE_SDL2),true)
  189. BASE_FLAGS += -DHAVE_SDL -DHAVE_SDL2
  190. else ifeq ($(HAVE_SDL1),true)
  191. BASE_FLAGS += -DHAVE_SDL -DHAVE_SDL1
  192. endif
  193. ifeq ($(HAVE_SNDFILE),true)
  194. BASE_FLAGS += -DHAVE_SNDFILE
  195. endif
  196. ifeq ($(HAVE_X11),true)
  197. BASE_FLAGS += -DHAVE_X11
  198. endif
  199. ifeq ($(USING_JUCE),true)
  200. BASE_FLAGS += -DUSING_JUCE
  201. BASE_FLAGS += -DJUCE_APP_CONFIG_HEADER='"AppConfig.h"'
  202. ifeq ($(WINDOWS),true)
  203. BASE_FLAGS += -D_WIN32_WINNT=0x0600
  204. endif
  205. endif
  206. ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
  207. BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
  208. endif
  209. ifeq ($(USING_RTAUDIO),true)
  210. BASE_FLAGS += -DUSING_RTAUDIO
  211. endif
  212. ifeq ($(STATIC_PLUGIN_TARGET),true)
  213. BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
  214. endif
  215. # ---------------------------------------------------------------------------------------------------------------------
  216. # Allow custom namespace
  217. ifneq ($(CARLA_BACKEND_NAMESPACE),)
  218. BASE_FLAGS += -DCARLA_BACKEND_NAMESPACE=$(CARLA_BACKEND_NAMESPACE)
  219. endif
  220. # ---------------------------------------------------------------------------------------------------------------------
  221. # Set app extension
  222. ifeq ($(WASM),true)
  223. APP_EXT = .html
  224. else ifeq ($(WINDOWS),true)
  225. APP_EXT = .exe
  226. endif
  227. # ---------------------------------------------------------------------------------------------------------------------
  228. # Set shared lib extension
  229. ifeq ($(MACOS),true)
  230. LIB_EXT = .dylib
  231. else ifeq ($(WASM),true)
  232. LIB_EXT = .wasm
  233. else ifeq ($(WINDOWS),true)
  234. LIB_EXT = .dll
  235. else
  236. LIB_EXT = .so
  237. endif
  238. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  239. # ---------------------------------------------------------------------------------------------------------------------
  240. # Set static libs start & end
  241. ifneq ($(MACOS),true)
  242. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  243. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  244. endif
  245. # ---------------------------------------------------------------------------------------------------------------------
  246. # Handle the verbosity switch
  247. SILENT =
  248. ifeq ($(VERBOSE),1)
  249. else ifeq ($(VERBOSE),y)
  250. else ifeq ($(VERBOSE),yes)
  251. else ifeq ($(VERBOSE),true)
  252. else
  253. SILENT = @
  254. endif
  255. # ---------------------------------------------------------------------------------------------------------------------
  256. # Set shared library CLI arg
  257. ifeq ($(MACOS),true)
  258. SHARED = -dynamiclib
  259. else ifeq ($(WASM),true)
  260. SHARED = -sSIDE_MODULE=1
  261. else
  262. SHARED = -shared
  263. endif
  264. # ---------------------------------------------------------------------------------------------------------------------
  265. # Set arguments used for inline 'sed'
  266. ifeq ($(BSD),true)
  267. SED_ARGS=-i '' -e
  268. else
  269. SED_ARGS=-i -e
  270. endif
  271. # ---------------------------------------------------------------------------------------------------------------------
  272. # Set command used for file symlinking
  273. LINK := ln -sf
  274. # ---------------------------------------------------------------------------------------------------------------------
  275. # Check if we can generate ttl files
  276. ifneq ($(BUILDING_FOR_WINE),true)
  277. ifeq ($(CROSS_COMPILING),true)
  278. ifeq ($(WINDOWS),true)
  279. NEEDS_WINE = true
  280. endif
  281. endif
  282. endif
  283. ifneq ($(CROSS_COMPILING),true)
  284. CAN_GENERATE_LV2_TTL = true
  285. else ifeq ($(NEEDS_WINE),true)
  286. ifneq ($(EXE_WRAPPER),)
  287. CAN_GENERATE_LV2_TTL = true
  288. endif
  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. # ---------------------------------------------------------------------------------------------------------------------