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/.
14 gb_README
= README_
$(1)
16 # use CC/CXX if they are nondefaults
17 ifneq ($(origin CC
),default
)
25 ifneq ($(origin CXX
),default
)
31 ifneq ($(origin AR
),default
)
34 gb_AR
:= $(shell $(CC
) -print-prog-name
=ar)
37 # shell setup (env.vars) for the compiler
40 ifeq ($(strip $(gb_COMPILEROPTFLAGS
)),)
41 gb_COMPILEROPTFLAGS
:= -O2
46 gb_AFLAGS
:= $(AFLAGS
)
49 -DBOOST_ERROR_CODE_HEADER_ONLY \
50 -DBOOST_SYSTEM_NO_DEPRECATED \
51 -DCPPU_ENV
=$(gb_CPPU_ENV
) \
60 $(if
$(or
$(and
$(COM_IS_CLANG
),$(or
$(findstring icecc
,$(CC
)),$(findstring icecc
,$(CCACHE_PREFIX
)))),$(findstring sccache
,$(CC
))),,-Wunused-macros
) \
61 $(if
$(COM_IS_CLANG
),-Wembedded-directive
) \
62 -finput-charset
=UTF-8 \
66 -fstack-protector-strong \
67 $(if
$(gb_COLOR
),-fdiagnostics-color
=always
) \
69 gb_CXXFLAGS_COMMON
:= \
77 $(if
$(or
$(and
$(COM_IS_CLANG
),$(or
$(findstring icecc
,$(CXX
)),$(findstring icecc
,$(CCACHE_PREFIX
)))),$(findstring sccache
,$(CXX
))),,-Wunused-macros
) \
78 $(if
$(COM_IS_CLANG
),-Wembedded-directive
) \
79 -finput-charset
=UTF-8 \
83 -fstack-protector-strong \
84 $(if
$(gb_COLOR
),-fdiagnostics-color
=always
) \
86 ifeq ($(HAVE_WDEPRECATED_COPY_DTOR
),TRUE
)
87 gb_CXXFLAGS_COMMON
+= -Wdeprecated-copy-dtor
90 gb_CXXFLAGS_DISABLE_WARNINGS
= -w
92 ifeq ($(HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED
),TRUE
)
93 gb_CXXFLAGS_COMMON
+= -Wno-maybe-uninitialized
96 gb_CXXFLAGS_Wundef
= -Wno-undef
98 ifeq ($(strip $(gb_GCOV
)),YES
)
99 gb_CFLAGS_COMMON
+= -fprofile-arcs
-ftest-coverage
100 gb_CXXFLAGS_COMMON
+= -fprofile-arcs
-ftest-coverage
101 gb_LinkTarget_LDFLAGS
+= -fprofile-arcs
-lgcov
102 gb_COMPILEROPTFLAGS
:= -O0
105 ifeq ($(DISABLE_DYNLOADING
),TRUE
)
106 gb_CFLAGS_COMMON
+= -ffunction-sections
-fdata-sections
107 gb_CXXFLAGS_COMMON
+= -ffunction-sections
-fdata-sections
108 gb_LinkTarget_LDFLAGS
+= -Wl
,--gc-sections
111 ifeq ($(COM_IS_CLANG
),TRUE
)
112 gb_CXXFLAGS_COMMON
+= \
113 -Wimplicit-fallthrough \
114 -Wunused-exception-parameter \
115 -Wrange-loop-analysis
117 gb_CFLAGS_COMMON
+= \
121 gb_CXXFLAGS_COMMON
+= \
125 -Wunused-const-variable
=1
128 # GCC 8 -Wcast-function-type (included in -Wextra) unhelpfully even warns on reinterpret_cast
129 # between incompatible function types:
130 ifeq ($(shell expr
'$(GCC_VERSION)' '>=' 800),1)
131 gb_CXXFLAGS_COMMON
+= \
132 -Wno-cast-function-type
135 # If CC or CXX already include -fvisibility=hidden, don't duplicate it
136 ifeq (,$(filter -fvisibility
=hidden
,$(CC
)))
137 gb_VISIBILITY_FLAGS
:= -fvisibility
=hidden
139 gb_VISIBILITY_FLAGS_CXX
:= -fvisibility-inlines-hidden
140 gb_CXXFLAGS_COMMON
+= $(gb_VISIBILITY_FLAGS_CXX
)
142 gb_LinkTarget_LDFLAGS
+= -fstack-protector-strong
144 ifneq ($(gb_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
)
161 ifeq ($(ENABLE_OPTIMIZED
)-$(COM_IS_CLANG
),TRUE-
)
162 gb_CFLAGS_WERROR
+= -Wno-stringop-overflow
165 # This is the default in non-C++11 mode
166 ifeq ($(COM_IS_CLANG
),TRUE
)
167 gb_CXX03FLAGS
:= -std
=gnu
++98 -Werror
=c
++11-extensions
-Wno-c
++11-long-long \
168 -Wno-deprecated-declarations
170 gb_CXX03FLAGS
:= -std
=gnu
++98 -Wno-long-long \
171 -Wno-variadic-macros
-Wno-non-virtual-dtor
-Wno-deprecated-declarations
174 # On Windows MSVC only supports C90 so force gnu89 (especially in clang) to
175 # to catch potential gnu89/C90 incompatibilities locally.
176 gb_CFLAGS_COMMON
+= -std
=gnu89
178 ifeq ($(ENABLE_LTO
),TRUE
)
179 ifeq ($(COM_IS_CLANG
),TRUE
)
180 ifneq (,$(index
,iOS MACOSX
,$(OS
)))
181 gb_LTOFLAGS
:= -flto
=thin
184 gb_LTOPLUGINFLAGS
:= --plugin LLVMgold.so
187 gb_LTOFLAGS
:= -flto
$(if
$(filter-out 0,$(PARALLELISM
)),=$(PARALLELISM
)) -fuse-linker-plugin
-O2
191 gb_LinkTarget_EXCEPTIONFLAGS
:= \
195 ifeq ($(gb_ENABLE_DBGUTIL
),$(false
))
196 # Clang doesn't have this option
197 ifeq ($(HAVE_GCC_FNO_ENFORCE_EH_SPECS
),TRUE
)
198 gb_LinkTarget_EXCEPTIONFLAGS
+= \
199 -fno-enforce-eh-specs
200 gb_FilterOutClangCFLAGS
+= -fno-enforce-eh-specs
204 gb_PrecompiledHeader_EXCEPTIONFLAGS
:= $(gb_LinkTarget_EXCEPTIONFLAGS
)
207 gb_COMPILERNOOPTFLAGS
:= -O0
-fstrict-aliasing
-fstrict-overflow
208 gb_COMPILERDEBUGOPTFLAGS
:= -Og
211 gb_DEBUGINFO_FLAGS
=-glldb
212 # Clang does not know -ggdb2 or some other options
213 else ifeq ($(HAVE_GCC_GGDB2
),TRUE
)
214 gb_DEBUGINFO_FLAGS
=-ggdb2
216 gb_DEBUGINFO_FLAGS
=-g2
218 gb_LINKER_DEBUGINFO_FLAGS
=
220 # GCC 11 defaults to -gdwarf-5, which GDB 10 doesn't support in split debug info
221 ifeq ($(HAVE_GCC_SPLIT_DWARF
),TRUE
)
222 gb_DEBUGINFO_FLAGS
+=-gsplit-dwarf
223 ifeq ($(COM_IS_CLANG
),)
224 gb_DEBUGINFO_FLAGS
+=-gdwarf-4
228 ifeq ($(HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR
),TRUE
)
229 gb_DEBUGINFO_FLAGS
+=-Xclang
-debug-info-kind
=constructor
232 ifeq ($(ENABLE_GDB_INDEX
),TRUE
)
233 gb_LINKER_DEBUGINFO_FLAGS
+= -Wl
,--gdb-index
234 gb_DEBUGINFO_FLAGS
+= -ggnu-pubnames
237 gb_LinkTarget_INCLUDE
:=\
239 -I
$(BUILDDIR
)/config_
$(gb_Side
) \
241 ifeq ($(COM_IS_CLANG
),TRUE
)
242 gb_COMPILER_TEST_FLAGS
:= -Xclang
-plugin-arg-loplugin
-Xclang
--unit-test-mode
243 ifeq ($(COMPILER_PLUGIN_TOOL
),)
244 gb_COMPILER_PLUGINS
:= -Xclang
-load
-Xclang
$(BUILDDIR
)/compilerplugins
/clang
/plugin.so
-Xclang
-add-plugin
-Xclang loplugin
245 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY
),)
246 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang \
247 --warnings-only
='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
250 gb_COMPILER_PLUGINS
:= -Xclang
-load
-Xclang
$(BUILDDIR
)/compilerplugins
/clang
/plugin.so
-Xclang
-plugin
-Xclang loplugin
$(foreach plugin
,$(COMPILER_PLUGIN_TOOL
), -Xclang
-plugin-arg-loplugin
-Xclang
$(plugin
))
251 ifneq ($(UPDATE_FILES
),)
252 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang
--scope
=$(UPDATE_FILES
)
255 ifeq ($(COMPILER_PLUGINS_DEBUG
),TRUE
)
256 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang
--debug
258 # set CCACHE_CPP2=1 to prevent clang generating spurious warnings
259 gb_COMPILER_SETUP
+= CCACHE_CPP2
=1
260 gb_COMPILER_PLUGINS_SETUP
:= ICECC_EXTRAFILES
=$(SRCDIR
)/include/sal
/log-areas.dox CCACHE_EXTRAFILES
=$(SRCDIR
)/include/sal
/log-areas.dox
261 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
:= \
262 -Xclang
-plugin-arg-loplugin
-Xclang
--warnings-as-errors
264 # Set CCACHE_CPP2 to prevent GCC -Werror=implicit-fallthrough= when ccache strips comments from C
265 # code (which still needs /*fallthrough*/-style comments to silence that warning):
266 ifeq ($(ENABLE_WERROR
),TRUE
)
267 gb_COMPILER_SETUP
+= CCACHE_CPP2
=1
269 gb_COMPILER_TEST_FLAGS
:=
270 gb_COMPILER_PLUGINS
:=
271 gb_COMPILER_PLUGINS_SETUP
:=
272 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
:=
277 gb_Executable_EXT_for_build
:=
281 ifeq ($(OS_FOR_BUILD
),MACOSX
)
282 gb_Helper_LIBRARY_PATH_VAR
:= DYLD_LIBRARY_PATH
283 else ifeq ($(OS_FOR_BUILD
),AIX
)
284 gb_Helper_LIBRARY_PATH_VAR
:= LIBPATH
285 else ifeq ($(OS_FOR_BUILD
),WNT
)
286 # In theory possible if cross-compiling to some Unix from Windows,
287 # in practice strongly discouraged to even try that
288 gb_Helper_LIBRARY_PATH_VAR
:= PATH
289 else ifeq ($(OS_FOR_BUILD
),HAIKU
)
290 gb_Helper_LIBRARY_PATH_VAR
:= LIBRARY_PATH
292 gb_Helper_LIBRARY_PATH_VAR
:= LD_LIBRARY_PATH
295 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)"
297 # $(1): list of : separated directory pathnames to append to the ld path
298 define gb_Helper_extend_ld_path
299 $(gb_Helper_set_ld_path
):$(1)
302 # Convert path to file URL.
303 define gb_Helper_make_url
307 gb_Helper_get_rcfile
= $(1)rc
309 ifneq ($(gb_ENABLE_PCH
),)
310 # Enable use of .sum files for PCHs.
311 gb_COMPILER_SETUP
+= CCACHE_PCH_EXTSUM
=1
312 # CCACHE_SLOPPINESS should contain pch_defines,time_macros for PCHs.
313 gb_CCACHE_SLOPPINESS
:=
314 ifeq ($(shell test -z
"$$CCACHE_SLOPPINESS" && echo
1),1)
315 gb_CCACHE_SLOPPINESS
:= CCACHE_SLOPPINESS
=pch_defines
,time_macros
317 ifeq ($(shell echo
"$$CCACHE_SLOPPINESS" | grep
-q pch_defines | grep
-q time_macros
&& echo
1),1)
318 gb_CCACHE_SLOPPINESS
:= CCACHE_SLOPPINESS
=$CCACHE_SLOPPINESS:pch_defines
,time_macros
321 gb_COMPILER_SETUP
+= $(gb_CCACHE_SLOPPINESS
)
324 ifneq ($(CCACHE_DEPEND_MODE
),)
325 gb_COMPILER_SETUP
+= CCACHE_DEPEND
=1
328 # vim: set noet sw=4: