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.

Makefile.mk 8.5KB

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