Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / gbuild.mk
blob756b845dd20976bd0a380772cc98f5579276ec63
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_JPEG (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 # by default gbuild use /bin/sh
48 # if you want to use a particular shell
49 # you can export gb_SHELL=<path_to_shell>
52 ifdef gb_SHELL
53 SHELL := $(gb_SHELL)
54 else
55 ifeq ($(OS_FOR_BUILD),WNT)
56 ifeq ($(GNUMAKE_WIN_NATIVE),TRUE)
57 SHELL := $(shell cygpath -m /bin/sh)
58 else
59 SHELL := /bin/sh
60 endif
61 else
62 SHELL := /bin/sh
63 endif
64 endif
66 true := T
67 false :=
68 define NEWLINE
71 endef
73 define WHITESPACE
75 endef
77 COMMA :=,
79 CLOSE_PAREN :=)
81 gb_VERBOSE := $(verbose)$(VERBOSE)
83 include $(GBUILDDIR)/Helper.mk
85 # optional extensions that should never be essential
86 ifneq ($(wildcard $(GBUILDDIR)/extensions/pre_*.mk),)
87 include $(wildcard $(GBUILDDIR)/extensions/pre_*.mk)
88 endif
90 include $(GBUILDDIR)/Output.mk
92 gb_TIMELOG := 0
93 ifneq ($(strip $(TIMELOG)$(timelog)),)
94 gb_TIMELOG := 1
95 endif
97 ifneq ($(ENABLE_DBGUTIL),)
98 gb_ENABLE_DBGUTIL := $(true)
99 else
100 gb_ENABLE_DBGUTIL := $(false)
101 endif
103 gb_DEBUGLEVEL := 0
104 ifneq ($(strip $(DEBUG)),)
105 gb_DEBUGLEVEL := 1
106 # make DEBUG=true should force -g
107 ifeq ($(origin DEBUG),command line)
108 ENABLE_DEBUGINFO_FOR := all
109 endif
110 endif
111 ifneq ($(strip $(debug)),)
112 gb_DEBUGLEVEL := 1
113 ifeq ($(origin debug),command line)
114 ENABLE_DEBUGINFO_FOR := all
115 endif
116 endif
117 ifeq ($(gb_ENABLE_DBGUTIL),$(true))
118 gb_DEBUGLEVEL := 1
119 endif
121 ifneq ($(strip $(DBGLEVEL)),)
122 gb_DEBUGLEVEL := $(strip $(DBGLEVEL))
123 ifeq ($(origin DBGLEVEL),command line)
124 ENABLE_DEBUGINFO_FOR := all
125 endif
126 endif
127 ifneq ($(strip $(dbglevel)),)
128 gb_DEBUGLEVEL := $(strip $(dbglevel))
129 ifeq ($(origin dbglevel),command line)
130 ENABLE_DEBUGINFO_FOR := all
131 endif
132 endif
134 ifeq ($(HARDLINKDELIVER),TRUE)
135 gb_Deliver_HARDLINK := $(true)
136 endif
138 # note: ENABLE_CRASHDUMP turns on gb_SYMBOL
139 ifeq ($(or $(ENABLE_SYMBOLS),$(enable_symbols)),FALSE)
140 gb_SYMBOL := $(false)
141 else
142 ifneq ($(strip $(ENABLE_SYMBOLS)$(enable_symbols)$(ENABLE_CRASHDUMP)),)
143 gb_SYMBOL := $(true)
144 endif
145 endif
147 ifneq ($(strip $(ENABLE_PCH)),)
148 gb_ENABLE_PCH := $(true)
149 else
150 gb_ENABLE_PCH := $(false)
151 endif
153 ifneq ($(nodep)$(ENABLE_PRINT_DEPS),)
154 gb_FULLDEPS := $(false)
155 else
156 gb_FULLDEPS := $(true)
157 endif
159 ifneq ($(strip $(patches)$(PATCHES)),)
160 gb_KEEP_PRISTINE := $(true)
161 else
162 gb_KEEP_PRISTINE := $(false)
163 endif
165 ifeq ($(findstring s,$(MAKEFLAGS)),)
166 gb_QUIET_EXTERNAL := $(false)
167 else
168 gb_QUIET_EXTERNAL := $(true)
169 endif
171 # save user-supplied flags for latter use
172 ifneq ($(strip $(ENVCFLAGS)),)
173 gb__ENV_CFLAGS := $(ENVCFLAGS)
174 endif
175 ifneq ($(strip $(ENVCFLAGSCXX)),)
176 gb__ENV_CXXFLAGS := $(ENVCFLAGSCXX)
177 endif
179 include $(GBUILDDIR)/ExternalExecutable.mk
180 include $(GBUILDDIR)/TargetLocations.mk
181 include $(GBUILDDIR)/Tempfile.mk
183 $(eval $(call gb_Helper_init_registries))
184 include $(SRCDIR)/Repository.mk
185 include $(SRCDIR)/RepositoryExternal.mk
186 $(eval $(call gb_Helper_collect_knownlibs))
188 gb_Library_DLLPOSTFIX := lo
190 # Include platform/cpu/compiler specific config/definitions
191 include $(GBUILDDIR)/platform/$(OS)_$(CPUNAME)_$(COM).mk
193 # this is optional
194 include $(SRCDIR)/RepositoryFixes.mk
196 # after platform; at least currently python depends on variable set in platform
197 $(eval $(call gb_ExternalExecutable_collect_registrations))
199 # add user-supplied flags
200 ifneq ($(strip gb__ENV_CFLAGS),)
201 gb_LinkTarget_CFLAGS += $(gb__ENV_CFLAGS)
202 endif
203 ifneq ($(strip gb__ENV_CXXFLAGS),)
204 gb_LinkTarget_CXXFLAGS += $(gb__ENV_CXXFLAGS)
205 endif
207 gb_CPUDEFS += -D$(CPUNAME)
209 gb_GLOBALDEFS := \
210 -D_REENTRANT \
211 -DOSL_DEBUG_LEVEL=$(gb_DEBUGLEVEL) \
212 $(gb_OSDEFS) \
213 $(gb_COMPILERDEFS) \
214 $(gb_CPUDEFS) \
216 ifeq ($(gb_ENABLE_DBGUTIL),$(true))
217 gb_GLOBALDEFS += -DDBG_UTIL
219 ifneq ($(COM)-$(MSVC_USE_DEBUG_RUNTIME),MSC-)
220 gb_GLOBALDEFS += -D_DEBUG
221 endif
222 endif
224 ifeq ($(gb_TIMELOG),1)
225 gb_GLOBALDEFS += -DTIMELOG \
227 endif
229 ifeq ($(gb_DEBUGLEVEL),0)
230 gb_GLOBALDEFS += -DOPTIMIZE \
232 ifeq ($(strip $(ASSERT_ALWAYS_ABORT)),FALSE)
233 gb_GLOBALDEFS += -DNDEBUG \
235 endif
237 ifeq ($(ENABLE_SAL_LOG),TRUE)
238 gb_GLOBALDEFS += -DSAL_LOG_INFO \
239 -DSAL_LOG_WARN \
241 endif
243 else
244 gb_GLOBALDEFS += -DSAL_LOG_INFO \
245 -DSAL_LOG_WARN \
247 ifneq ($(gb_DEBUGLEVEL),1) # 2 or more
248 gb_GLOBALDEFS += -DDEBUG \
250 endif
251 endif
253 ifeq ($(ENABLE_HEADLESS),TRUE)
254 gb_GLOBALDEFS += -DLIBO_HEADLESS \
256 endif
258 gb_GLOBALDEFS += \
259 $(call gb_Helper_define_if_set,\
260 DISABLE_DYNLOADING \
261 DISABLE_EXPORT \
262 ENABLE_LTO \
265 gb_GLOBALDEFS := $(sort $(gb_GLOBALDEFS))
267 # This is used to detect whether LibreOffice is being built (as opposed to building
268 # 3rd-party code). Used for tag deprecation for API we want to
269 # ensure is not used at all externally while we clean
270 # out our internal usage, for code in sal/ that should be used only internally, etc.
271 gb_DEFS_INTERNAL := \
272 -DLIBO_INTERNAL_ONLY \
274 include $(GBUILDDIR)/Deliver.mk
276 $(eval $(call gb_Deliver_init))
278 # We are using a set of scopes that we might as well call classes.
280 # TODO: to what extent is the following still true?
281 # It is important to include them in the right order as that is
282 # -- at least in part -- defining precedence. This is not an issue in the
283 # WORKDIR as there are no nameing collisions there, but INSTDIR is a mess
284 # and precedence is important there. This is also platform dependent.
286 # This is less of an issue with GNU Make versions > 3.82 which matches for
287 # shortest stem instead of first match. However, upon intoduction this version
288 # is not available everywhere by default.
290 include $(foreach class, \
291 ComponentTarget \
292 Postprocess \
293 AllLangResTarget \
294 WinResTarget \
295 LinkTarget \
296 Library \
297 StaticLibrary \
298 Executable \
299 SdiTarget \
300 Package \
301 ExternalPackage \
302 CustomTarget \
303 ExternalProject \
304 Gallery \
305 Pagein \
306 PrecompiledHeaders \
307 Pyuno \
308 PythonTest \
309 Rdb \
310 CppunitTest \
311 Jar \
312 JavaClassSet \
313 JunitTest \
314 Module \
315 UIConfig \
316 UnoApiTarget \
317 UnoApi \
318 UnpackedTarball \
319 InternalUnoApi \
320 CliAssembly \
321 CliLibrary \
322 CliNativeLibrary \
323 CliUnoApi \
324 Zip \
325 AllLangPackage \
326 Configuration \
327 HelpTarget \
328 AllLangHelp \
329 Extension \
330 ExtensionPackage \
331 Dictionary \
332 InstallModuleTarget \
333 InstallModule \
334 InstallScript \
335 AutoInstall \
336 PackageSet \
337 GeneratedPackage \
338 ,$(GBUILDDIR)/$(class).mk)
340 $(eval $(call gb_Helper_process_executable_registrations))
341 $(eval $(call gb_Postprocess_make_targets))
343 # optional extensions that should never be essential
344 ifneq ($(wildcard $(GBUILDDIR)/extensions/post_*.mk),)
345 include $(wildcard $(GBUILDDIR)/extensions/post_*.mk)
346 endif
348 define gb_Extensions_final_hook
349 ifneq ($(wildcard $(GBUILDDIR)/extensions/final_*.mk),)
350 include $(wildcard $(GBUILDDIR)/extensions/final_*.mk)
351 endif
353 endef
355 # vim: set noet sw=4: