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 gb_Helper_MISC
:= $(WORKDIR
)/Misc
22 # general purpose phony target
23 gb_Helper_PHONY
:= $(gb_Helper_MISC
)/PHONY
25 # general purpose empty dummy target
26 gb_Helper_MISCDUMMY
:= $(gb_Helper_MISC
)/DUMMY
28 # target for reacting to changes in the list of configured languages
29 gb_Helper_LANGSTARGET
:= $(BUILDDIR
)/config_
$(gb_Side
)_lang.mk.stamp
31 .PHONY
: $(WORKDIR
)/Misc
/PHONY
32 $(gb_Helper_MISCDUMMY
) :
33 @mkdir
-p
$(dir $@
) && touch
$@
35 ifeq ($(SRCDIR
),$(BUILDDIR
))
36 define gb_Helper_abbreviate_dirs
38 $(subst $(SRCDIR
)/,$$S/,I
=$(INSTDIR
)) && \
39 $(subst $(SRCDIR
)/,$$S/,W
=$(WORKDIR
)) && \
40 $(subst $(SRCDIR
)/,$$S/,$(subst $(INSTDIR
)/,$$I/,$(subst $(WORKDIR
)/,$$W/,$(1))))
43 define gb_Helper_abbreviate_dirs
45 $(subst $(SRCDIR
)/,$$S/,B
=$(BUILDDIR
)) && \
46 $(subst $(SRCDIR
)/,$$S/,$(subst $(BUILDDIR
)/,$$B/,I
=$(INSTDIR
))) && \
47 $(subst $(SRCDIR
)/,$$S/,$(subst $(BUILDDIR
)/,$$B/,W
=$(WORKDIR
))) && \
48 $(subst $(SRCDIR
)/,$$S/,$(subst $(BUILDDIR
)/,$$B/,$(subst $(INSTDIR
)/,$$I/,$(subst $(WORKDIR
)/,$$W/,$(1)))))
52 define gb_Helper_abbreviate_dirs_native
53 $(call gb_Output_error
,gb_Helper_abbreviate_dirs_native
: use gb_Helper_abbreviate_dirs instead.
)
56 define gb_Helper_native_path
57 $(call gb_Output_error
,gb_Helper_native_path
: Do not use. Should not be necessary.
)
60 # cygwin seems to eat one backslash when executing command, thus replace with '\\'
61 define gb_Helper_windows_path
67 # path-replacement optimizations, instead of calling cygpath/wslpath all the time, just do it once
68 # and then do all other path-replacements without the need to spawn processes/shells for that
69 SRCDIR_CYG
:= $(shell cygpath
-u
$(SRCDIR
))
70 BUILDDIR_CYG
:= $(shell cygpath
-u
$(BUILDDIR
))
71 INSTDIR_CYG
:= $(shell cygpath
-u
$(INSTDIR
))
72 WORKDIR_CYG
:= $(shell cygpath
-u
$(WORKDIR
))
73 TARFILE_LOCATION_CYG
:= $(shell cygpath
-u
$(TARFILE_LOCATION
))
75 define gb_Helper_cyg_path
76 $(subst $(TARFILE_LOCATION
)/,$(TARFILE_LOCATION_CYG
)/,$(subst $(SRCDIR
)/,$(SRCDIR_CYG
)/,$(subst $(BUILDDIR
)/,$(BUILDDIR_CYG
)/,$(subst $(INSTDIR
)/,$(INSTDIR_CYG
)/,$(subst $(WORKDIR
)/,$(WORKDIR_CYG
)/,$(1))))))
80 # paths to reach into windows realm from within wsl
81 SRCDIR_WSL
:= $(shell $(WSL
) wslpath
-u
$(SRCDIR
))
82 BUILDDIR_WSL
:= $(shell $(WSL
) wslpath
-u
$(BUILDDIR
))
83 INSTDIR_WSL
:= $(shell $(WSL
) wslpath
-u
$(INSTDIR
))
84 WORKDIR_WSL
:= $(shell $(WSL
) wslpath
-u
$(WORKDIR
))
85 TARFILE_LOCATION_WSL
:= $(shell $(WSL
) wslpath
-u
$(TARFILE_LOCATION
))
87 define gb_Helper_wsl_path
88 $(subst $(TARFILE_LOCATION
)/,$(TARFILE_LOCATION_WSL
)/,$(subst $(SRCDIR
)/,$(SRCDIR_WSL
)/,$(subst $(BUILDDIR
)/,$(BUILDDIR_WSL
)/,$(subst $(INSTDIR
)/,$(INSTDIR_WSL
)/,$(subst $(WORKDIR
)/,$(WORKDIR_WSL
)/,$(1))))))
91 # not needed for cygwin
92 gb_Helper_wsl_path
=$(1)
96 # noop for non-Windows
97 gb_Helper_wsl_path
=$(1)
98 gb_Helper_cyg_path
=$(1)
101 define gb_Helper_make_clean_target
102 gb_
$(1)_get_clean_target
= $(WORKDIR
)/Clean
/$(1)/$$(1)
106 define gb_Helper_make_dep_target
107 gb_
$(1)_get_dep_target
= $(WORKDIR
)/Dep
/$(1)/$$(1).d
111 define gb_Helper_make_clean_targets
112 $(foreach targettype
,$(1),\
113 $(call gb_Helper_make_clean_target
,$(targettype
)))
117 define gb_Helper_make_dep_targets
118 $(foreach targettype
,$(1),\
119 $(call gb_Helper_make_dep_target
,$(targettype
)))
123 # e.g. 'make CppunitTest_sw_macros_test'
125 # gb_Helper_make_userfriendly_targets target class build-target? clean-target?
126 define gb_Helper_make_userfriendly_targets
127 .PHONY
: $(2) $(2)_
$(1) $(2)_
$(1).
clean
129 $(2)_
$(1) : $(if
$(3),$(3),$(call gb_
$(2)_get_target
,$(1)))
130 $(2)_
$(1).
clean : $(if
$(4),$(4),$(call gb_
$(2)_get_clean_target
,$(1)))
134 define gb_Helper_init_registries
135 gb_Executable_VALIDGROUPS_INSTALLED
:= UREBIN SDK OOO
136 gb_Executable_VALIDGROUPS_NOTINSTALLED
:= NONE
137 gb_Executable_VALIDGROUPS
:= UREBIN SDK OOO NONE
138 gb_Library_VALIDGROUPS_INSTALLED
:= OOOLIBS PLAINLIBS_URE PLAINLIBS_OOO PRIVATELIBS_URE RTVERLIBS UNOVERLIBS PLAINLIBS_SHLXTHDL
139 gb_Library_VALIDGROUPS_NOTINSTALLED
:= PLAINLIBS_NONE PLAINLIBS_OXT EXTENSIONLIBS
140 gb_Library_VALIDGROUPS
:= OOOLIBS PLAINLIBS_URE PLAINLIBS_OOO PRIVATELIBS_URE RTVERLIBS UNOVERLIBS PLAINLIBS_SHLXTHDL PLAINLIBS_NONE PLAINLIBS_OXT EXTENSIONLIBS
141 gb_Jar_VALIDGROUPS_INSTALLED
:= URE OOO
142 gb_Jar_VALIDGROUPS_NOTINSTALLED
:= OXT NONE
143 gb_Jar_VALIDGROUPS
:= URE OOO OXT NONE
145 $$(foreach group
,$$(gb_Executable_VALIDGROUPS
),$$(eval gb_Executable_
$$(group
) :=))
146 $$(foreach group
,$$(gb_Library_VALIDGROUPS
),$$(eval gb_Library_
$$(group
) :=))
147 $$(foreach group
,$$(gb_Jar_VALIDGROUPS
),$$(eval gb_Jar_
$$(group
) :=))
151 define gb_Helper_collect_knownlibs
152 gb_Library_KNOWNLIBS
:= $$(foreach group
,$$(gb_Library_VALIDGROUPS
),$$(gb_Library_
$$(group
)))
153 gb_Executable_KNOWN
:= $$(foreach group
,$$(gb_Executable_VALIDGROUPS
),$$(gb_Executable_
$$(group
)))
154 gb_Jar_KNOWN
:= $$(foreach group
,$$(gb_Jar_VALIDGROUPS
),$$(gb_Jar_
$$(group
)))
155 gb_Fuzzers_KNOWN
:= $$(filter %fuzzer
,$$(foreach group
,$$(gb_Executable_VALIDGROUPS
),$$(gb_Executable_
$$(group
))))
159 define gb_Helper_process_executable_registrations
160 $(foreach group
,$(gb_Executable_VALIDGROUPS
),\
161 $(foreach executable
,$(gb_Executable_
$(group
)),\
162 $(if
$(filter-out undefined
,$(origin gb_Executable__register_
$(executable
))),\
163 $(call gb_Executable__register_
$(executable
)))))
167 define gb_Helper__register_executables
168 $(foreach group
,$(gb_Executable_VALIDGROUPS
),\
169 $(foreach target
,$(2),\
170 $(if
$(filter $(target
),$(gb_Executable_
$(group
))),\
171 $(call gb_Output_error
,gb_Helper_register_executables
: already registered
: $(target
)))))
172 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
173 $(call gb_Output_error
,gb_Helper_register_executables
: contains duplicates
: $(2)))
175 gb_Executable_
$(1) += $(2)
179 # $(call gb_Helper_register_executables,layer,exes)
180 define gb_Helper_register_executables
181 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS_NOTINSTALLED
)),)
182 $$(eval
$$(call gb_Output_error
,$(1) is not a valid group for executables that are not installed. Valid groups are
: $$(gb_Executable_VALIDGROUPS_NOTINSTALLED
). Use gb_Helper_register_executables_for_install for installed executables.
))
184 $(call gb_Helper__register_executables
,$(1),$(2))
188 # $(call gb_Helper_register_executables_for_install,layer,installmodule,exes)
189 define gb_Helper_register_executables_for_install
190 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_executables_for_install
: no executables
- need
3 parameters
))
191 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS_INSTALLED
)),)
192 $$(eval
$$(call gb_Output_error
,$(1) is not a valid group for installed executables. Valid groups are
: $$(gb_Executable_VALIDGROUPS_INSTALLED
). Use gb_Helper_register_executables for executables that are not installed.
))
194 $(call gb_Helper__register_executables
,$(1),$(3))
196 gb_Executable_MODULE_
$(2) += $(3)
200 define gb_Helper__register_libraries
201 $(foreach group
,$(gb_Library_VALIDGROUPS
),\
202 $(foreach target
,$(2),\
203 $(if
$(filter $(target
),$(gb_Library_
$(group
))),\
204 $(call gb_Output_error
,gb_Helper_register_libraries
: already registered
: $(target
)))))
205 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
206 $(call gb_Output_error
,gb_Helper_register_libraries
: contains duplicates
: $(2)))
208 gb_Library_
$(1) += $(2)
212 # $(call gb_Helper_register_libraries,layer,libs)
213 define gb_Helper_register_libraries
214 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS_NOTINSTALLED
)),)
215 $$(eval
$$(call gb_Output_error
,$(1) is not a valid group for libraries that are not installed. Valid groups are
: $$(gb_Library_VALIDGROUPS_NOTINSTALLED
). Use gb_Helper_register_libraries_for_install for installed libraries.
))
217 $(call gb_Helper__register_libraries
,$(1),$(2))
221 # the first argument is the group, which sets rpaths etc.
222 # the second argument is the install module, which describes in which distro package/msi a lib should show up
223 # UGLY: for versioned libraries "sdk" module is hard-coded for now
224 # $(call gb_Helper_register_libraries_for_install,layer,installmodule,libs)
225 define gb_Helper_register_libraries_for_install
226 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_libraries_for_install
: no libraries
- need
3 parameters
))
227 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS_INSTALLED
)),)
228 $$(eval
$$(call gb_Output_error
,$(1) is not a valid group for installed libraries. Valid groups are
: $$(gb_Library_VALIDGROUPS_INSTALLED
). Use gb_Helper_register_libraries for libraries that are not installed.
))
230 $(call gb_Helper__register_libraries
,$(1),$(3))
232 gb_Library_MODULE_
$(2) += $(filter-out $(gb_MERGEDLIBS
),$(3))
234 $(if
$(filter UNOVERLIBS RTVERLIBS
,$(1)),\
235 gb_SdkLinkLibrary_MODULE_sdk
+= $(3))
239 # a plugin is a library, why can't be dynamically linked and must be dlopen'd, but must be linked static
240 define gb_Helper_register_plugins_for_install
241 $(call gb_Helper_register_libraries_for_install
,$(1),$(2),$(3))
242 gb_Library_KNOWNPLUGINS
+= $(3)
246 define gb_Helper__register_jars
247 $(foreach group
,$(gb_Jar_VALIDGROUPS
),\
248 $(foreach target
,$(2),\
249 $(if
$(filter $(target
),$(gb_Jar_
$(group
))),\
250 $(call gb_Output_error
,gb_Helper_register_jars
: already registered
: $(target
)))))
251 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
252 $(call gb_Output_error
,gb_Helper_register_jars
: contains duplicates
: $(2)))
258 # $(call gb_Helper_register_jars,layer,jars)
259 define gb_Helper_register_jars
260 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS_NOTINSTALLED
)),)
261 $$(eval
$$(call gb_Output_error
,$(1) is not a valid group for jars that are not installed. Valid groups are
: $$(gb_Jar_VALIDGROUPS_NOTINSTALLED
). Use gb_Helper_register_jars_for_install for installed jars.
))
263 $(call gb_Helper__register_jars
,$(1),$(2))
267 # $(call gb_Helper_register_jars_for_install,layer,installmodule,jars)
268 define gb_Helper_register_jars_for_install
269 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_jars_for_install
: no jars
- need
3 parameters
))
270 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS_INSTALLED
)),)
271 $$(eval
$$(call gb_Output_error
,$(1) is not a valid group for installed jars. Valid groups are
: $$(gb_Jar_VALIDGROUPS_INSTALLED
). Use gb_Helper_register_jars for jars that are not installed.
))
273 $(call gb_Helper__register_jars
,$(1),$(3))
275 gb_Jar_MODULE_
$(2) += $(3)
279 define gb_Helper__register_packages
280 $(foreach target
,$(1),\
281 $(if
$(filter $(target
),$(gb_Package_REGISTERED
)),\
282 $(call gb_Output_error
,gb_Helper_register_packages
: already registered
: $(target
))))
283 $(if
$(filter-out $(words $(1)),$(words $(sort $(1)))),\
284 $(call gb_Output_error
,gb_Helper_register_packages
: contains duplicates
: $(1)))
286 gb_Package_REGISTERED
+= $(1)
290 # $(call gb_Helper_register_packages,packages)
291 define gb_Helper_register_packages
292 $(call gb_Helper__register_packages
,$(1))
296 # $(call gb_Helper_register_packages_for_install,installmodule,packages)
297 define gb_Helper_register_packages_for_install
298 $(if
$(2),,$(call gb_Output_error
,gb_Helper_register_packages_for_install
: no packages
- need
2 parameters
))
299 $(call gb_Helper__register_packages
,$(2))
301 gb_Package_MODULE_
$(1) += $(2)
305 define gb_Helper_register_mos
306 gb_AllLangMoTarget_REGISTERED
+= $(1)
310 # TODO: this should be extended to handle auto-installation.
311 define gb_Helper_register_uiconfigs
312 gb_UIConfig_REGISTERED
+= $(1)
316 define gb_Helper_get_imagelists
317 $(foreach ui
,$(gb_UIConfig_REGISTERED
),$(call gb_UIConfig_get_imagelist_target
,$(ui
)))
320 # call gb_Helper_replace_if_different_and_touch,source,target,optional-touch-reference-file
321 define gb_Helper_replace_if_different_and_touch
322 if cmp
-s
$(1) $(2); then
rm $(1); \
323 else mv
$(1) $(2) $(if
$(3),&& touch
-r
$(3) $(2)); \
327 # call gb_Helper_copy_if_different_and_touch,source,target,optional-touch-reference-file
328 define gb_Helper_copy_if_different_and_touch
329 if
! cmp
-s
$(1) $(2); then \
330 cp
$(1) $(2) $(if
$(3),&& touch
-r
$(3) $(2)); \
334 define gb_Helper_define_if_set
335 $(foreach def
,$(1),$(if
$(filter TRUE YES
,$($(def
))),-D
$(def
)))
338 define gb_Helper_execute
339 $(call gb_Executable_get_command
,$(firstword $(1))) $(wordlist
2,$(words $(1)),$(1))
342 # define gb_Helper_install registered-target target-to-install target-from-workdir
343 define gb_Helper_install
345 $(2) : $(3) |
$(dir $(2)).
dir
346 $(call gb_Deliver_add_deliverable
,$(2),$(3),$(2))
349 # use if the installed target is the final target
350 define gb_Helper_install_final
351 $(1) : $(2) |
$(dir $(1)).
dir
352 $(call gb_Deliver_add_deliverable
,$(1),$(2),$(1))
355 # call gb_Helper_optional,build_type,if-true,if-false
356 define gb_Helper_optional
357 $(if
$(filter $(1),$(BUILD_TYPE
)),$(2),$(3))
360 # call gb_Helper_optionals_or,build_types,if-true,if-false
361 define gb_Helper_optionals_or
362 $(call gb_Helper_optional
,$(1),$(2),$(3))
365 # call gb_Helper_optionals_and,build_types,if-true,if-false
366 define gb_Helper_optionals_and
367 $(if
$(strip $(filter-out $(filter $(1),$(BUILD_TYPE
)),$(1))),$(3),$(2))
370 ifeq ($(WITH_LOCALES
),)
371 define gb_Helper_optional_locale
375 define gb_Helper_optional_locale
376 $(if
$(filter $(1) $(1)_
%,$(WITH_LOCALES
)),$(2))
380 define gb_Helper_print_on_error
381 $(if
$(gb_QUIET_EXTERNAL
), \
383 ( ( $(1) ) > $(2) 2>&1 ||
( cat
$(2) && false
) ), \
384 ( TEMPFILE
=$(shell $(gb_MKTEMP
)) && ( $(1) ) > $$TEMPFILE 2>&1 \
386 ||
( cat
$$TEMPFILE && rm $$TEMPFILE && false
) )), \
390 # vim: set noet sw=4 ts=4: