Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / platform / com_GCC_defs.mk
blob93b35a4884a3c75c1a4b63616f2680ad8ecb3d55
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/.
10 gb_AWK := awk
11 gb_YACC := bison
13 gb_CLASSPATHSEP := :
14 gb_LICENSE := LICENSE
15 gb_README = README_$(1)
17 # use CC/CXX if they are nondefaults
18 ifneq ($(origin CC),default)
19 gb_CC := $(CC)
20 gb_GCCP := $(CC)
21 else
22 gb_CC := gcc
23 gb_GCCP := gcc
24 endif
26 ifneq ($(origin CXX),default)
27 gb_CXX := $(CXX)
28 else
29 gb_CXX := g++
30 endif
32 ifneq ($(origin AR),default)
33 gb_AR := $(AR)
34 else
35 gb_AR := $(shell $(CC) -print-prog-name=ar)
36 endif
38 ifeq ($(strip $(gb_COMPILEROPTFLAGS)),)
39 gb_COMPILEROPTFLAGS := -O2
40 endif
42 gb_SHORTSTDC3 := 1
43 gb_SHORTSTDCPP3 := 6
45 gb_CPPU_ENV := gcc3
47 gb_AFLAGS := $(AFLAGS)
49 gb_COMPILERDEFS := \
50 -DBOOST_ERROR_CODE_HEADER_ONLY \
51 -DBOOST_SYSTEM_NO_DEPRECATED \
52 -DCPPU_ENV=$(gb_CPPU_ENV) \
54 gb_CFLAGS_COMMON := \
55 -Wall \
56 -Wendif-labels \
57 -Wextra \
58 -Wstrict-prototypes \
59 -Wundef \
60 -Wunused-macros \
61 -fmessage-length=0 \
62 -fno-common \
63 -pipe \
65 gb_CXXFLAGS_COMMON := \
66 -Wall \
67 -Wno-missing-braces \
68 -Wnon-virtual-dtor \
69 -Wendif-labels \
70 -Wextra \
71 -Wundef \
72 -Wunused-macros \
73 -fmessage-length=0 \
74 -fno-common \
75 -pipe \
77 gb_CXXFLAGS_Wundef = -Wno-undef
79 ifneq ($(HAVE_THREADSAFE_STATICS),TRUE)
80 gb_CXXFLAGS_COMMON += -fno-threadsafe-statics
81 endif
83 ifeq ($(strip $(gb_GCOV)),YES)
84 gb_CFLAGS_COMMON += -fprofile-arcs -ftest-coverage
85 gb_CXXFLAGS_COMMON += -fprofile-arcs -ftest-coverage
86 gb_LinkTarget_LDFLAGS += -fprofile-arcs -lgcov
87 gb_COMPILEROPTFLAGS := -O0
88 endif
91 ifeq ($(HAVE_GCC_VISIBILITY_FEATURE),TRUE)
92 gb_VISIBILITY_FLAGS := -DHAVE_GCC_VISIBILITY_FEATURE
93 # If CC or CXX already include -fvisibility=hidden, don't duplicate it
94 ifeq (,$(filter -fvisibility=hidden,$(CC)))
95 gb__visibility_hidden := -fvisibility=hidden
96 ifeq ($(COM_GCC_IS_CLANG),TRUE)
97 ifneq ($(filter -fsanitize=%,$(CC)),)
98 gb__visibility_hidden := -fvisibility-ms-compat
99 endif
100 endif
101 gb_VISIBILITY_FLAGS += $(gb__visibility_hidden)
102 endif
103 ifneq ($(HAVE_GCC_VISIBILITY_BROKEN),TRUE)
104 gb_VISIBILITY_FLAGS_CXX := -fvisibility-inlines-hidden
105 endif
106 endif
107 gb_CXXFLAGS_COMMON += $(gb_VISIBILITY_FLAGS_CXX)
109 ifeq ($(HAVE_GCC_STACK_PROTECTOR_STRONG),TRUE)
110 gb_CFLAGS_COMMON += -fstack-protector-strong
111 gb_CXXFLAGS_COMMON += -fstack-protector-strong
112 gb_LinkTarget_LDFLAGS += -fstack-protector-strong
113 endif
115 gb_CFLAGS_WERROR := $(if $(ENABLE_WERROR),-Werror)
117 # This is the default in non-C++11 mode
118 ifeq ($(COM_GCC_IS_CLANG),TRUE)
119 gb_CXX03FLAGS := -std=gnu++98 -Werror=c++11-extensions -Wno-c++11-long-long \
120 -Wno-deprecated-declarations
121 else
122 gb_CXX03FLAGS := -std=gnu++98 -pedantic-errors -Wno-long-long \
123 -Wno-variadic-macros -Wno-non-virtual-dtor -Wno-deprecated-declarations
124 endif
126 # On Windows MSVC only supports C90 so force gnu89 (especially in clang) to
127 # to catch potential gnu89/C90 incompatibilities locally.
128 gb_CFLAGS_COMMON += -std=gnu89
130 ifeq ($(ENABLE_LTO),TRUE)
131 ifeq ($(COM_GCC_IS_CLANG),TRUE)
132 gb_LTOFLAGS := -flto
133 else
134 gb_LTOFLAGS := -flto=$(PARALLELISM) -fuse-linker-plugin -O2
135 endif
136 endif
138 gb_LinkTarget_EXCEPTIONFLAGS := \
139 -DEXCEPTIONS_ON \
140 -fexceptions
142 ifeq ($(gb_ENABLE_DBGUTIL),$(false))
143 # Clang doesn't have this option
144 ifeq ($(HAVE_GCC_FNO_ENFORCE_EH_SPECS),TRUE)
145 gb_LinkTarget_EXCEPTIONFLAGS += \
146 -fno-enforce-eh-specs
147 endif
148 endif
150 gb_PrecompiledHeader_EXCEPTIONFLAGS := $(gb_LinkTarget_EXCEPTIONFLAGS)
152 # optimization level
153 gb_COMPILERNOOPTFLAGS := -O0 -fstrict-aliasing -fstrict-overflow
155 # Clang does not know -ggdb2 or some other options
156 ifeq ($(HAVE_GCC_GGDB2),TRUE)
157 GGDB2=-ggdb2
158 else
159 GGDB2=-g2
160 endif
162 ifeq ($(HAVE_GCC_FINLINE_LIMIT),TRUE)
163 FINLINE_LIMIT0=-finline-limit=0
164 endif
166 ifeq ($(HAVE_GCC_FNO_INLINE),TRUE)
167 FNO_INLINE=-fno-inline
168 endif
170 ifeq ($(HAVE_GCC_FNO_DEFAULT_INLINE),TRUE)
171 FNO_DEFAULT_INLINE=-fno-default-inline
172 endif
174 gb_DEBUG_CFLAGS := $(GGDB2) $(FINLINE_LIMIT0) $(FNO_INLINE)
175 gb_DEBUG_CXXFLAGS := $(FNO_DEFAULT_INLINE)
178 gb_LinkTarget_INCLUDE :=\
179 $(subst -I. , ,$(SOLARINC)) \
180 -I$(BUILDDIR)/config_$(gb_Side) \
182 ifeq ($(COM_GCC_IS_CLANG),TRUE)
183 ifeq ($(COMPILER_PLUGIN_TOOL),)
184 gb_COMPILER_PLUGINS := -Xclang -load -Xclang $(BUILDDIR)/compilerplugins/obj/plugin.so -Xclang -add-plugin -Xclang loplugin
185 ifneq ($(COMPILER_PLUGIN_WARNINGS_ONLY),)
186 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang \
187 --warnings-only='$(COMPILER_PLUGIN_WARNINGS_ONLY)'
188 endif
189 else
190 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))
191 ifneq ($(UPDATE_FILES),)
192 gb_COMPILER_PLUGINS += -Xclang -plugin-arg-loplugin -Xclang --scope=$(UPDATE_FILES)
193 endif
194 endif
195 # extra EF variable to make the command line shorter (just like is done with $(SRCDIR) etc.)
196 gb_COMPILER_PLUGINS_SETUP := EF=$(SRCDIR)/include/sal/log-areas.dox && ICECC_EXTRAFILES=$$EF CCACHE_EXTRAFILES=$$EF
197 else
198 gb_COMPILER_PLUGINS :=
199 gb_COMPILER_PLUGINS_SETUP :=
200 endif
202 # Executable class
204 gb_Executable_EXT_for_build :=
206 # Helper class
208 ifeq ($(OS_FOR_BUILD),MACOSX)
209 gb_Helper_LIBRARY_PATH_VAR := DYLD_LIBRARY_PATH
210 else ifeq ($(OS_FOR_BUILD),AIX)
211 gb_Helper_LIBRARY_PATH_VAR := LIBPATH
212 else ifeq ($(OS_FOR_BUILD),WNT)
213 # In theory possible if cross-compiling to some Unix from Windows,
214 # in practice strongly discouraged to even try that
215 gb_Helper_LIBRARY_PATH_VAR := PATH
216 else
217 gb_Helper_LIBRARY_PATH_VAR := LD_LIBRARY_PATH
218 endif
220 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)"
222 # $(1): list of : separated directory pathnames to append to the ld path
223 define gb_Helper_extend_ld_path
224 $(gb_Helper_set_ld_path):$(1)
225 endef
227 # Convert path to file URL.
228 define gb_Helper_make_url
229 file://$(strip $(1))
230 endef
232 gb_Helper_get_rcfile = $(1)rc
234 # vim: set noet sw=4: