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.

314 lines
8.2KB

  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. # mingw has issues with this specific optimization
  50. # See https://github.com/falkTX/Carla/issues/696
  51. BASE_OPTS += -fno-rerun-cse-after-loop
  52. # See https://github.com/falkTX/Carla/issues/855
  53. BASE_OPTS += -mstackrealign
  54. ifeq ($(BUILDING_FOR_WINE),true)
  55. BASE_FLAGS += -DBUILDING_CARLA_FOR_WINE
  56. endif
  57. else
  58. # Not needed for Windows
  59. BASE_FLAGS += -fPIC -DPIC
  60. endif
  61. ifeq ($(CLANG),true)
  62. BASE_FLAGS += -Wabsolute-value
  63. endif
  64. ifeq ($(DEBUG),true)
  65. BASE_FLAGS += -DDEBUG -O0 -g
  66. LINK_OPTS =
  67. else
  68. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  69. CXXFLAGS += -fvisibility-inlines-hidden
  70. endif
  71. 32BIT_FLAGS = -m32
  72. 64BIT_FLAGS = -m64
  73. ARM32_FLAGS = -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad
  74. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  75. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
  76. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  77. ifneq ($(MACOS),true)
  78. # Not available on MacOS
  79. LINK_FLAGS += -Wl,--no-undefined
  80. endif
  81. ifeq ($(MACOS_OLD),true)
  82. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
  83. endif
  84. ifeq ($(STATIC_BINARIES),true)
  85. LINK_FLAGS += -static
  86. endif
  87. # ---------------------------------------------------------------------------------------------------------------------
  88. # Strict test build
  89. ifeq ($(TESTBUILD),true)
  90. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wdisabled-optimization
  91. BASE_FLAGS += -Wdouble-promotion -Wfloat-equal -Wpointer-arith -Wsign-conversion
  92. BASE_FLAGS += -Wformat=2 -Woverlength-strings
  93. BASE_FLAGS += -Wmissing-declarations -Wredundant-decls
  94. BASE_FLAGS += -Wshadow -Wundef -Wuninitialized -Wunused
  95. BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
  96. BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
  97. BASE_FLAGS += -Wnull-dereference
  98. ifneq ($(CLANG),true)
  99. BASE_FLAGS += -Wabi=98 -Wclobbered -Wlogical-op
  100. BASE_FLAGS += -Wformat-truncation=2 -Wformat-overflow=2
  101. BASE_FLAGS += -Wstringop-overflow=4 -Wstringop-truncation
  102. BASE_FLAGS += -Wduplicated-branches -Wduplicated-cond
  103. endif
  104. CFLAGS += -Winit-self -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wwrite-strings
  105. ifneq ($(CLANG),true)
  106. CFLAGS += -Wjump-misses-init
  107. endif
  108. CXXFLAGS += -Wc++0x-compat -Wc++11-compat
  109. CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
  110. # CXXFLAGS += -Wold-style-cast -Wuseless-cast
  111. CXXFLAGS += -Wzero-as-null-pointer-constant
  112. ifneq ($(DEBUG),true)
  113. CXXFLAGS += -Weffc++
  114. endif
  115. ifeq ($(LINUX),true)
  116. BASE_FLAGS += -isystem /opt/kxstudio/include
  117. endif
  118. ifeq ($(MACOS),true)
  119. CXXFLAGS += -isystem /System/Library/Frameworks
  120. endif
  121. ifeq ($(WIN32),true)
  122. BASE_FLAGS += -isystem /opt/mingw32/include
  123. endif
  124. ifeq ($(WIN64),true)
  125. BASE_FLAGS += -isystem /opt/mingw64/include
  126. endif
  127. # TODO
  128. ifeq ($(CLANG),true)
  129. BASE_FLAGS += -Wno-double-promotion
  130. BASE_FLAGS += -Wno-format-nonliteral
  131. BASE_FLAGS += -Wno-tautological-pointer-compare
  132. endif
  133. endif
  134. # ---------------------------------------------------------------------------------------------------------------------
  135. # Set base defines
  136. ifeq ($(JACKBRIDGE_DIRECT),true)
  137. ifeq ($(HAVE_JACK),true)
  138. BASE_FLAGS += -DJACKBRIDGE_DIRECT
  139. else
  140. $(error jackbridge direct mode requested, but jack not available)
  141. endif
  142. endif
  143. ifeq ($(HAVE_DGL),true)
  144. BASE_FLAGS += -DHAVE_DGL
  145. BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL -DDGL_FILE_BROWSER_DISABLED -DDGL_NO_SHARED_RESOURCES
  146. endif
  147. ifeq ($(HAVE_FLUIDSYNTH),true)
  148. BASE_FLAGS += -DHAVE_FLUIDSYNTH
  149. ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
  150. BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
  151. endif
  152. endif
  153. ifeq ($(HAVE_FFMPEG),true)
  154. BASE_FLAGS += -DHAVE_FFMPEG
  155. endif
  156. ifeq ($(HAVE_HYLIA),true)
  157. BASE_FLAGS += -DHAVE_HYLIA
  158. endif
  159. ifeq ($(HAVE_LIBLO),true)
  160. BASE_FLAGS += -DHAVE_LIBLO
  161. endif
  162. ifeq ($(HAVE_LIBMAGIC),true)
  163. BASE_FLAGS += -DHAVE_LIBMAGIC
  164. endif
  165. ifeq ($(HAVE_PYQT),true)
  166. BASE_FLAGS += -DHAVE_PYQT
  167. endif
  168. ifeq ($(HAVE_SNDFILE),true)
  169. BASE_FLAGS += -DHAVE_SNDFILE
  170. endif
  171. ifeq ($(HAVE_X11),true)
  172. BASE_FLAGS += -DHAVE_X11
  173. endif
  174. ifeq ($(USING_JUCE),true)
  175. BASE_FLAGS += -DUSING_JUCE
  176. endif
  177. ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
  178. BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
  179. endif
  180. ifeq ($(USING_JUCE_GUI_EXTRA),true)
  181. BASE_FLAGS += -DUSING_JUCE_GUI_EXTRA
  182. endif
  183. ifeq ($(USING_RTAUDIO),true)
  184. BASE_FLAGS += -DUSING_RTAUDIO
  185. endif
  186. ifeq ($(STATIC_PLUGIN_TARGET),true)
  187. BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
  188. endif
  189. # ---------------------------------------------------------------------------------------------------------------------
  190. # Set app extension
  191. ifeq ($(WIN32),true)
  192. APP_EXT = .exe
  193. endif
  194. # ---------------------------------------------------------------------------------------------------------------------
  195. # Set shared lib extension
  196. LIB_EXT = .so
  197. ifeq ($(MACOS),true)
  198. LIB_EXT = .dylib
  199. endif
  200. ifeq ($(WIN32),true)
  201. LIB_EXT = .dll
  202. endif
  203. BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
  204. # ---------------------------------------------------------------------------------------------------------------------
  205. # Set static libs start & end
  206. ifneq ($(MACOS),true)
  207. LIBS_START = -Wl,--start-group -Wl,--whole-archive
  208. LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
  209. endif
  210. # ---------------------------------------------------------------------------------------------------------------------
  211. # Set shared library CLI arg
  212. ifeq ($(MACOS),true)
  213. SHARED = -dynamiclib
  214. else
  215. SHARED = -shared
  216. endif
  217. # ---------------------------------------------------------------------------------------------------------------------
  218. # Set arguments used for inline 'sed'
  219. ifeq ($(BSD),true)
  220. SED_ARGS=-i '' -e
  221. else
  222. SED_ARGS=-i -e
  223. endif
  224. # ---------------------------------------------------------------------------------------------------------------------
  225. # Set command used for file symlinking
  226. LINK := ln -sf
  227. # ---------------------------------------------------------------------------------------------------------------------
  228. # Check if we can generate ttl files
  229. ifneq ($(BUILDING_FOR_WINE),true)
  230. ifeq ($(CROSS_COMPILING),true)
  231. ifeq ($(WIN32),true)
  232. NEEDS_WINE = true
  233. endif
  234. endif
  235. endif
  236. ifneq ($(CROSS_COMPILING),true)
  237. CAN_GENERATE_LV2_TTL = true
  238. else ifeq ($(NEEDS_WINE),true)
  239. CAN_GENERATE_LV2_TTL = true
  240. endif
  241. # ---------------------------------------------------------------------------------------------------------------------
  242. # Check if we should build the external plugins
  243. ifeq ($(EXTERNAL_PLUGINS),true)
  244. ifneq ($(DEBUG),true)
  245. ifneq ($(TESTBUILD),true)
  246. ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
  247. BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
  248. include $(CWD)/native-plugins/external/Makefile.mk
  249. endif
  250. endif
  251. endif
  252. endif
  253. # ---------------------------------------------------------------------------------------------------------------------