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.2KB

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