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.

359 lines
9.3KB

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