2 # Makefile for Carla C++ code #
3 # --------------------------- #
7 # ---------------------------------------------------------------------------------------------------------------------
8 # Base environment vars
12 # ---------------------------------------------------------------------------------------------------------------------
13 # Internationalization
17 # ---------------------------------------------------------------------------------------------------------------------
18 # Base definitions for dependencies and system type
20 include $(CWD
)/Makefile.deps.mk
22 # ---------------------------------------------------------------------------------------------------------------------
23 # Set build and link flags
25 BASE_FLAGS
= -Wall
-Wextra
-pipe
-DBUILDING_CARLA
-MD
-MP
-fno-common
26 BASE_OPTS
= -O3
-ffast-math
-fdata-sections
-ffunction-sections
29 BASE_OPTS
+= -msse
-msse2
-msse3
-msimd128
30 else ifeq ($(CPU_ARM32
),true
)
31 BASE_OPTS
+= -mfpu
=neon-vfpv4
-mfloat-abi
=hard
32 else ifeq ($(CPU_I386_OR_X86_64
),true
)
33 BASE_OPTS
+= -mtune
=generic
-msse
-msse2
-mfpmath
=sse
38 BASE_FLAGS
+= -Wno-deprecated-declarations
39 LINK_OPTS
= -fdata-sections
-ffunction-sections
-Wl
,-dead_strip
,-dead_strip_dylibs
40 ifneq ($(SKIP_STRIPPING
),true
)
45 LINK_OPTS
= -fdata-sections
-ffunction-sections
-Wl
,-O1
,--gc-sections
47 LINK_OPTS
+= -Wl
,--as-needed
48 ifneq ($(SKIP_STRIPPING
),true
)
49 LINK_OPTS
+= -Wl
,--strip-all
55 # No CPU-specific optimization flags
56 BASE_OPTS
= -O2
-ffast-math
-fdata-sections
-ffunction-sections
-DBUILDING_CARLA_NOOPT
59 ifeq ($(WINDOWS
),true
)
60 # Assume we want posix
62 # Needed for windows, see https://github.com/falkTX/Carla/issues/855
63 BASE_FLAGS
+= -mstackrealign
64 ifeq ($(BUILDING_FOR_WINE
),true
)
65 BASE_FLAGS
+= -DBUILDING_CARLA_FOR_WINE
68 # Not needed for Windows
69 BASE_FLAGS
+= -fPIC
-DPIC
73 BASE_FLAGS
+= -Wabsolute-value
77 BASE_FLAGS
+= -DDEBUG
-O0
-g
80 LINK_OPTS
+= -sASSERTIONS
=1
83 BASE_FLAGS
+= -DNDEBUG
$(BASE_OPTS
) -fvisibility
=hidden
84 CXXFLAGS
+= -fvisibility-inlines-hidden
87 ifneq ($(MACOS_OR_WASM_OR_WINDOWS
),true
)
89 BASE_FLAGS
+= -fno-gnu-unique
93 ifeq ($(WITH_LTO
),true
)
94 BASE_FLAGS
+= -fno-strict-aliasing
-flto
95 LINK_OPTS
+= -fno-strict-aliasing
-flto
-Werror
=odr
-Werror
=lto-type-mismatch
100 ARM32_FLAGS
= -mcpu
=cortex-a7
-mtune
=cortex-a7
-mfpu
=neon-vfpv4
-mfloat-abi
=hard
-mvectorize-with-neon-quad
102 BUILD_C_FLAGS
= $(BASE_FLAGS
) -std
=gnu99
$(CFLAGS
)
103 BUILD_CXX_FLAGS
= $(BASE_FLAGS
) -std
=gnu
++11 $(CXXFLAGS
)
104 LINK_FLAGS
= $(LINK_OPTS
) $(LDFLAGS
)
107 # Special flag for emscripten
108 LINK_FLAGS
+= -sLLD_REPORT_UNDEFINED
109 else ifneq ($(MACOS
),true
)
110 # Not available on MacOS
111 LINK_FLAGS
+= -Wl
,--no-undefined
114 ifeq ($(WINDOWS
),true
)
115 # Always build static binaries on Windows
116 LINK_FLAGS
+= -static
119 # ---------------------------------------------------------------------------------------------------------------------
122 ifeq ($(TESTBUILD
),true
)
123 BASE_FLAGS
+= -Werror
-Wcast-qual
-Wconversion
-Wdisabled-optimization
124 BASE_FLAGS
+= -Wdouble-promotion
-Wfloat-equal
-Wpointer-arith
-Wsign-conversion
125 BASE_FLAGS
+= -Wformat
=2 -Woverlength-strings
126 BASE_FLAGS
+= -Wmissing-declarations
-Wredundant-decls
127 BASE_FLAGS
+= -Wshadow
-Wundef
-Wuninitialized
-Wunused
128 BASE_FLAGS
+= -Wstrict-aliasing
-fstrict-aliasing
129 BASE_FLAGS
+= -Wstrict-overflow
-fstrict-overflow
130 BASE_FLAGS
+= -Wnull-dereference
131 ifneq ($(CLANG
),true
)
132 BASE_FLAGS
+= -Wabi
=98 -Wclobbered
-Wlogical-op
133 BASE_FLAGS
+= -Wformat-truncation
=2 -Wformat-overflow
=2
134 BASE_FLAGS
+= -Wstringop-overflow
=4 -Wstringop-truncation
135 BASE_FLAGS
+= -Wduplicated-branches
-Wduplicated-cond
137 CFLAGS
+= -Winit-self
-Wmissing-prototypes
-Wnested-externs
-Wstrict-prototypes
-Wwrite-strings
138 ifneq ($(CLANG
),true
)
139 CFLAGS
+= -Wjump-misses-init
141 CXXFLAGS
+= -Wc
++0x-compat
-Wc
++11-compat
142 CXXFLAGS
+= -Wnon-virtual-dtor
-Woverloaded-virtual
143 # CXXFLAGS += -Wold-style-cast -Wuseless-cast
144 CXXFLAGS
+= -Wzero-as-null-pointer-constant
145 ifneq ($(DEBUG
),true
)
149 BASE_FLAGS
+= -isystem
/opt
/kxstudio
/include
152 CXXFLAGS
+= -isystem
/System
/Library
/Frameworks
156 BASE_FLAGS
+= -Wno-double-promotion
157 BASE_FLAGS
+= -Wno-format-nonliteral
158 BASE_FLAGS
+= -Wno-tautological-pointer-compare
162 # ---------------------------------------------------------------------------------------------------------------------
165 ifeq ($(JACKBRIDGE_DIRECT
),true
)
166 ifeq ($(HAVE_JACKLIB
),true
)
167 BASE_FLAGS
+= -DJACKBRIDGE_DIRECT
169 $(error jackbridge direct mode requested
, but jack not available
)
173 ifeq ($(HAVE_DGL
),true
)
174 BASE_FLAGS
+= -DHAVE_DGL
175 BASE_FLAGS
+= -DHAVE_OPENGL
176 BASE_FLAGS
+= -DDGL_OPENGL
177 BASE_FLAGS
+= -DDONT_SET_USING_DGL_NAMESPACE
178 ifneq ($(USING_CUSTOM_DPF
),true
)
179 BASE_FLAGS
+= -DDGL_FILE_BROWSER_DISABLED
180 BASE_FLAGS
+= -DDGL_NO_SHARED_RESOURCES
182 BASE_FLAGS
+= -DDISTRHO_UI_FILE_BROWSER
=0
184 ifneq ($(DGL_NAMESPACE
),)
185 BASE_FLAGS
+= -DDGL_NAMESPACE
=$(DGL_NAMESPACE
)
187 BASE_FLAGS
+= -DDGL_NAMESPACE
=CarlaDGL
191 ifeq ($(HAVE_FLUIDSYNTH
),true
)
192 BASE_FLAGS
+= -DHAVE_FLUIDSYNTH
193 ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH
),true
)
194 BASE_FLAGS
+= -DHAVE_FLUIDSYNTH_INSTPATCH
198 ifeq ($(HAVE_FFMPEG
),true
)
199 BASE_FLAGS
+= -DHAVE_FFMPEG
202 ifeq ($(HAVE_HYLIA
),true
)
203 BASE_FLAGS
+= -DHAVE_HYLIA
206 ifeq ($(HAVE_JACK
),true
)
207 BASE_FLAGS
+= -DHAVE_JACK
210 ifeq ($(HAVE_LIBLO
),true
)
211 BASE_FLAGS
+= -DHAVE_LIBLO
214 ifeq ($(HAVE_LIBMAGIC
),true
)
215 BASE_FLAGS
+= -DHAVE_LIBMAGIC
218 ifeq ($(HAVE_PYQT
),true
)
219 BASE_FLAGS
+= -DHAVE_PYQT
222 ifeq ($(HAVE_SDL2
),true
)
223 BASE_FLAGS
+= -DHAVE_SDL
-DHAVE_SDL2
224 else ifeq ($(HAVE_SDL1
),true
)
225 BASE_FLAGS
+= -DHAVE_SDL
-DHAVE_SDL1
228 ifeq ($(HAVE_SNDFILE
),true
)
229 BASE_FLAGS
+= -DHAVE_SNDFILE
232 ifeq ($(HAVE_X11
),true
)
233 BASE_FLAGS
+= -DHAVE_X11
236 ifeq ($(HAVE_YSFX
),true
)
237 BASE_FLAGS
+= -DHAVE_YSFX
240 ifeq ($(USING_RTAUDIO
),true
)
241 BASE_FLAGS
+= -DUSING_RTAUDIO
244 ifeq ($(STATIC_PLUGIN_TARGET
),true
)
245 BASE_FLAGS
+= -DSTATIC_PLUGIN_TARGET
248 # ---------------------------------------------------------------------------------------------------------------------
249 # Allow custom namespace
251 ifneq ($(CARLA_BACKEND_NAMESPACE
),)
252 BASE_FLAGS
+= -DCARLA_BACKEND_NAMESPACE
=$(CARLA_BACKEND_NAMESPACE
)
255 # ---------------------------------------------------------------------------------------------------------------------
260 else ifeq ($(WINDOWS
),true
)
264 # ---------------------------------------------------------------------------------------------------------------------
265 # Set shared lib extension
269 else ifeq ($(WASM
),true
)
271 else ifeq ($(WINDOWS
),true
)
277 BASE_FLAGS
+= -DCARLA_LIB_EXT
=\"$(LIB_EXT
)\"
279 # ---------------------------------------------------------------------------------------------------------------------
280 # Set static libs start & end
282 ifneq ($(MACOS
),true
)
283 LIBS_START
= -Wl
,--start-group
-Wl
,--whole-archive
284 LIBS_END
= -Wl
,--no-whole-archive
-Wl
,--end-group
287 # ---------------------------------------------------------------------------------------------------------------------
288 # Handle the verbosity switch
293 else ifeq ($(VERBOSE
),y
)
294 else ifeq ($(VERBOSE
),yes
)
295 else ifeq ($(VERBOSE
),true
)
300 # ---------------------------------------------------------------------------------------------------------------------
301 # Set shared library CLI arg
305 else ifeq ($(WASM
),true
)
306 SHARED
= -sMAIN_MODULE
=2
311 # ---------------------------------------------------------------------------------------------------------------------
312 # Set arguments used for inline 'sed'
320 # ---------------------------------------------------------------------------------------------------------------------
321 # Set command used for file symlinking
325 # ---------------------------------------------------------------------------------------------------------------------
326 # Check if we can generate ttl files
328 ifneq ($(BUILDING_FOR_WINE
),true
)
329 ifeq ($(CROSS_COMPILING
),true
)
330 ifeq ($(WINDOWS
),true
)
336 ifneq ($(CROSS_COMPILING
),true
)
337 CAN_GENERATE_LV2_TTL
= true
338 else ifeq ($(NEEDS_WINE
),true
)
339 ifneq ($(EXE_WRAPPER
),)
340 CAN_GENERATE_LV2_TTL
= true
344 # ---------------------------------------------------------------------------------------------------------------------
345 # Check if we should build the external plugins
347 ifeq ($(EXTERNAL_PLUGINS
),true
)
348 ifneq ($(DEBUG
),true
)
349 ifneq ($(TESTBUILD
),true
)
350 ifneq (,$(wildcard $(CWD
)/native-plugins
/external
/Makefile.mk
))
351 BASE_FLAGS
+= -DHAVE_EXTERNAL_PLUGINS
352 include $(CWD
)/native-plugins
/external
/Makefile.mk
358 # ---------------------------------------------------------------------------------------------------------------------