Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / solenv / gbuild / gbuild.mk
blobf14e9f1a1ed4bcb01092d455de138d844b2d1f76
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/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 GBUILDDIR:=$(SRCDIR)/solenv/gbuild
22 # vars needed from the env/calling makefile
24 # DEBUG
25 # JAVA_HOME
26 # LIBXML_CFLAGS
27 # OS
28 # SOLARINC
29 # UPD
31 # PTHREAD_CFLAGS (Linux)
32 # SYSTEM_ICU (Linux)
33 # SYSTEM_LIBJPEG (Linux)
34 # SYSTEM_LIBXML (Linux)
36 .DELETE_ON_ERROR:
38 # do not use built-in rules
39 # DO NOT TOUCH THIS LINE UNLESS YOU REALLY KNOW WHAT YOU ARE DOING
40 # REMOVING THIS MAKES e.g. MODULE SW ALONE SLOWER BY SOME 300%
41 # FOR TAIL_BUILD THE IMPACT IS HUGE!
42 # (unless you are doing make -r, which we should explicitly NOT require from
43 # users)
44 MAKEFLAGS += r
45 .SUFFIXES:
47 true := T
48 false :=
49 gb_not = $(if $(1),$(false),$(true))
51 define NEWLINE
54 endef
56 define WHITESPACE
58 endef
60 COMMA :=,
62 OPEN_PAREN :=(
63 CLOSE_PAREN :=)
65 gb_SPACE:=$(gb_SPACE) $(gb_SPACE)
67 gb_VERBOSE := $(verbose)
69 include $(GBUILDDIR)/Helper.mk
71 include $(GBUILDDIR)/Conditions.mk
73 include $(SRCDIR)/solenv/inc/langlist.mk
75 # optional extensions that should never be essential
76 ifneq ($(wildcard $(GBUILDDIR)/extensions/pre_*.mk),)
77 include $(wildcard $(GBUILDDIR)/extensions/pre_*.mk)
78 endif
80 include $(GBUILDDIR)/Output.mk
82 gb_TIMELOG := 0
83 ifneq ($(strip $(TIMELOG)$(timelog)),)
84 gb_TIMELOG := 1
85 endif
87 ifneq ($(ENABLE_DBGUTIL),)
88 gb_ENABLE_DBGUTIL := $(true)
89 else
90 gb_ENABLE_DBGUTIL := $(false)
91 endif
93 gb_ENABLE_SYMBOLS_FOR := $(ENABLE_SYMBOLS_FOR)
95 # ENABLE_SYMBOLS (presumably from the command line)
96 ifneq ($(strip $(ENABLE_SYMBOLS)),)
97 gb_ENABLE_SYMBOLS_FOR := $(ENABLE_SYMBOLS)
98 endif
99 ifneq ($(strip $(enable_symbols)),)
100 gb_ENABLE_SYMBOLS_FOR := $(enable_symbols)
101 endif
103 # note: ENABLE_BREAKPAD turns on symbols
104 ifneq ($(strip $(ENABLE_BREAKPAD)),)
105 gb_ENABLE_SYMBOLS_FOR := all
106 endif
108 gb_DEBUGLEVEL := 0
109 ifneq ($(strip $(DEBUG)),)
110 gb_DEBUGLEVEL := 1
111 # make DEBUG=true should force -g
112 ifeq ($(origin DEBUG),command line)
113 gb_ENABLE_SYMBOLS_FOR := all
114 endif
115 endif
116 ifneq ($(strip $(debug)),)
117 gb_DEBUGLEVEL := 1
118 ifeq ($(origin debug),command line)
119 gb_ENABLE_SYMBOLS_FOR := all
120 endif
121 endif
122 ifeq ($(gb_ENABLE_DBGUTIL),$(true))
123 gb_DEBUGLEVEL := 1
124 endif
126 ifneq ($(strip $(DBGLEVEL)),)
127 gb_DEBUGLEVEL := $(strip $(DBGLEVEL))
128 ifeq ($(origin DBGLEVEL),command line)
129 gb_ENABLE_SYMBOLS_FOR := all
130 endif
131 endif
132 ifneq ($(strip $(dbglevel)),)
133 gb_DEBUGLEVEL := $(strip $(dbglevel))
134 ifeq ($(origin dbglevel),command line)
135 gb_ENABLE_SYMBOLS_FOR := all
136 endif
137 endif
139 # handle special cases
140 ifeq ($(gb_ENABLE_SYMBOLS_FOR),1)
141 gb_ENABLE_SYMBOLS_FOR := all
142 endif
143 ifeq ($(gb_ENABLE_SYMBOLS_FOR),0)
144 gb_ENABLE_SYMBOLS_FOR :=
145 endif
146 ifeq ($(gb_ENABLE_SYMBOLS_FOR),yes)
147 gb_ENABLE_SYMBOLS_FOR := all
148 endif
149 ifeq ($(gb_ENABLE_SYMBOLS_FOR),no)
150 gb_ENABLE_SYMBOLS_FOR :=
151 endif
153 # Detect whether symbols should be enabled for the given gbuild target.
154 # enable if: no "-TARGET" defined AND [module is enabled OR "TARGET" defined]
155 gb_target_symbols_enabled = \
156 $(and $(if $(filter -$(1),$(ENABLE_SYMBOLS_FOR)),,$(true)),\
157 $(or $(gb_Module_CURRENTMODULE_SYMBOLS_ENABLED),\
158 $(filter $(1),$(ENABLE_SYMBOLS_FOR))))
160 ifeq ($(BLOCK_PCH),)
161 gb_ENABLE_PCH := $(ENABLE_PCH)
162 else
163 # Setting BLOCK_PCH effectively disables PCH, but the extra object file will be still linked in.
164 # This is useful for rebuilding only some files with PCH disabled, e.g. to check #include's,
165 # disabling the whole ENABLE_PCH would lead to unresolved symbols at link time.
166 gb_ENABLE_PCH :=
167 endif
169 ifneq ($(nodep)$(ENABLE_PRINT_DEPS),)
170 gb_FULLDEPS := $(false)
171 else
172 gb_FULLDEPS := $(true)
173 endif
175 ifneq ($(strip $(patches)$(PATCHES)),)
176 gb_KEEP_PRISTINE := $(true)
177 else
178 gb_KEEP_PRISTINE := $(false)
179 endif
181 ifeq ($(findstring s,$(MAKEFLAGS)),)
182 gb_QUIET_EXTERNAL := $(false)
183 else
184 gb_QUIET_EXTERNAL := $(true)
185 endif
187 # save user-supplied flags for latter use
188 ifneq ($(strip $(ENVCFLAGS)),)
189 gb__ENV_CFLAGS := $(ENVCFLAGS)
190 endif
191 ifneq ($(strip $(ENVCFLAGSCXX)),)
192 gb__ENV_CXXFLAGS := $(ENVCFLAGSCXX)
193 endif
195 include $(GBUILDDIR)/ExternalExecutable.mk
196 include $(GBUILDDIR)/TargetLocations.mk
198 define gb_var2file
199 $(file >$(1),$(2))$(1)
200 endef
202 $(eval $(call gb_Helper_init_registries))
203 include $(SRCDIR)/Repository.mk
204 include $(SRCDIR)/RepositoryExternal.mk
205 $(eval $(call gb_Helper_collect_knownlibs))
207 gb_Library_DLLPOSTFIX := lo
208 gb_RUN_CONFIGURE :=
210 gb_CONFIGURE_PLATFORMS := --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)
212 # Include platform/cpu/compiler specific config/definitions
214 include $(GBUILDDIR)/platform/$(OS)_$(CPUNAME)_$(COM).mk
216 # this is optional
217 include $(SRCDIR)/RepositoryFixes.mk
219 # after platform; at least currently python depends on variable set in platform
220 $(eval $(call gb_ExternalExecutable_collect_registrations))
222 # add user-supplied flags
223 ifneq ($(strip gb__ENV_CFLAGS),)
224 gb_LinkTarget_CFLAGS += $(gb__ENV_CFLAGS)
225 endif
226 ifneq ($(strip gb__ENV_CXXFLAGS),)
227 gb_LinkTarget_CXXFLAGS += $(gb__ENV_CXXFLAGS)
228 endif
230 gb_CPUDEFS += -D$(CPUNAME)
232 gb_GLOBALDEFS := \
233 -D_REENTRANT \
234 -DOSL_DEBUG_LEVEL=$(gb_DEBUGLEVEL) \
235 $(gb_OSDEFS) \
236 $(gb_COMPILERDEFS) \
237 $(gb_CPUDEFS) \
239 ifeq ($(gb_ENABLE_DBGUTIL),$(true))
240 gb_GLOBALDEFS += -DDBG_UTIL
242 ifneq ($(COM)-$(MSVC_USE_DEBUG_RUNTIME),MSC-)
243 gb_GLOBALDEFS += -D_DEBUG
244 endif
245 endif
247 ifeq ($(gb_TIMELOG),1)
248 gb_GLOBALDEFS += -DTIMELOG \
250 endif
252 ifeq ($(strip $(ASSERT_ALWAYS_ABORT)),FALSE)
253 gb_GLOBALDEFS += -DNDEBUG \
255 endif
257 ifeq ($(ENABLE_SAL_LOG),TRUE)
258 gb_GLOBALDEFS += -DSAL_LOG_INFO \
259 -DSAL_LOG_WARN \
261 endif
263 ifneq ($(gb_DEBUGLEVEL),0)
264 ifneq ($(gb_DEBUGLEVEL),1) # 2 or more
265 gb_GLOBALDEFS += -DDEBUG \
267 endif
268 endif
270 gb_GLOBALDEFS += \
271 $(call gb_Helper_define_if_set,\
272 DISABLE_DYNLOADING \
275 gb_GLOBALDEFS := $(sort $(gb_GLOBALDEFS))
277 # Common environment variables passed into all gb_*Test classes:
278 # * Cap the number of threads unittests use:
279 gb_TEST_ENV_VARS := MAX_CONCURRENCY=4
280 # * Disable searching for certificates by default:
282 # see xmlsecurity/source/xmlsec/nss/nssinitializer.cxx for use
284 # a) If MOZILLA_CERTIFICATE_FOLDER is empty then LibreOffice autodetects
285 # the user's mozilla-descended application profile. To disable that we
286 # use a non-empty string here.
288 # b) Using dbm: appears to nss as equivalent to an empty path so the
289 # initial NSS_InitReadWrite will fail. In response to that failure
290 # LibreOffice will create a temp fallback cert database which is removed
291 # on process exit
292 gb_TEST_ENV_VARS += MOZILLA_CERTIFICATE_FOLDER=dbm:
293 # Avoid hanging if the cups daemon requests a password:
294 gb_TEST_ENV_VARS += SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION=1
295 ifeq (,$(SAL_USE_VCLPLUGIN))
296 gb_TEST_ENV_VARS += SAL_USE_VCLPLUGIN=svp
297 endif
299 # This is used to detect whether LibreOffice is being built (as opposed to building
300 # 3rd-party code). Used for tag deprecation for API we want to
301 # ensure is not used at all externally while we clean
302 # out our internal usage, for code in sal/ that should be used only internally, etc.
303 gb_DEFS_INTERNAL := \
304 -DLIBO_INTERNAL_ONLY \
306 include $(GBUILDDIR)/Deliver.mk
308 $(eval $(call gb_Deliver_init))
310 include $(GBUILDDIR)/Trace.mk
312 # We are using a set of scopes that we might as well call classes.
314 # TODO: to what extent is the following still true?
315 # It is important to include them in the right order as that is
316 # -- at least in part -- defining precedence. This is not an issue in the
317 # WORKDIR as there are no naming collisions there, but INSTDIR is a mess
318 # and precedence is important there. This is also platform dependent.
320 # This is less of an issue with GNU Make versions > 3.82 which matches for
321 # shortest stem instead of first match. However, upon introduction this version
322 # is not available everywhere by default.
324 include $(foreach class, \
325 ComponentTarget \
326 Postprocess \
327 AllLangMoTarget \
328 WinResTarget \
329 LinkTarget \
330 Library \
331 StaticLibrary \
332 Executable \
333 SdiTarget \
334 Package \
335 ExternalPackage \
336 CustomTarget \
337 ExternalProject \
338 Gallery \
339 Pagein \
340 PrecompiledHeaders \
341 Pyuno \
342 PythonTest \
343 UITest \
344 Rdb \
345 CppunitTest \
346 Jar \
347 JavaClassSet \
348 JunitTest \
349 Module \
350 UIConfig \
351 UnoApiTarget \
352 UnoApi \
353 UnpackedTarball \
354 InternalUnoApi \
355 CliAssembly \
356 CliLibrary \
357 CliNativeLibrary \
358 CliUnoApi \
359 Zip \
360 AllLangPackage \
361 Configuration \
362 HelpTarget \
363 AllLangHelp \
364 Extension \
365 ExtensionPackage \
366 Dictionary \
367 InstallModuleTarget \
368 InstallModule \
369 InstallScript \
370 AutoInstall \
371 PackageSet \
372 GeneratedPackage \
373 CompilerTest \
374 ,$(GBUILDDIR)/$(class).mk)
376 $(eval $(call gb_Helper_process_executable_registrations))
377 $(eval $(call gb_Postprocess_make_targets))
379 # optional extensions that should never be essential
380 ifneq ($(wildcard $(GBUILDDIR)/extensions/post_*.mk),)
381 include $(wildcard $(GBUILDDIR)/extensions/post_*.mk)
382 endif
384 define gb_Extensions_final_hook
385 ifneq ($(wildcard $(GBUILDDIR)/extensions/final_*.mk),)
386 include $(wildcard $(GBUILDDIR)/extensions/final_*.mk)
387 endif
389 endef
391 # Setup for ccache.
392 ifneq ($(gb_ENABLE_PCH),)
393 # CCACHE_SLOPPINESS should contain pch_defines,time_macros for PCHs.
394 gb_CCACHE_SLOPPINESS :=
395 ifeq ($(shell test -z "$$CCACHE_SLOPPINESS" && echo 1),1)
396 gb_CCACHE_SLOPPINESS := CCACHE_SLOPPINESS=pch_defines,time_macros
397 else
398 ifeq ($(shell echo "$$CCACHE_SLOPPINESS" | grep -q pch_defines | grep -q time_macros && echo 1),1)
399 gb_CCACHE_SLOPPINESS := CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS:pch_defines,time_macros
400 endif
401 endif
402 gb_COMPILER_SETUP += $(gb_CCACHE_SLOPPINESS)
403 endif
405 ifneq ($(CCACHE_DEPEND_MODE),)
406 gb_COMPILER_SETUP += CCACHE_DEPEND=1
407 endif
409 # vim: set noet sw=4: