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 \
70 -fstack-protector-strong \
72 gb_CXXFLAGS_COMMON
:= \
80 $(if
$(and
$(COM_IS_CLANG
),$(or
$(findstring icecc
,$(CC
)),$(findstring icecc
,$(CCACHE_PREFIX
)))),,-Wunused-macros
) \
81 -finput-charset
=UTF-8 \
85 -fstack-protector-strong \
87 gb_CXXFLAGS_DISABLE_WARNINGS
= -w
89 ifeq ($(HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED
),TRUE
)
90 gb_CXXFLAGS_COMMON
+= -Wno-maybe-uninitialized
93 gb_CXXFLAGS_Wundef
= -Wno-undef
95 ifeq ($(strip $(gb_GCOV
)),YES
)
96 gb_CFLAGS_COMMON
+= -fprofile-arcs
-ftest-coverage
97 gb_CXXFLAGS_COMMON
+= -fprofile-arcs
-ftest-coverage
98 gb_LinkTarget_LDFLAGS
+= -fprofile-arcs
-lgcov
99 gb_COMPILEROPTFLAGS
:= -O0
102 ifeq ($(DISABLE_DYNLOADING
),TRUE
)
103 gb_CFLAGS_COMMON
+= -ffunction-sections
-fdata-sections
104 gb_CXXFLAGS_COMMON
+= -ffunction-sections
-fdata-sections
105 gb_LinkTarget_LDFLAGS
+= -Wl
,--gc-sections
108 ifeq ($(COM_IS_CLANG
),TRUE
)
109 gb_CXXFLAGS_COMMON
+= \
110 -Wimplicit-fallthrough \
111 -Wunused-exception-parameter \
112 -Wrange-loop-analysis
114 gb_CFLAGS_COMMON
+= \
118 gb_CXXFLAGS_COMMON
+= \
122 -Wunused-const-variable
=1
125 # GCC 8 -Wcast-function-type (included in -Wextra) unhelpfully even warns on reinterpret_cast
126 # between incompatible function types:
127 ifeq ($(shell expr
'$(GCC_VERSION)' '>=' 800),1)
128 gb_CXXFLAGS_COMMON
+= \
129 -Wno-cast-function-type
132 # If CC or CXX already include -fvisibility=hidden, don't duplicate it
133 ifeq (,$(filter -fvisibility
=hidden
,$(CC
)))
134 gb_VISIBILITY_FLAGS
:= -fvisibility
=hidden
136 gb_VISIBILITY_FLAGS_CXX
:= -fvisibility-inlines-hidden
137 gb_CXXFLAGS_COMMON
+= $(gb_VISIBILITY_FLAGS_CXX
)
139 gb_LinkTarget_LDFLAGS
+= -fstack-protector-strong
141 ifneq ($(ENABLE_PCH
),)
142 ifeq ($(COM_IS_CLANG
),TRUE
)
143 # Clang by default includes in the PCH timestamps of the files it was
144 # generated from, which would make the PCH be a "new" file for ccache
145 # even if the file has not actually changed. Disabling the timestamp
146 # prevents this at the cost of risking using an outdated PCH (which
147 # should be unlikely, given that gbuild has dependencies set up
148 # for our includes and system includes are unlikely to change).
149 gb_NO_PCH_TIMESTAMP
:= -Xclang
-fno-pch-timestamp
151 gb_CFLAGS_COMMON
+= -fpch-preprocess
-Winvalid-pch
152 gb_CXXFLAGS_COMMON
+= -fpch-preprocess
-Winvalid-pch
153 gb_NO_PCH_TIMESTAMP
:=
157 gb_CFLAGS_WERROR
= $(if
$(ENABLE_WERROR
),-Werror
)
159 # This is the default in non-C++11 mode
160 ifeq ($(COM_IS_CLANG
),TRUE
)
161 gb_CXX03FLAGS
:= -std
=gnu
++98 -Werror
=c
++11-extensions
-Wno-c
++11-long-long \
162 -Wno-deprecated-declarations
164 gb_CXX03FLAGS
:= -std
=gnu
++98 -Wno-long-long \
165 -Wno-variadic-macros
-Wno-non-virtual-dtor
-Wno-deprecated-declarations
168 # On Windows MSVC only supports C90 so force gnu89 (especially in clang) to
169 # to catch potential gnu89/C90 incompatibilities locally.
170 gb_CFLAGS_COMMON
+= -std
=gnu89
172 ifeq ($(ENABLE_LTO
),TRUE
)
173 ifeq ($(COM_IS_CLANG
),TRUE
)
175 gb_LTOPLUGINFLAGS
:= --plugin LLVMgold.so
177 gb_LTOFLAGS
:= -flto
=$(PARALLELISM
) -fuse-linker-plugin
-O2
181 gb_LinkTarget_EXCEPTIONFLAGS
:= \
185 ifeq ($(gb_ENABLE_DBGUTIL
),$(false
))
186 # Clang doesn't have this option
187 ifeq ($(HAVE_GCC_FNO_ENFORCE_EH_SPECS
),TRUE
)
188 gb_LinkTarget_EXCEPTIONFLAGS
+= \
189 -fno-enforce-eh-specs
193 gb_PrecompiledHeader_EXCEPTIONFLAGS
:= $(gb_LinkTarget_EXCEPTIONFLAGS
)
196 gb_COMPILERNOOPTFLAGS
:= -O0
-fstrict-aliasing
-fstrict-overflow
199 gb_DEBUGINFO_FLAGS
=-glldb
200 # Clang does not know -ggdb2 or some other options
201 else ifeq ($(HAVE_GCC_GGDB2
),TRUE
)
202 gb_DEBUGINFO_FLAGS
=-ggdb2
204 gb_DEBUGINFO_FLAGS
=-g2
206 gb_LINKER_DEBUGINFO_FLAGS
=
208 ifeq ($(HAVE_GCC_SPLIT_DWARF
),TRUE
)
209 gb_DEBUGINFO_FLAGS
+=-gsplit-dwarf
212 ifeq ($(ENABLE_GDB_INDEX
),TRUE
)
213 gb_LINKER_DEBUGINFO_FLAGS
+= -Wl
,--gdb-index
214 gb_DEBUGINFO_FLAGS
+= -ggnu-pubnames
217 gb_LinkTarget_INCLUDE
:=\
219 -I
$(BUILDDIR
)/config_
$(gb_Side
) \
221 ifeq ($(COM_IS_CLANG
),TRUE
)
222 gb_COMPILER_TEST_FLAGS
:= -Xclang
-plugin-arg-loplugin
-Xclang
--unit-test-mode
223 ifeq ($(COMPILER_PLUGIN_TOOL
),)
224 gb_COMPILER_PLUGINS
:= -Xclang
-load
-Xclang
$(BUILDDIR
)/compilerplugins
/clang
/plugin.so
-Xclang
-add-plugin
-Xclang loplugin
225 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY
),)
226 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang \
227 --warnings-only
='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
230 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
))
231 ifneq ($(UPDATE_FILES
),)
232 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang
--scope
=$(UPDATE_FILES
)
235 ifeq ($(COMPILER_PLUGINS_DEBUG
),TRUE
)
236 gb_COMPILER_PLUGINS
+= -Xclang
-plugin-arg-loplugin
-Xclang
--debug
238 # set CCACHE_CPP2=1 to prevent clang generating spurious warnings
239 gb_COMPILER_SETUP
+= CCACHE_CPP2
=1
240 gb_COMPILER_PLUGINS_SETUP
:= ICECC_EXTRAFILES
=$(SRCDIR
)/include/sal
/log-areas.dox CCACHE_EXTRAFILES
=$(SRCDIR
)/include/sal
/log-areas.dox
241 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
:= \
242 -Xclang
-plugin-arg-loplugin
-Xclang
--warnings-as-errors
244 # Set CCACHE_CPP2 to prevent GCC -Werror=implicit-fallthrough= when ccache strips comments from C
245 # code (which still needs /*fallthrough*/-style comments to silence that warning):
246 ifeq ($(ENABLE_WERROR
),TRUE
)
247 gb_COMPILER_SETUP
+= CCACHE_CPP2
=1
249 gb_COMPILER_TEST_FLAGS
:=
250 gb_COMPILER_PLUGINS
:=
251 gb_COMPILER_PLUGINS_SETUP
:=
252 gb_COMPILER_PLUGINS_WARNINGS_AS_ERRORS
:=
257 gb_Executable_EXT_for_build
:=
261 ifeq ($(OS_FOR_BUILD
),MACOSX
)
262 gb_Helper_LIBRARY_PATH_VAR
:= DYLD_LIBRARY_PATH
263 else ifeq ($(OS_FOR_BUILD
),AIX
)
264 gb_Helper_LIBRARY_PATH_VAR
:= LIBPATH
265 else ifeq ($(OS_FOR_BUILD
),WNT
)
266 # In theory possible if cross-compiling to some Unix from Windows,
267 # in practice strongly discouraged to even try that
268 gb_Helper_LIBRARY_PATH_VAR
:= PATH
269 else ifeq ($(OS_FOR_BUILD
),HAIKU
)
270 gb_Helper_LIBRARY_PATH_VAR
:= LIBRARY_PATH
272 gb_Helper_LIBRARY_PATH_VAR
:= LD_LIBRARY_PATH
275 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)"
277 # $(1): list of : separated directory pathnames to append to the ld path
278 define gb_Helper_extend_ld_path
279 $(gb_Helper_set_ld_path
):$(1)
282 # Convert path to file URL.
283 define gb_Helper_make_url
287 gb_Helper_get_rcfile
= $(1)rc
289 ifneq ($(ENABLE_PCH
),)
290 # Enable use of .sum files for PCHs.
291 gb_COMPILER_SETUP
+= CCACHE_PCH_EXTSUM
=1
292 # CCACHE_SLOPPINESS should contain pch_defines,time_macros for PCHs.
293 gb_CCACHE_SLOPPINESS
:=
294 ifeq ($(shell test -z
"$$CCACHE_SLOPPINESS" && echo
1),1)
295 gb_CCACHE_SLOPPINESS
:= CCACHE_SLOPPINESS
=pch_defines
,time_macros
297 ifeq ($(shell echo
"$$CCACHE_SLOPPINESS" | grep
-q pch_defines | grep
-q time_macros
&& echo
1),1)
298 gb_CCACHE_SLOPPINESS
:= CCACHE_SLOPPINESS
=$CCACHE_SLOPPINESS:pch_defines
,time_macros
301 gb_COMPILER_SETUP
+= $(gb_CCACHE_SLOPPINESS
)
304 ifneq ($(CCACHE_DEPEND_MODE
),)
305 gb_COMPILER_SETUP
+= CCACHE_DEPEND
=1
308 # vim: set noet sw=4: