gbuild trace: disable flock for wsl-as-helper case
[LibreOffice.git] / solenv / gbuild / gbuild.mk
blob2f5704896d42e0b3e37ee760808547513463066a
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 ifeq ($(strip $(dbglevel)),)
88 ifeq ($(debug),)
89 dbglevel := 0
90 else
91 dbglevel := 1
92 endif
93 endif
95 gb_ENABLE_SYMBOLS_FOR := $(ENABLE_SYMBOLS_FOR)
97 # enable_symbols (presumably from the command line)
98 ifneq ($(strip $(enable_symbols)),)
99 gb_ENABLE_SYMBOLS_FOR := $(enable_symbols)
100 endif
101 ifeq ($(origin debug),command line)
102 gb_ENABLE_SYMBOLS_FOR := all
103 endif
104 ifeq ($(origin dbglevel),command line)
105 gb_ENABLE_SYMBOLS_FOR := all
106 endif
108 # note: ENABLE_BREAKPAD turns on symbols
109 ifneq ($(strip $(ENABLE_BREAKPAD)),)
110 gb_ENABLE_SYMBOLS_FOR := all
111 endif
113 # handle special cases
114 ifeq ($(gb_ENABLE_SYMBOLS_FOR),1)
115 gb_ENABLE_SYMBOLS_FOR := all
116 endif
117 ifeq ($(gb_ENABLE_SYMBOLS_FOR),0)
118 gb_ENABLE_SYMBOLS_FOR :=
119 endif
120 ifeq ($(gb_ENABLE_SYMBOLS_FOR),yes)
121 gb_ENABLE_SYMBOLS_FOR := all
122 endif
123 ifeq ($(gb_ENABLE_SYMBOLS_FOR),no)
124 gb_ENABLE_SYMBOLS_FOR :=
125 endif
127 # Detect whether symbols should be enabled for the given gbuild target.
128 # enable if: no "-TARGET" defined AND [module is enabled OR "TARGET" defined]
129 gb_target_symbols_enabled = \
130 $(and $(if $(filter -$(1),$(ENABLE_SYMBOLS_FOR)),,$(true)),\
131 $(or $(gb_Module_CURRENTMODULE_SYMBOLS_ENABLED),\
132 $(filter $(1),$(ENABLE_SYMBOLS_FOR))))
134 ifeq ($(BLOCK_PCH),)
135 gb_ENABLE_PCH := $(ENABLE_PCH)
136 else
137 # Setting BLOCK_PCH effectively disables PCH, but the extra object file will be still linked in.
138 # This is useful for rebuilding only some files with PCH disabled, e.g. to check #include's,
139 # disabling the whole ENABLE_PCH would lead to unresolved symbols at link time.
140 gb_ENABLE_PCH :=
141 endif
143 ifneq ($(nodep)$(ENABLE_PRINT_DEPS),)
144 gb_FULLDEPS := $(false)
145 else
146 gb_FULLDEPS := $(true)
147 endif
149 ifneq ($(strip $(patches)$(PATCHES)),)
150 gb_KEEP_PRISTINE := $(true)
151 else
152 gb_KEEP_PRISTINE := $(false)
153 endif
155 ifeq ($(findstring s,$(MAKEFLAGS)),)
156 gb_QUIET_EXTERNAL := $(false)
157 else
158 gb_QUIET_EXTERNAL := $(true)
159 endif
161 # save user-supplied flags for latter use
162 ifneq ($(strip $(ENVCFLAGS)),)
163 gb__ENV_CFLAGS := $(ENVCFLAGS)
164 endif
165 ifneq ($(strip $(ENVCFLAGSCXX)),)
166 gb__ENV_CXXFLAGS := $(ENVCFLAGSCXX)
167 endif
169 include $(GBUILDDIR)/ExternalExecutable.mk
170 include $(GBUILDDIR)/TargetLocations.mk
172 define gb_var2file
173 $(file >$(1),$(2))$(1)
174 endef
176 $(eval $(call gb_Helper_init_registries))
177 include $(SRCDIR)/Repository.mk
178 include $(SRCDIR)/RepositoryExternal.mk
179 $(eval $(call gb_Helper_collect_knownlibs))
181 gb_Library_DLLPOSTFIX := lo
182 gb_RUN_CONFIGURE :=
184 gb_CONFIGURE_PLATFORMS := --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)
186 # Include platform/cpu/compiler specific config/definitions
188 include $(GBUILDDIR)/platform/$(OS)_$(CPUNAME)_$(COM).mk
190 # this is optional
191 include $(SRCDIR)/RepositoryFixes.mk
193 # after platform; at least currently python depends on variable set in platform
194 $(eval $(call gb_ExternalExecutable_collect_registrations))
196 # add user-supplied flags
197 ifneq ($(strip gb__ENV_CFLAGS),)
198 gb_LinkTarget_CFLAGS += $(gb__ENV_CFLAGS)
199 endif
200 ifneq ($(strip gb__ENV_CXXFLAGS),)
201 gb_LinkTarget_CXXFLAGS += $(gb__ENV_CXXFLAGS)
202 endif
204 gb_CPUDEFS += -D$(CPUNAME)
206 gb_GLOBALDEFS := \
207 -D_REENTRANT \
208 -DOSL_DEBUG_LEVEL=$(dbglevel) \
209 $(gb_OSDEFS) \
210 $(gb_COMPILERDEFS) \
211 $(gb_CPUDEFS) \
213 ifeq ($(ENABLE_DBGUTIL),TRUE)
214 gb_GLOBALDEFS += -DDBG_UTIL
216 ifneq ($(COM)-$(MSVC_USE_DEBUG_RUNTIME),MSC-)
217 gb_GLOBALDEFS += -D_DEBUG
218 endif
219 endif
221 ifeq ($(gb_TIMELOG),1)
222 gb_GLOBALDEFS += -DTIMELOG \
224 endif
226 ifeq ($(strip $(ASSERT_ALWAYS_ABORT)),FALSE)
227 gb_GLOBALDEFS += -DNDEBUG \
229 endif
231 ifeq ($(ENABLE_SAL_LOG),TRUE)
232 gb_GLOBALDEFS += -DSAL_LOG_INFO \
233 -DSAL_LOG_WARN \
235 endif
237 gb_GLOBALDEFS += \
238 $(call gb_Helper_define_if_set,\
239 DISABLE_DYNLOADING \
242 gb_GLOBALDEFS := $(sort $(gb_GLOBALDEFS))
244 # Common environment variables passed into all gb_*Test classes:
245 # * Cap the number of threads unittests use:
246 gb_TEST_ENV_VARS := MAX_CONCURRENCY=4
247 # * Disable searching for certificates by default:
249 # see xmlsecurity/source/xmlsec/nss/nssinitializer.cxx for use
251 # a) If MOZILLA_CERTIFICATE_FOLDER is empty then LibreOffice autodetects
252 # the user's mozilla-descended application profile. To disable that we
253 # use a non-empty string here.
255 # b) Using dbm: appears to nss as equivalent to an empty path so the
256 # initial NSS_InitReadWrite will fail. In response to that failure
257 # LibreOffice will create a temp fallback cert database which is removed
258 # on process exit
259 gb_TEST_ENV_VARS += MOZILLA_CERTIFICATE_FOLDER=dbm:
260 # Avoid hanging if the cups daemon requests a password:
261 gb_TEST_ENV_VARS += SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION=1
262 ifeq (,$(SAL_USE_VCLPLUGIN))
263 gb_TEST_ENV_VARS += SAL_USE_VCLPLUGIN=svp
264 endif
266 # This is used to detect whether LibreOffice is being built (as opposed to building
267 # 3rd-party code). Used for tag deprecation for API we want to
268 # ensure is not used at all externally while we clean
269 # out our internal usage, for code in sal/ that should be used only internally, etc.
270 gb_DEFS_INTERNAL := \
271 -DLIBO_INTERNAL_ONLY \
273 include $(GBUILDDIR)/Deliver.mk
275 $(eval $(call gb_Deliver_init))
277 include $(GBUILDDIR)/Trace.mk
279 # We are using a set of scopes that we might as well call classes.
281 # TODO: to what extent is the following still true?
282 # It is important to include them in the right order as that is
283 # -- at least in part -- defining precedence. This is not an issue in the
284 # WORKDIR as there are no naming collisions there, but INSTDIR is a mess
285 # and precedence is important there. This is also platform dependent.
287 # This is less of an issue with GNU Make versions > 3.82 which matches for
288 # shortest stem instead of first match. However, upon introduction this version
289 # is not available everywhere by default.
291 include $(foreach class, \
292 ComponentTarget \
293 Postprocess \
294 AllLangMoTarget \
295 WinResTarget \
296 LinkTarget \
297 Library \
298 StaticLibrary \
299 Executable \
300 SdiTarget \
301 Package \
302 ExternalPackage \
303 CustomTarget \
304 ExternalProject \
305 Gallery \
306 Pagein \
307 PrecompiledHeaders \
308 Pyuno \
309 PythonTest \
310 UITest \
311 Rdb \
312 CppunitTest \
313 Jar \
314 JavaClassSet \
315 JunitTest \
316 Module \
317 UIConfig \
318 UnoApiTarget \
319 UnoApi \
320 UnpackedTarball \
321 InternalUnoApi \
322 CliAssembly \
323 CliLibrary \
324 CliNativeLibrary \
325 CliUnoApi \
326 Zip \
327 AllLangPackage \
328 Configuration \
329 HelpTarget \
330 AllLangHelp \
331 Extension \
332 ExtensionPackage \
333 Dictionary \
334 InstallModuleTarget \
335 InstallModule \
336 InstallScript \
337 AutoInstall \
338 PackageSet \
339 GeneratedPackage \
340 CompilerTest \
341 ,$(GBUILDDIR)/$(class).mk)
343 $(eval $(call gb_Helper_process_executable_registrations))
344 $(eval $(call gb_Postprocess_make_targets))
346 # optional extensions that should never be essential
347 ifneq ($(wildcard $(GBUILDDIR)/extensions/post_*.mk),)
348 include $(wildcard $(GBUILDDIR)/extensions/post_*.mk)
349 endif
351 define gb_Extensions_final_hook
352 ifneq ($(wildcard $(GBUILDDIR)/extensions/final_*.mk),)
353 include $(wildcard $(GBUILDDIR)/extensions/final_*.mk)
354 endif
356 endef
358 # Setup for ccache.
359 ifneq ($(gb_ENABLE_PCH),)
360 # CCACHE_SLOPPINESS should contain pch_defines,time_macros for PCHs.
361 gb_CCACHE_SLOPPINESS :=
362 ifeq ($(shell test -z "$$CCACHE_SLOPPINESS" && echo 1),1)
363 gb_CCACHE_SLOPPINESS := CCACHE_SLOPPINESS=pch_defines,time_macros
364 else
365 ifeq ($(shell echo "$$CCACHE_SLOPPINESS" | grep -q pch_defines | grep -q time_macros && echo 1),1)
366 gb_CCACHE_SLOPPINESS := CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS:pch_defines,time_macros
367 endif
368 endif
369 gb_COMPILER_SETUP += $(gb_CCACHE_SLOPPINESS)
370 endif
372 ifneq ($(CCACHE_DEPEND_MODE),)
373 gb_COMPILER_SETUP += CCACHE_DEPEND=1
374 endif
376 $(WORKDIR)/%/.dir:
377 mkdir -p $(@D) && touch $@
379 # vim: set noet sw=4: