1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 gb_README
= README_
$(1)
17 # use CC/CXX if they are nondefaults
18 ifneq ($(origin CC
),default
)
26 ifneq ($(origin CXX
),default
)
32 ifneq ($(origin AR
),default
)
35 gb_AR
:= $(shell $(CC
) -print-prog-name
=ar)
38 # shell setup (env.vars) for the compiler
42 gb_LinkTarget_LDFLAGS
+= -fuse-ld
=$(USE_LD
)
45 ifeq ($(strip $(gb_COMPILEROPTFLAGS
)),)
46 gb_COMPILEROPTFLAGS
:= -O2
51 gb_AFLAGS
:= $(AFLAGS
)
54 -DBOOST_ERROR_CODE_HEADER_ONLY \
55 -DBOOST_SYSTEM_NO_DEPRECATED \
56 -DCPPU_ENV
=$(gb_CPPU_ENV
) \
65 $(if
$(and
$(COM_IS_CLANG
),$(or
$(findstring icecc
,$(CC
)),$(findstring icecc
,$(CCACHE_PREFIX
)))),,-Wunused-macros
) \
66 -finput-charset
=UTF-8 \
71 gb_CXXFLAGS_COMMON
:= \
79 $(if
$(and
$(COM_IS_CLANG
),$(or
$(findstring icecc
,$(CC
)),$(findstring icecc
,$(CCACHE_PREFIX
)))),,-Wunused-macros
) \
80 -finput-charset
=UTF-8 \
85 gb_Helper_disable_warnings
= $(1) -w
87 ifeq ($(HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED
),TRUE
)
88 gb_CXXFLAGS_COMMON
+= -Wno-maybe-uninitialized
91 gb_CXXFLAGS_Wundef
= -Wno-undef
93 ifeq ($(strip $(gb_GCOV
)),YES
)
94 gb_CFLAGS_COMMON
+= -fprofile-arcs
-ftest-coverage
95 gb_CXXFLAGS_COMMON
+= -fprofile-arcs
-ftest-coverage
96 gb_LinkTarget_LDFLAGS
+= -fprofile-arcs
-lgcov
97 gb_COMPILEROPTFLAGS
:= -O0
100 ifeq ($(DISABLE_DYNLOADING
),TRUE
)
101 gb_CFLAGS_COMMON
+= -ffunction-sections
-fdata-sections
102 gb_CXXFLAGS_COMMON
+= -ffunction-sections
-fdata-sections
103 gb_LinkTarget_LDFLAGS
+= -Wl
,--gc-sections
106 ifeq ($(COM_IS_CLANG
),TRUE
)
107 gb_CXXFLAGS_COMMON
+= -Wimplicit-fallthrough
109 gb_CFLAGS_COMMON
+= \
113 gb_CXXFLAGS_COMMON
+= \
117 -Wunused-const-variable
=1
120 # GCC 8 -Wcast-function-type (included in -Wextra) unhelpfully even warns on reinterpret_cast
121 # between incompatible function types:
122 ifeq ($(shell expr
'$(GCC_VERSION)' '>=' 800),1)
123 gb_CXXFLAGS_COMMON
+= \
124 -Wno-cast-function-type
127 # If CC or CXX already include -fvisibility=hidden, don't duplicate it
128 ifeq (,$(filter -fvisibility
=hidden
,$(CC
)))
129 ifeq ($(NEED_CLANG_LINUX_UBSAN_RTTI_VISIBILITY
),TRUE
)
130 gb_VISIBILITY_FLAGS
:= -fvisibility-ms-compat
132 gb_VISIBILITY_FLAGS
:= -fvisibility
=hidden
135 gb_VISIBILITY_FLAGS_CXX
:= -fvisibility-inlines-hidden
136 gb_CXXFLAGS_COMMON
+= $(gb_VISIBILITY_FLAGS_CXX
)
138 ifeq ($(HAVE_GCC_STACK_PROTECTOR_STRONG
),TRUE
)
139 gb_CFLAGS_COMMON
+= -fstack-protector-strong
140 gb_CXXFLAGS_COMMON
+= -fstack-protector-strong
141 gb_LinkTarget_LDFLAGS
+= -fstack-protector-strong
144 ifneq ($(ENABLE_PCH
),)
145 ifeq ($(COM_IS_CLANG
),TRUE
)
146 # Clang by default includes in the PCH timestamps of the files it was
147 # generated from, which would make the PCH be a "new" file for ccache
148 # even if the file has not actually changed. Disabling the timestamp
149 # prevents this at the cost of risking using an outdated PCH (which
150 # should be unlikely, given that gbuild has dependencies set up
151 # for our includes and system includes are unlikely to change).
152 gb_NO_PCH_TIMESTAMP
:= -Xclang
-fno-pch-timestamp
154 gb_CFLAGS_COMMON
+= -fpch-preprocess
-Winvalid-pch
155 gb_CXXFLAGS_COMMON
+= -fpch-preprocess
-Winvalid-pch
156 gb_NO_PCH_TIMESTAMP
:=
160 gb_CFLAGS_WERROR
= $(if
$(ENABLE_WERROR
),-Werror
)
162 # This is the default in non-C++11 mode
163 ifeq ($(COM_IS_CLANG
),TRUE
)
164 gb_CXX03FLAGS
:= -std
=gnu
++98 -Werror
=c
++11-extensions
-Wno-c
++11-long-long \
165 -Wno-deprecated-declarations
167 gb_CXX03FLAGS
:= -std
=gnu
++98 -Wno-long-long \
168 -Wno-variadic-macros
-Wno-non-virtual-dtor
-Wno-deprecated-declarations
171 # On Windows MSVC only supports C90 so force gnu89 (especially in clang) to
172 # to catch potential gnu89/C90 incompatibilities locally.
173 gb_CFLAGS_COMMON
+= -std
=gnu89
175 ifeq ($(ENABLE_LTO
),TRUE
)
176 ifeq ($(COM_IS_CLANG
),TRUE
)
178 gb_LTOPLUGINFLAGS
:= --plugin LLVMgold.so
180 gb_LTOFLAGS
:= -flto
=$(PARALLELISM
) -fuse-linker-plugin
-O2
184 gb_LinkTarget_EXCEPTIONFLAGS
:= \
188 ifeq ($(gb_ENABLE_DBGUTIL
),$(false
))
189 # Clang doesn't have this option
190 ifeq ($(HAVE_GCC_FNO_ENFORCE_EH_SPECS
),TRUE
)
191 gb_LinkTarget_EXCEPTIONFLAGS
+= \
192 -fno-enforce-eh-specs
196 gb_PrecompiledHeader_EXCEPTIONFLAGS
:= $(gb_LinkTarget_EXCEPTIONFLAGS
)
199 gb_COMPILERNOOPTFLAGS
:= -O0
-fstrict-aliasing
-fstrict-overflow
202 gb_DEBUGINFO_FLAGS
=-glldb
203 # Clang does not know -ggdb2 or some other options
204 else ifeq ($(HAVE_GCC_GGDB2
),TRUE
)
205 gb_DEBUGINFO_FLAGS
=-ggdb2
207 gb_DEBUGINFO_FLAGS
=-g2
209 gb_LINKER_DEBUGINFO_FLAGS
=
211 ifeq ($(HAVE_GCC_SPLIT_DWARF
),TRUE
)
212 gb_DEBUGINFO_FLAGS
+=-gsplit-dwarf
215 ifeq ($(ENABLE_GDB_INDEX
),TRUE
)
216 gb_LINKER_DEBUGINFO_FLAGS
+= -Wl
,--gdb-index
217 gb_DEBUGINFO_FLAGS
+= -ggnu-pubnames
220 gb_LinkTarget_INCLUDE
:=\
222 -I
$(BUILDDIR
)/config_
$(gb_Side
) \
224 ifeq ($(COM_IS_CLANG
),TRUE
)
225 gb_COMPILER_TEST_FLAGS
:= -Xclang
-plugin-arg-loplugin
-Xclang
--unit-test-mode
226 ifeq ($(COMPILER_PLUGIN_TOOL
),)
227 gb_COMPILER_PLUGINS
:= -Xclang
-load
-Xclang
$(BUILDDIR
)/compilerplugins
/obj
/plugin.so
-Xclang
-add-plugin
-Xclang loplugin
228 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY
),)
229 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang \
230 --warnings-only
='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
233 gb_COMPILER_PLUGINS
:= -Xclang
-load
-Xclang
$(BUILDDIR
)/compilerplugins
/obj
/plugin.so
-Xclang
-plugin
-Xclang loplugin
$(foreach plugin
,$(COMPILER_PLUGIN_TOOL
), -Xclang
-plugin-arg-loplugin
-Xclang
$(plugin
))
234 ifneq ($(UPDATE_FILES
),)
235 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang
--scope
=$(UPDATE_FILES
)
238 ifeq ($(COMPILER_PLUGINS_DEBUG
),TRUE
)
239 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang
--debug
241 # set CCACHE_CPP2=1 to prevent clang generating spurious warnings
242 gb_COMPILER_SETUP
+= CCACHE_CPP2
=1
243 gb_COMPILER_PLUGINS_SETUP
:= ICECC_EXTRAFILES
=$(SRCDIR
)/include/sal
/log-areas.dox CCACHE_EXTRAFILES
=$(SRCDIR
)/include/sal
/log-areas.dox
244 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
:= \
245 -Xclang
-plugin-arg-loplugin
-Xclang
--warnings-as-errors
247 # Set CCACHE_CPP2 to prevent GCC -Werror=implicit-fallthrough= when ccache strips comments from C
248 # code (which still needs /*fallthrough*/-style comments to silence that warning):
249 ifeq ($(ENABLE_WERROR
),TRUE
)
250 gb_COMPILER_SETUP
+= CCACHE_CPP2
=1
252 gb_COMPILER_TEST_FLAGS
:=
253 gb_COMPILER_PLUGINS
:=
254 gb_COMPILER_PLUGINS_SETUP
:=
255 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
:=
260 gb_Executable_EXT_for_build
:=
264 ifeq ($(OS_FOR_BUILD
),MACOSX
)
265 gb_Helper_LIBRARY_PATH_VAR
:= DYLD_LIBRARY_PATH
266 else ifeq ($(OS_FOR_BUILD
),AIX
)
267 gb_Helper_LIBRARY_PATH_VAR
:= LIBPATH
268 else ifeq ($(OS_FOR_BUILD
),WNT
)
269 # In theory possible if cross-compiling to some Unix from Windows,
270 # in practice strongly discouraged to even try that
271 gb_Helper_LIBRARY_PATH_VAR
:= PATH
272 else ifeq ($(OS_FOR_BUILD
),HAIKU
)
273 gb_Helper_LIBRARY_PATH_VAR
:= LIBRARY_PATH
275 gb_Helper_LIBRARY_PATH_VAR
:= LD_LIBRARY_PATH
278 gb_Helper_set_ld_path
:= $(gb_Helper_LIBRARY_PATH_VAR
)=$${$(gb_Helper_LIBRARY_PATH_VAR
):+$$$(gb_Helper_LIBRARY_PATH_VAR
):}"$(INSTROOT_FOR_BUILD)/$(LIBO_URE_LIB_FOLDER_FOR_BUILD):$(INSTROOT_FOR_BUILD)/$(LIBO_LIB_FOLDER_FOR_BUILD)"
280 # $(1): list of : separated directory pathnames to append to the ld path
281 define gb_Helper_extend_ld_path
282 $(gb_Helper_set_ld_path
):$(1)
285 # Convert path to file URL.
286 define gb_Helper_make_url
290 gb_Helper_get_rcfile
= $(1)rc
292 ifneq ($(ENABLE_PCH
),)
293 # Enable use of .sum files for PCHs.
294 gb_COMPILER_SETUP
+= CCACHE_PCH_EXTSUM
=1
295 # CCACHE_SLOPPINESS should contain pch_defines,time_macros for PCHs.
296 gb_CCACHE_SLOPPINESS
:=
297 ifeq ($(shell test -z
"$$CCACHE_SLOPPINESS" && echo
1),1)
298 gb_CCACHE_SLOPPINESS
:= CCACHE_SLOPPINESS
=pch_defines
,time_macros
300 ifeq ($(shell echo
"$$CCACHE_SLOPPINESS" | grep
-q pch_defines | grep
-q time_macros
&& echo
1),1)
301 gb_CCACHE_SLOPPINESS
:= CCACHE_SLOPPINESS
=$CCACHE_SLOPPINESS:pch_defines
,time_macros
304 gb_COMPILER_SETUP
+= $(gb_CCACHE_SLOPPINESS
)
307 ifneq ($(CCACHE_DEPEND_MODE
),)
308 gb_COMPILER_SETUP
+= CCACHE_DEPEND
=1
311 # vim: set noet sw=4: