Audio and MIDI file render through 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.

346 lines
8.6KB

  1. #!/usr/bin/make -f
  2. # Makefile for DIE-Plugins #
  3. # ------------------------ #
  4. # Created by falkTX
  5. #
  6. AR ?= ar
  7. CC ?= gcc
  8. CXX ?= g++
  9. # ---------------------------------------------------------------------------------------------------------------------
  10. # Auto-detect OS if not defined
  11. TARGET_MACHINE := $(shell $(CC) -dumpmachine)
  12. ifneq ($(BSD),true)
  13. ifneq ($(HAIKU),true)
  14. ifneq ($(HURD),true)
  15. ifneq ($(LINUX),true)
  16. ifneq ($(MACOS),true)
  17. ifneq ($(WINDOWS),true)
  18. ifneq (,$(findstring bsd,$(TARGET_MACHINE)))
  19. BSD=true
  20. endif
  21. ifneq (,$(findstring haiku,$(TARGET_MACHINE)))
  22. HAIKU=true
  23. endif
  24. ifneq (,$(findstring gnu,$(TARGET_MACHINE)))
  25. HURD=true
  26. endif
  27. ifneq (,$(findstring linux,$(TARGET_MACHINE)))
  28. LINUX=true
  29. endif
  30. ifneq (,$(findstring apple,$(TARGET_MACHINE)))
  31. MACOS=true
  32. endif
  33. ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
  34. WINDOWS=true
  35. endif
  36. endif
  37. endif
  38. endif
  39. endif
  40. endif
  41. endif
  42. # ---------------------------------------------------------------------------------------------------------------------
  43. # Auto-detect the processor
  44. TARGET_PROCESSOR := $(firstword $(subst -, ,$(TARGET_MACHINE)))
  45. ifneq (,$(filter i%86,$(TARGET_PROCESSOR)))
  46. CPU_I386=true
  47. CPU_I386_OR_X86_64=true
  48. endif
  49. ifneq (,$(filter x86_64,$(TARGET_PROCESSOR)))
  50. CPU_X86_64=true
  51. CPU_I386_OR_X86_64=true
  52. endif
  53. ifneq (,$(filter arm%,$(TARGET_PROCESSOR)))
  54. CPU_ARM=true
  55. CPU_ARM_OR_AARCH64=true
  56. endif
  57. ifneq (,$(filter arm64%,$(TARGET_PROCESSOR)))
  58. CPU_ARM64=true
  59. CPU_ARM_OR_AARCH64=true
  60. endif
  61. ifneq (,$(filter aarch64%,$(TARGET_PROCESSOR)))
  62. CPU_AARCH64=true
  63. CPU_ARM_OR_AARCH64=true
  64. endif
  65. # ---------------------------------------------------------------------------------------------------------------------
  66. # Set PKG_CONFIG (can be overridden by environment variable)
  67. ifeq ($(WINDOWS),true)
  68. # Build statically on Windows by default
  69. PKG_CONFIG ?= pkg-config --static
  70. else
  71. PKG_CONFIG ?= pkg-config
  72. endif
  73. # ---------------------------------------------------------------------------------------------------------------------
  74. # Set LINUX_OR_MACOS
  75. ifeq ($(LINUX),true)
  76. LINUX_OR_MACOS=true
  77. endif
  78. ifeq ($(MACOS),true)
  79. LINUX_OR_MACOS=true
  80. endif
  81. # ---------------------------------------------------------------------------------------------------------------------
  82. # Set MACOS_OR_WINDOWS and HAIKU_OR_MACOS_OR_WINDOWS
  83. ifeq ($(HAIKU),true)
  84. HAIKU_OR_MACOS_OR_WINDOWS=true
  85. endif
  86. ifeq ($(MACOS),true)
  87. MACOS_OR_WINDOWS=true
  88. HAIKU_OR_MACOS_OR_WINDOWS=true
  89. endif
  90. ifeq ($(WINDOWS),true)
  91. MACOS_OR_WINDOWS=true
  92. HAIKU_OR_MACOS_OR_WINDOWS=true
  93. endif
  94. # ---------------------------------------------------------------------------------------------------------------------
  95. # Set UNIX
  96. ifeq ($(BSD),true)
  97. UNIX=true
  98. endif
  99. ifeq ($(HURD),true)
  100. UNIX=true
  101. endif
  102. ifeq ($(LINUX),true)
  103. UNIX=true
  104. endif
  105. ifeq ($(MACOS),true)
  106. UNIX=true
  107. endif
  108. # ---------------------------------------------------------------------------------------------------------------------
  109. # Set build and link flags
  110. BASE_FLAGS = -Wall -Wextra -pipe -MD -MP
  111. BASE_OPTS = -O3 -ffast-math -fdata-sections -ffunction-sections
  112. ifeq ($(CPU_I386_OR_X86_64),true)
  113. BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse
  114. endif
  115. ifeq ($(CPU_ARM),true)
  116. ifneq ($(CPU_ARM64),true)
  117. BASE_OPTS += -mfpu=neon-vfpv4 -mfloat-abi=hard
  118. endif
  119. endif
  120. ifeq ($(MACOS),true)
  121. # MacOS linker flags
  122. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
  123. else
  124. # Common linker flags
  125. LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed
  126. ifneq ($(SKIP_STRIPPING),true)
  127. LINK_OPTS += -Wl,--strip-all
  128. endif
  129. endif
  130. ifeq ($(NOOPT),true)
  131. # No CPU-specific optimization flags
  132. BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
  133. endif
  134. ifeq ($(WINDOWS),true)
  135. # mingw has issues with this specific optimization
  136. # See https://github.com/falkTX/Carla/issues/696
  137. BASE_OPTS += -fno-rerun-cse-after-loop
  138. # See https://github.com/falkTX/Carla/issues/855
  139. BASE_OPTS += -mstackrealign
  140. else
  141. # Not needed for Windows
  142. BASE_FLAGS += -fPIC -DPIC
  143. endif
  144. ifeq ($(DEBUG),true)
  145. BASE_FLAGS += -DDEBUG -O0 -g
  146. LINK_OPTS =
  147. else
  148. BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
  149. CXXFLAGS += -fvisibility-inlines-hidden
  150. endif
  151. BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
  152. BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++0x $(CXXFLAGS)
  153. LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
  154. ifneq ($(MACOS),true)
  155. # Not available on MacOS
  156. LINK_FLAGS += -Wl,--no-undefined
  157. endif
  158. ifeq ($(MACOS_OLD),true)
  159. BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
  160. endif
  161. ifeq ($(WINDOWS),true)
  162. # Always build statically on windows
  163. LINK_FLAGS += -static
  164. endif
  165. # ---------------------------------------------------------------------------------------------------------------------
  166. # Strict test build
  167. ifeq ($(TESTBUILD),true)
  168. BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
  169. BASE_FLAGS += -Wpointer-arith -Wabi -Winit-self -Wuninitialized -Wstrict-overflow=5
  170. # BASE_FLAGS += -Wfloat-equal
  171. ifeq ($(CC),clang)
  172. BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
  173. BASE_FLAGS += -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-exit-time-destructors -Wno-float-equal
  174. else
  175. BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
  176. endif
  177. ifneq ($(MACOS),true)
  178. BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
  179. ifneq ($(CC),clang)
  180. BASE_FLAGS += -Wlogical-op
  181. endif
  182. endif
  183. CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
  184. CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
  185. endif
  186. # ---------------------------------------------------------------------------------------------------------------------
  187. # Check for required libraries
  188. HAVE_CAIRO = $(shell $(PKG_CONFIG) --exists cairo && echo true)
  189. ifeq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
  190. HAVE_OPENGL = true
  191. else
  192. HAVE_OPENGL = $(shell $(PKG_CONFIG) --exists gl && echo true)
  193. HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true)
  194. endif
  195. # ---------------------------------------------------------------------------------------------------------------------
  196. # Check for optional libraries
  197. HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true)
  198. HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
  199. # ---------------------------------------------------------------------------------------------------------------------
  200. # Set Generic DGL stuff
  201. ifeq ($(HAIKU),true)
  202. DGL_SYSTEM_LIBS += -lbe
  203. endif
  204. ifeq ($(MACOS),true)
  205. DGL_SYSTEM_LIBS += -framework Cocoa
  206. endif
  207. ifeq ($(WINDOWS),true)
  208. DGL_SYSTEM_LIBS += -lgdi32 -lcomdlg32
  209. endif
  210. ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
  211. ifeq ($(HAVE_X11),true)
  212. DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11)
  213. DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
  214. endif
  215. endif
  216. # ---------------------------------------------------------------------------------------------------------------------
  217. # Set Cairo specific stuff
  218. ifeq ($(HAVE_CAIRO),true)
  219. DGL_FLAGS += -DHAVE_CAIRO
  220. CAIRO_FLAGS = $(shell $(PKG_CONFIG) --cflags cairo)
  221. CAIRO_LIBS = $(shell $(PKG_CONFIG) --libs cairo)
  222. HAVE_CAIRO_OR_OPENGL = true
  223. endif
  224. # ---------------------------------------------------------------------------------------------------------------------
  225. # Set OpenGL specific stuff
  226. ifeq ($(HAVE_OPENGL),true)
  227. DGL_FLAGS += -DHAVE_OPENGL
  228. ifeq ($(HAIKU),true)
  229. OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl)
  230. OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl)
  231. endif
  232. ifeq ($(MACOS),true)
  233. OPENGL_LIBS = -framework OpenGL
  234. endif
  235. ifeq ($(WINDOWS),true)
  236. OPENGL_LIBS = -lopengl32
  237. endif
  238. ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
  239. OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11)
  240. OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11)
  241. endif
  242. HAVE_CAIRO_OR_OPENGL = true
  243. endif
  244. # ---------------------------------------------------------------------------------------------------------------------
  245. # Set app extension
  246. ifeq ($(WINDOWS),true)
  247. APP_EXT = .exe
  248. endif
  249. # ---------------------------------------------------------------------------------------------------------------------
  250. # Set shared lib extension
  251. LIB_EXT = .so
  252. ifeq ($(MACOS),true)
  253. LIB_EXT = .dylib
  254. endif
  255. ifeq ($(WINDOWS),true)
  256. LIB_EXT = .dll
  257. endif
  258. # ---------------------------------------------------------------------------------------------------------------------
  259. # Set shared library CLI arg
  260. ifeq ($(MACOS),true)
  261. SHARED = -dynamiclib
  262. else
  263. SHARED = -shared
  264. endif
  265. # ---------------------------------------------------------------------------------------------------------------------
  266. # Handle the verbosity switch
  267. ifeq ($(VERBOSE),true)
  268. SILENT =
  269. else
  270. SILENT = @
  271. endif
  272. # ---------------------------------------------------------------------------------------------------------------------