bump product version to 4.2.0.1
[LibreOffice.git] / solenv / gbuild / Module.mk
blobd08e5cbdf9f3aefd516a488fd96582ff14800462
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 .
21 # Overview of dependencies and tasks of Module
23 # target task depends on
24 # Module build the product all product targets
25 # excluding tests recursive Modules
26 # Module/unitcheck run unit tests all unit tests
27 # recursive Module/checks
28 # Module/slowcheck run all slow unit tests
29 # Module/subsequentcheck run system tests all system tests
30 # recursive Module/subsequentchecks
31 # build (global) build the product top-level Module
32 # unitcheck (global) run unit tests top-level Module/unitcheck
33 # slowcheck (global) run slow unit tests top-level Module/slowcheck
34 # subsequentcheck (global) run system tests top-level Module/subsequentcheck
35 # all (global) default goal build unitcheck
38 # Module class
40 gb_Module_ALLMODULES :=
41 gb_Module_MODULELOCATIONS :=
42 gb_Module_TARGETSTACK :=
43 gb_Module_L10NTARGETSTACK :=
44 gb_Module_CHECKTARGETSTACK :=
45 gb_Module_SLOWCHECKTARGETSTACK :=
46 gb_Module_SUBSEQUENTCHECKTARGETSTACK :=
47 gb_Module_CLEANTARGETSTACK :=
49 # The currently read gbuild makefile.
51 # gbuild classes should use this if they need to depend on their makefile
52 # (e.g., to make sure a zip file is rebuilt if files are removed from it).
53 # Because makefiles may include other makefiles, it is not safe to rely
54 # on $(MAKEFILE_LIST).
55 gb_Module_CURRENTMAKEFILE :=
57 $(call gb_Module_get_nonl10n_target,%) :
58 $(call gb_Output_announce,$*,$(true),BIN,5)
59 -$(call gb_Helper_abbreviate_dirs,\
60 mkdir -p $(dir $@) && \
61 touch $@)
63 .PHONY : $(call gb_Module_get_clean_target,%)
64 $(call gb_Module_get_clean_target,%) :
65 $(call gb_Output_announce,$*,$(false),MOD,5)
66 $(call gb_Output_announce_title,module $* cleared.)
67 -$(call gb_Helper_abbreviate_dirs,\
68 rm -f $(call gb_Module_get_target,$*) $(call gb_Module_get_nonl10n_target,$*) $(call gb_Module_get_l10n_target,$*) $(call gb_Module_get_check_target,$*) $(call gb_Module_get_slowcheck_target,$*) $(call gb_Module_get_subsequentcheck_target,$*))
70 $(call gb_Module_get_l10n_target,%) :
71 $(call gb_Output_announce,$*,$(true),LOC,5)
72 $(call gb_Output_announce_title,module $* done.)
73 -$(call gb_Helper_abbreviate_dirs,\
74 mkdir -p $(dir $@) && \
75 touch $@)
77 $(call gb_Module_get_check_target,%) :
78 $(call gb_Output_announce,$*,$(true),CHK,5)
79 $(call gb_Output_announce_title,module $* checks done.)
80 -$(call gb_Helper_abbreviate_dirs,\
81 mkdir -p $(dir $@) && \
82 touch $@)
84 $(call gb_Module_get_slowcheck_target,%) :
85 $(call gb_Output_announce,$*,$(true),SLC,5)
86 $(call gb_Output_announce_title,module $* slowchecks done.)
87 -$(call gb_Helper_abbreviate_dirs,\
88 mkdir -p $(dir $@) && \
89 touch $@)
91 $(call gb_Module_get_subsequentcheck_target,%) :
92 $(call gb_Output_announce,$*,$(true),SCK,5)
93 $(call gb_Output_announce_title,module $* subsequentchecks done.)
94 -$(call gb_Helper_abbreviate_dirs,\
95 mkdir -p $(dir $@) && \
96 touch $@)
98 $(call gb_Module_get_target,%) :
99 $(call gb_Output_announce,$*,$(true),MOD,5)
100 $(call gb_Output_announce_title,module $* done.)
101 -$(call gb_Helper_abbreviate_dirs,\
102 mkdir -p $(dir $@) && \
103 touch $@)
105 .PHONY : all build build-l10n-only build-non-l10n-only unitcheck slowcheck subsequentcheck clean check debugrun help showmodules translations
106 .DEFAULT_GOAL := all
108 all : build $(if $(CROSS_COMPILING),,unitcheck $(if $(gb_PARTIAL_BUILD),,slowcheck))
110 build-tools : $(gb_BUILD_TOOLS)
111 $(call gb_Output_announce,loaded tools: $(gb_BUILD_TOOLS),$(true),ALL,6)
112 $(call gb_Output_announce_title,build-tools done.)
113 $(call gb_Output_announce_bell)
115 build :
116 $(call gb_Output_announce,top level modules: $(foreach module,$(filter-out deliverlog $(WORKDIR)/bootstrap,$^),$(notdir $(module))),$(true),ALL,6)
117 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),ALL,6)
118 $(call gb_Output_announce_title,build done.)
119 $(call gb_Output_announce_bell)
121 build-l10n-only :
122 $(call gb_Output_announce,top level modules: $(foreach module,$(filter-out deliverlog $(WORKDIR)/bootstrap,$^),$(notdir $(module))),$(true),LOC,6)
123 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),LOC,6)
124 $(call gb_Output_announce_title,l10n done.)
125 $(call gb_Output_announce_bell)
127 build-non-l10n-only :
128 $(call gb_Output_announce,top level modules: $(foreach module,$(filter-out deliverlog $(WORKDIR)/bootstrap,$^),$(notdir $(module))),$(true),NLC,6)
129 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),BIN,6)
130 $(call gb_Output_announce_title,non-l10n done.)
131 $(call gb_Output_announce_bell)
133 unitcheck :
134 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),CHK,6)
135 $(call gb_Output_announce_title,all unittests checked.)
136 $(call gb_Output_announce_bell)
138 slowcheck :
139 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),SLC,6)
140 $(call gb_Output_announce_title,all slowtests checked.)
141 $(call gb_Output_announce_bell)
143 # removing the dependency on build for now until we can make a full build with gbuild
144 #subsequentcheck : all
145 subsequentcheck :
146 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(true),SCK,6)
147 $(call gb_Output_announce_title,all subsequent tests checked.)
148 $(call gb_Output_announce_bell)
150 clean :
151 $(call gb_Output_announce,top level modules: $(foreach module,$^,$(notdir $(module))),$(false),ALL,6)
152 $(call gb_Output_announce,loaded modules: $(sort $(gb_Module_ALLMODULES)),$(false),ALL,6)
153 $(call gb_Output_announce_title,all cleared.)
154 $(call gb_Output_announce_bell)
156 check : unitcheck slowcheck
157 $(call gb_Output_announce_title,all tests checked.)
158 $(call gb_Output_announce_bell)
160 debugrun :
161 $(call gb_Module_DEBUGRUNCOMMAND)
163 help :
164 @cat $(SRCDIR)/solenv/gbuild/gbuild.help.txt
166 showmodules :
167 $(info $(strip $(gb_Module_ALLMODULES)))
168 @true
170 translations : $(WORKDIR)/pot.done
172 $(WORKDIR)/pot.done : $(foreach exec,cfgex helpex localize transex3 \
173 propex uiex ulfex xrmex treex, \
174 $(call gb_Executable_get_target_for_build,$(exec)))
175 $(call gb_Output_announce,$(subst .pot,,$(subst $(WORKDIR)/,,$@)),$(true),POT,1)
176 $(call gb_Helper_abbreviate_dirs,\
177 mkdir -p $(dir $@) && $(call gb_Helper_execute,localize) $(SRCDIR) $(dir $@)/pot \
178 && find $(dir $@)/pot -type f -printf "%P\n" | sed -e "s/\.pot/.po/" > $(dir $@)/LIST \
179 && touch $@)
181 # enable if: no "-MODULE/" defined AND ["all" defined OR "MODULE/" defined]
182 gb_Module__debug_enabled = \
183 $(and $(if $(filter -$(1)/,$(ENABLE_DEBUGINFO_FOR)),,$(true)),\
184 $(filter all $(1)/,$(ENABLE_DEBUGINFO_FOR)))
186 define gb_Module_Module
187 gb_Module_ALLMODULES += $(1)
188 gb_Module_MODULELOCATIONS += $(1):$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
189 gb_Module_TARGETSTACK := $(call gb_Module_get_target,$(1)) $(gb_Module_TARGETSTACK)
190 gb_Module_L10NTARGETSTACK := $(call gb_Module_get_l10n_target,$(1)) $(gb_Module_L10NTARGETSTACK)
191 gb_Module_CHECKTARGETSTACK := $(call gb_Module_get_check_target,$(1)) $(gb_Module_CHECKTARGETSTACK)
192 gb_Module_SLOWCHECKTARGETSTACK := $(call gb_Module_get_slowcheck_target,$(1)) $(gb_Module_SLOWCHECKTARGETSTACK)
193 gb_Module_SUBSEQUENTCHECKTARGETSTACK := $(call gb_Module_get_subsequentcheck_target,$(1)) $(gb_Module_SUBSEQUENTCHECKTARGETSTACK)
194 gb_Module_CLEANTARGETSTACK := $(call gb_Module_get_clean_target,$(1)) $(gb_Module_CLEANTARGETSTACK)
195 gb_Module_CURRENTMODULE_DEBUG_ENABLED := $(call gb_Module__debug_enabled,$(1))
196 gb_Module_CURRENTMODULE_NAME := $(1)
197 $(call gb_Helper_make_userfriendly_targets,$(1),Module)
198 $(if $(filter-out libreoffice instsetoo_native android ios,$(1)),\
199 $(call gb_Postprocess_register_target,AllModulesButInstsetNative,Module,$(1)))
201 $(call gb_Postprocess_get_target,AllModuleTests) : $(call gb_Module_get_check_target,$(1))
202 $(call gb_Postprocess_get_clean_target,AllModuleTests) : $(call gb_Module_get_clean_target,$(1))
204 endef
206 # This is called inside the included file and pushes one target on each stack.
207 # This has to be called with full late evaluation ($$(eval $$(call ))) and
208 # should never be inlined ($(call )) as the calls defining it might be sourced
209 # before gb_Module.
210 define gb_Module_register_target
211 gb_Module_CURRENTTARGET := $(1)
212 gb_Module_CURRENTCLEANTARGET := $(2)
214 endef
216 # Here we include the file (in it there will be a call to gb_Module_register_target)
217 define gb_Module__read_targetfile
218 gb_Module_CURRENTTARGET :=
219 gb_Module_CURRENTCLEANTARGET :=
220 gb_Module_CURRENTMAKEFILE := $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS)))$(2).mk
221 include $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS)))$(2).mk
222 gb_Module_CURRENTMAKEFILE :=
223 ifneq ($$(words $$(gb_Module_CURRENTTARGET)) $$(words $$(gb_Module_CURRENTCLEANTARGET)),1 1)
224 $$(eval $$(call gb_Output_error,No $(3) registered while reading $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS)))$(2).mk!))
225 endif
227 endef
229 define gb_Module_add_target
230 $(if $(filter AllLang% Dictionary% UIConfig% Package_registry,$(2)),$(warning target $(2) should be a l10n target))
231 $(call gb_Module__read_targetfile,$(1),$(2),target)
233 $(call gb_Module_get_nonl10n_target,$(1)) : $$(gb_Module_CURRENTTARGET)
234 $(call gb_Module_get_clean_target,$(1)) : $$(gb_Module_CURRENTCLEANTARGET)
236 endef
238 define gb_Module_add_l10n_target
239 $(if $(filter AllLang% Dictionary% UIConfig% Package_registry,$(2)),,$(warning target $(2) should not be a l10n target))
240 $(call gb_Module__read_targetfile,$(1),$(2),target)
242 $(call gb_Module_get_l10n_target,$(1)) : $$(gb_Module_CURRENTTARGET)
243 $(call gb_Module_get_clean_target,$(1)) : $$(gb_Module_CURRENTCLEANTARGET)
245 endef
247 define gb_Module_add_check_target
248 $(call gb_Module__read_targetfile,$(1),$(2),check target)
250 $(call gb_Module_get_check_target,$(1)) : $$(gb_Module_CURRENTTARGET)
251 $(call gb_Module_get_clean_target,$(1)) : $$(gb_Module_CURRENTCLEANTARGET)
253 endef
255 define gb_Module_add_slowcheck_target
256 $(call gb_Module__read_targetfile,$(1),$(2),slowcheck target)
258 $(call gb_Module_get_slowcheck_target,$(1)) : $$(gb_Module_CURRENTTARGET)
259 $(call gb_Module_get_clean_target,$(1)) : $$(gb_Module_CURRENTCLEANTARGET)
261 endef
263 # has order dependency on AllModulesButInstsetNative to be able to run
264 # subsequentcheck in the same make process on "make check"
265 define gb_Module_add_subsequentcheck_target
266 $(call gb_Module__read_targetfile,$(1),$(2),subsequentcheck target)
268 $(call gb_Module_get_subsequentcheck_target,$(1)) : $$(gb_Module_CURRENTTARGET)
269 $$(gb_Module_CURRENTTARGET) :| \
270 $(call gb_Postprocess_get_target,AllModulesButInstsetNative)
271 $(call gb_Module_get_clean_target,$(1)) : $$(gb_Module_CURRENTCLEANTARGET)
273 endef
275 define gb_Module_add_moduledir
276 include $(patsubst $(1):%,%,$(filter $(1):%,$(gb_Module_MODULELOCATIONS)))/$(2)/Module_$(2).mk
277 $(call gb_Module_get_target,$(1)) : $$(firstword $$(gb_Module_TARGETSTACK))
278 $(call gb_Module_get_l10n_target,$(1)) : $$(firstword $$(gb_Module_L10NTARGETSTACK))
279 $(call gb_Module_get_check_target,$(1)) : $$(firstword $$(gb_Module_CHECKTARGETSTACK))
280 $(call gb_Module_get_slowcheck_target,$(1)) : $$(firstword $$(gb_Module_SLOWCHECKTARGETSTACK))
281 $(call gb_Module_get_subsequentcheck_target,$(1)) : $$(firstword $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK))
282 $(call gb_Module_get_clean_target,$(1)) : $$(firstword $$(gb_Module_CLEANTARGETSTACK))
283 gb_Module_TARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_TARGETSTACK)),$$(gb_Module_TARGETSTACK))
284 gb_Module_L10NTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_L10NTARGETSTACK)),$$(gb_Module_L10NTARGETSTACK))
285 gb_Module_CHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_CHECKTARGETSTACK)),$$(gb_Module_CHECKTARGETSTACK))
286 gb_Module_SLOWCHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_SLOWCHECKTARGETSTACK)),$$(gb_Module_SLOWCHECKTARGETSTACK))
287 gb_Module_SUBSEQUENTCHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK))
288 gb_Module_CLEANTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_CLEANTARGETSTACK)),$$(gb_Module_CLEANTARGETSTACK))
290 endef
292 define gb_Module_add_targets
293 $(call gb_Module_get_target,$(1)) : $(call gb_Module_get_nonl10n_target,$(1))
294 $(foreach target,$(2),$(call gb_Module_add_target,$(1),$(target)))
296 endef
298 define gb_Module_add_l10n_targets
299 $(call gb_Module_get_target,$(1)) : $(call gb_Module_get_l10n_target,$(1))
300 $(foreach target,$(2),$(call gb_Module_add_l10n_target,$(1),$(target)))
302 endef
304 gb_Module_add_targets_for_build = $(call gb_Module_add_targets,$(1),$(2))
306 define gb_Module_add_check_targets
307 $(foreach target,$(2),$(call gb_Module_add_check_target,$(1),$(target)))
309 endef
311 define gb_Module_add_slowcheck_targets
312 $(foreach target,$(2),$(call gb_Module_add_slowcheck_target,$(1),$(target)))
314 endef
316 define gb_Module_add_subsequentcheck_targets
317 $(foreach target,$(2),$(call gb_Module_add_subsequentcheck_target,$(1),$(target)))
319 endef
321 define gb_Module_add_moduledirs
322 $(foreach target,$(sort $(2)),$(call gb_Module_add_moduledir,$(1),$(target)))
324 endef
326 define gb_Module_make_global_targets
327 ifneq ($$(gb_Module_TARGETSTACK),)
328 $$(eval $$(call gb_Output_error,Corrupted module target stack!1))
329 endif
331 include $(1)
333 build : build-non-l10n-only build-l10n-only
334 build-non-l10n-only : $$(firstword $$(gb_Module_TARGETSTACK))
335 build-l10n-only : $$(firstword $$(gb_Module_L10NTARGETSTACK))
336 unitcheck : $$(firstword $$(gb_Module_CHECKTARGETSTACK))
337 slowcheck : $$(firstword $$(gb_Module_SLOWCHECKTARGETSTACK))
338 subsequentcheck : $$(firstword $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK))
339 clean : $$(firstword $$(gb_Module_CLEANTARGETSTACK))
341 ifneq ($$(words $$(gb_Module_TARGETSTACK)),1)
342 $$(eval $$(call gb_Output_error,Corrupted module target stack! $(gb_Module_TARGETSTACK)))
343 endif
345 gb_Module_TARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_TARGETSTACK)),$$(gb_Module_TARGETSTACK))
346 gb_Module_L10NTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_L10NTARGETSTACK)),$$(gb_Module_L10NTARGETSTACK))
347 gb_Module_CHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_CHECKTARGETSTACK)),$$(gb_Module_CHECKTARGETSTACK))
348 gb_Module_SLOWCHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_SLOWCHECKTARGETSTACK)),$$(gb_Module_SLOWCHECKTARGETSTACK))
349 gb_Module_SUBSEQUENTCHECKTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_SUBSEQUENTCHECKTARGETSTACK)),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK))
350 gb_Module_CLEANTARGETSTACK := $$(wordlist 2,$$(words $$(gb_Module_CLEANTARGETSTACK)),$$(gb_Module_CLEANTARGETSTACK))
352 ifneq ($$(and $$(gb_Module_TARGETSTACK),$$(gb_Module_CHECKTARGETSTACK),$$(gb_Module_SLOWCHECKTARGETSTACK),$$(gb_Module_SUBSEQUENTCHECKTARGETSTACK),$$(gb_Module_L10NTARGETSTACK)),)
353 $$(eval $$(call gb_Output_error,Corrupted module target stack!3))
354 endif
356 $$(eval $$(gb_Extensions_final_hook))
357 endef
359 # vim: set noet sw=4: