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

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