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.

324 lines
8.4KB

  1. #!/usr/bin/make -f
  2. # Makefile for Carla C++ code #
  3. # --------------------------- #
  4. # Created by falkTX
  5. #
  6. # ---------------------------------------------------------------------------------------------------------------------
  7. # Base environment vars
  8. AR ?= ar
  9. CC ?= gcc
  10. CXX ?= g++
  11. WINECC ?= winegcc
  12. # ---------------------------------------------------------------------------------------------------------------------
  13. # Internationalization
  14. I18N_LANGUAGES :=
  15. # ---------------------------------------------------------------------------------------------------------------------
  16. # Base definitions for dependencies and system type
  17. include $(CWD)/Makefile.deps.mk
  18. # ---------------------------------------------------------------------------------------------------------------------
  19. # Set build and link flags
  20. BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MD -MP -fno-common
  21. BASE_OPTS = -O3 -ffast-math -fdata-sections -ffunction-sections
  22. ifeq ($(CPU_I386_OR_X86_64),true)
  23. BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse
  24. endif
  25. ifeq ($(CPU_ARM),true)
  26. ifneq ($(CPU_ARM64),true)
  27. BASE_OPTS += -mfpu=neon-vfpv4 -mfloat-abi=hard
  28. endif
  29. endif
  30. ifeq ($(MACOS),true)
  31. # MacOS linker flags
  32. BASE_FLAGS += -Wno-deprecated-declarations
  33. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  34. ifneq ($(SKIP_STRIPPING),true)
  35. LINK_OPTS += -Wl,-x
  36. endif
  37. else
  38. # Common linker flags
  39. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed
  40. ifneq ($(SKIP_STRIPPING),true)
  41. LINK_OPTS += -Wl,--strip-all
  42. endif
  43. endif
  44. ifeq ($(NOOPT),true)
  45. # No CPU-specific optimization flags
  46. BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections -DBUILDING_CARLA_NOOPT
  47. endif
  48. ifeq ($(WIN32),true)
  49. # Assume we want posix
  50. BASE_FLAGS += -posix
  51. # Needed for windows, see https://github.com/falkTX/Carla/issues/855
  52. BASE_FLAGS += -mstackrealign
  53. ifeq ($(BUILDING_FOR_WINE),true)
  54. BASE_FLAGS += -DBUILDING_CARLA_FOR_WINE
  55. endif
  56. else
  57. # Not needed for Windows
  58. BASE_FLAGS += -fPIC -DPIC
  59. endif
  60. ifeq ($(CLANG),true)
  61. BASE_FLAGS += -Wabsolute-value
  62. endif
  63. ifeq ($(DEBUG),true)
  64. BASE_FLAGS += -DDEBUG -O0 -g
  65. LINK_OPTS =
  66. else
  67. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  68. CXXFLAGS += -fvisibility-inlines-hidden
  69. endif
  70. ifeq ($(WITH_LTO),true)
  71. BASE_FLAGS += -fno-strict-aliasing -flto
  72. endif
  73. 32BIT_FLAGS = -m32
  74. 64BIT_FLAGS = -m64
  75. ARM32_FLAGS = -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad
  76. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  77. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
  78. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  79. ifneq ($(MACOS),true)
  80. # Not available on MacOS
  81. LINK_FLAGS += -Wl,--no-undefined
  82. endif
  83. ifeq ($(MACOS_OLD),true)
  84. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
  85. endif
  86. ifeq ($(STATIC_BINARIES),true)
  87. LINK_FLAGS += -static
  88. endif
  89. # ---------------------------------------------------------------------------------------------------------------------
  90. # Strict test build
  91. ifeq ($(TESTBUILD),true)
  92. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wdisabled-optimization
  93. BASE_FLAGS += -Wdouble-promotion -Wfloat-equal -Wpointer-arith -Wsign-conversion
  94. BASE_FLAGS += -Wformat=2 -Woverlength-strings
  95. BASE_FLAGS += -Wmissing-declarations -Wredundant-decls
  96. BASE_FLAGS += -Wshadow -Wundef -Wuninitialized -Wunused
  97. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  98. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  99. BASE_FLAGS += -Wnull-dereference
  100. ifneq ($(CLANG),true)
  101. BASE_FLAGS += -Wabi=98 -Wclobbered -Wlogical-op
  102. BASE_FLAGS += -Wformat-truncation=2 -Wformat-overflow=2
  103. BASE_FLAGS += -Wstringop-overflow=4 -Wstringop-truncation
  104. BASE_FLAGS += -Wduplicated-branches -Wduplicated-cond
  105. endif
  106. CFLAGS += -Winit-self -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wwrite-strings
  107. ifneq ($(CLANG),true)
  108. CFLAGS += -Wjump-misses-init
  109. endif
  110. CXXFLAGS += -Wc++0x-compat -Wc++11-compat
  111. CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
  112. # CXXFLAGS += -Wold-style-cast -Wuseless-cast
  113. CXXFLAGS += -Wzero-as-null-pointer-constant
  114. ifneq ($(DEBUG),true)
  115. CXXFLAGS += -Weffc++
  116. endif
  117. ifeq ($(LINUX),true)
  118. BASE_FLAGS += -isystem /opt/kxstudio/include
  119. endif
  120. ifeq ($(MACOS),true)
  121. CXXFLAGS += -isystem /System/Library/Frameworks
  122. endif
  123. ifeq ($(WIN32),true)
  124. BASE_FLAGS += -isystem /opt/mingw32/include
  125. endif
  126. ifeq ($(WIN64),true)
  127. BASE_FLAGS += -isystem /opt/mingw64/include
  128. endif
  129. # TODO
  130. ifeq ($(CLANG),true)
  131. BASE_FLAGS += -Wno-double-promotion
  132. BASE_FLAGS += -Wno-format-nonliteral
  133. BASE_FLAGS += -Wno-tautological-pointer-compare
  134. endif
  135. endif
  136. # ---------------------------------------------------------------------------------------------------------------------
  137. # Set base defines
  138. ifeq ($(JACKBRIDGE_DIRECT),true)
  139. ifeq ($(HAVE_JACK),true)
  140. BASE_FLAGS += -DJACKBRIDGE_DIRECT
  141. else
  142. $(error jackbridge direct mode requested, but jack not available)
  143. endif
  144. endif
  145. ifeq ($(HAVE_DGL),true)
  146. BASE_FLAGS += -DHAVE_DGL
  147. BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL -DDGL_FILE_BROWSER_DISABLED -DDGL_NO_SHARED_RESOURCES
  148. endif
  149. ifeq ($(HAVE_FLUIDSYNTH),true)
  150. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  151. ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
  152. BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
  153. endif
  154. endif
  155. ifeq ($(HAVE_FFMPEG),true)
  156. BASE_FLAGS += -DHAVE_FFMPEG
  157. endif
  158. ifeq ($(HAVE_HYLIA),true)
  159. BASE_FLAGS += -DHAVE_HYLIA
  160. endif
  161. ifeq ($(HAVE_LIBLO),true)
  162. BASE_FLAGS += -DHAVE_LIBLO
  163. endif
  164. ifeq ($(HAVE_LIBMAGIC),true)
  165. BASE_FLAGS += -DHAVE_LIBMAGIC
  166. endif
  167. ifeq ($(HAVE_PYQT),true)
  168. BASE_FLAGS += -DHAVE_PYQT
  169. endif
  170. ifeq ($(HAVE_SNDFILE),true)
  171. BASE_FLAGS += -DHAVE_SNDFILE
  172. endif
  173. ifeq ($(HAVE_X11),true)
  174. BASE_FLAGS += -DHAVE_X11
  175. endif
  176. ifeq ($(USING_JUCE),true)
  177. BASE_FLAGS += -DUSING_JUCE
  178. endif
  179. ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
  180. BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
  181. endif
  182. ifeq ($(USING_JUCE_GUI_EXTRA),true)
  183. BASE_FLAGS += -DUSING_JUCE_GUI_EXTRA
  184. endif
  185. ifeq ($(USING_RTAUDIO),true)
  186. BASE_FLAGS += -DUSING_RTAUDIO
  187. endif
  188. ifeq ($(STATIC_PLUGIN_TARGET),true)
  189. BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
  190. endif
  191. # ---------------------------------------------------------------------------------------------------------------------
  192. # Allow custom namespace
  193. ifneq ($(CARLA_BACKEND_NAMESPACE),)
  194. BASE_FLAGS += -DCARLA_BACKEND_NAMESPACE=$(CARLA_BACKEND_NAMESPACE)
  195. endif
  196. # ---------------------------------------------------------------------------------------------------------------------
  197. # Set app extension
  198. ifeq ($(WIN32),true)
  199. APP_EXT = .exe
  200. endif
  201. # ---------------------------------------------------------------------------------------------------------------------
  202. # Set shared lib extension
  203. LIB_EXT = .so
  204. ifeq ($(MACOS),true)
  205. LIB_EXT = .dylib
  206. endif
  207. ifeq ($(WIN32),true)
  208. LIB_EXT = .dll
  209. endif
  210. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  211. # ---------------------------------------------------------------------------------------------------------------------
  212. # Set static libs start & end
  213. ifneq ($(MACOS),true)
  214. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  215. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  216. endif
  217. # ---------------------------------------------------------------------------------------------------------------------
  218. # Set shared library CLI arg
  219. ifeq ($(MACOS),true)
  220. SHARED = -dynamiclib
  221. else
  222. SHARED = -shared
  223. endif
  224. # ---------------------------------------------------------------------------------------------------------------------
  225. # Set arguments used for inline 'sed'
  226. ifeq ($(BSD),true)
  227. SED_ARGS=-i '' -e
  228. else
  229. SED_ARGS=-i -e
  230. endif
  231. # ---------------------------------------------------------------------------------------------------------------------
  232. # Set command used for file symlinking
  233. LINK := ln -sf
  234. # ---------------------------------------------------------------------------------------------------------------------
  235. # Check if we can generate ttl files
  236. ifneq ($(BUILDING_FOR_WINE),true)
  237. ifeq ($(CROSS_COMPILING),true)
  238. ifeq ($(WIN32),true)
  239. NEEDS_WINE = true
  240. endif
  241. endif
  242. endif
  243. ifneq ($(CROSS_COMPILING),true)
  244. CAN_GENERATE_LV2_TTL = true
  245. else ifeq ($(NEEDS_WINE),true)
  246. CAN_GENERATE_LV2_TTL = true
  247. endif
  248. # ---------------------------------------------------------------------------------------------------------------------
  249. # Check if we should build the external plugins
  250. ifeq ($(EXTERNAL_PLUGINS),true)
  251. ifneq ($(DEBUG),true)
  252. ifneq ($(TESTBUILD),true)
  253. ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
  254. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  255. include $(CWD)/native-plugins/external/Makefile.mk
  256. endif
  257. endif
  258. endif
  259. endif
  260. # ---------------------------------------------------------------------------------------------------------------------