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
65 define gb_Helper_make_clean_target
66 gb_
$(1)_get_clean_target
= $(WORKDIR
)/Clean
/$(1)/$$(1)
70 define gb_Helper_make_dep_target
71 gb_
$(1)_get_dep_target
= $(WORKDIR
)/Dep
/$(1)/$$(1).d
75 define gb_Helper_make_clean_targets
76 $(foreach targettype
,$(1),\
77 $(call gb_Helper_make_clean_target
,$(targettype
)))
81 define gb_Helper_make_dep_targets
82 $(foreach targettype
,$(1),\
83 $(call gb_Helper_make_dep_target
,$(targettype
)))
87 # e.g. 'make CppunitTest_sw_macros_test'
89 # gb_Helper_make_userfriendly_targets target class build-target? clean-target?
90 define gb_Helper_make_userfriendly_targets
91 .PHONY
: $(2) $(2)_
$(1) $(2)_
$(1).
clean
93 $(2)_
$(1) : $(if
$(3),$(3),$(call gb_
$(2)_get_target
,$(1)))
94 $(2)_
$(1).
clean : $(if
$(4),$(4),$(call gb_
$(2)_get_clean_target
,$(1)))
98 define gb_Helper_init_registries
99 gb_Executable_VALIDGROUPS_INSTALLED
:= UREBIN SDK OOO
100 gb_Executable_VALIDGROUPS_NOTINSTALLED
:= NONE
101 gb_Executable_VALIDGROUPS
:= UREBIN SDK OOO NONE
102 gb_Library_VALIDGROUPS_INSTALLED
:= OOOLIBS PLAINLIBS_URE PLAINLIBS_OOO PRIVATELIBS_URE RTVERLIBS UNOVERLIBS PLAINLIBS_SHLXTHDL
103 gb_Library_VALIDGROUPS_NOTINSTALLED
:= PLAINLIBS_NONE PLAINLIBS_OXT EXTENSIONLIBS
104 gb_Library_VALIDGROUPS
:= OOOLIBS PLAINLIBS_URE PLAINLIBS_OOO PRIVATELIBS_URE RTVERLIBS UNOVERLIBS PLAINLIBS_SHLXTHDL PLAINLIBS_NONE PLAINLIBS_OXT EXTENSIONLIBS
105 gb_Jar_VALIDGROUPS_INSTALLED
:= URE OOO
106 gb_Jar_VALIDGROUPS_NOTINSTALLED
:= OXT NONE
107 gb_Jar_VALIDGROUPS
:= URE OOO OXT NONE
109 $$(foreach group
,$$(gb_Executable_VALIDGROUPS
),$$(eval gb_Executable_
$$(group
) :=))
110 $$(foreach group
,$$(gb_Library_VALIDGROUPS
),$$(eval gb_Library_
$$(group
) :=))
111 $$(foreach group
,$$(gb_Jar_VALIDGROUPS
),$$(eval gb_Jar_
$$(group
) :=))
115 define gb_Helper_collect_knownlibs
116 gb_Library_KNOWNLIBS
:= $$(foreach group
,$$(gb_Library_VALIDGROUPS
),$$(gb_Library_
$$(group
)))
117 gb_Executable_KNOWN
:= $$(foreach group
,$$(gb_Executable_VALIDGROUPS
),$$(gb_Executable_
$$(group
)))
118 gb_Jar_KNOWN
:= $$(foreach group
,$$(gb_Jar_VALIDGROUPS
),$$(gb_Jar_
$$(group
)))
122 define gb_Helper_process_executable_registrations
123 $(foreach group
,$(gb_Executable_VALIDGROUPS
),\
124 $(foreach executable
,$(gb_Executable_
$(group
)),\
125 $(if
$(filter-out undefined
,$(origin gb_Executable__register_
$(executable
))),\
126 $(call gb_Executable__register_
$(executable
)))))
130 define gb_Helper__register_executables
131 $(foreach group
,$(gb_Executable_VALIDGROUPS
),\
132 $(foreach target
,$(2),\
133 $(if
$(filter $(target
),$(gb_Executable_
$(group
))),\
134 $(call gb_Output_error
,gb_Helper_register_executables
: already registered
: $(target
)))))
135 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
136 $(call gb_Output_error
,gb_Helper_register_executables
: contains duplicates
: $(2)))
138 gb_Executable_
$(1) += $(2)
142 # $(call gb_Helper_register_executables,layer,exes)
143 define gb_Helper_register_executables
144 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS_NOTINSTALLED
)),)
145 $$(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.
))
147 $(call gb_Helper__register_executables
,$(1),$(2))
151 # $(call gb_Helper_register_executables_for_install,layer,installmodule,exes)
152 define gb_Helper_register_executables_for_install
153 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_executables_for_install
: no executables
- need
3 parameters
))
154 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS_INSTALLED
)),)
155 $$(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.
))
157 $(call gb_Helper__register_executables
,$(1),$(3))
159 gb_Executable_MODULE_
$(2) += $(3)
163 define gb_Helper__register_libraries
164 $(foreach group
,$(gb_Library_VALIDGROUPS
),\
165 $(foreach target
,$(2),\
166 $(if
$(filter $(target
),$(gb_Library_
$(group
))),\
167 $(call gb_Output_error
,gb_Helper_register_libraries
: already registered
: $(target
)))))
168 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
169 $(call gb_Output_error
,gb_Helper_register_libraries
: contains duplicates
: $(2)))
171 gb_Library_
$(1) += $(2)
175 # $(call gb_Helper_register_libraries,layer,libs)
176 define gb_Helper_register_libraries
177 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS_NOTINSTALLED
)),)
178 $$(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.
))
180 $(call gb_Helper__register_libraries
,$(1),$(2))
184 # the first argument is the group, which sets rpaths etc.
185 # the second argument is the install module, which describes in which distro package/msi a lib should show up
186 # UGLY: for versioned libraries "sdk" module is hard-coded for now
187 # $(call gb_Helper_register_libraries_for_install,layer,installmodule,libs)
188 define gb_Helper_register_libraries_for_install
189 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_libraries_for_install
: no libraries
- need
3 parameters
))
190 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS_INSTALLED
)),)
191 $$(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.
))
193 $(call gb_Helper__register_libraries
,$(1),$(3))
195 gb_Library_MODULE_
$(2) += $(filter-out $(gb_MERGEDLIBS
),$(3))
197 $(if
$(filter UNOVERLIBS RTVERLIBS
,$(1)),\
198 gb_SdkLinkLibrary_MODULE_sdk
+= $(3))
202 define gb_Helper__register_jars
203 $(foreach group
,$(gb_Jar_VALIDGROUPS
),\
204 $(foreach target
,$(2),\
205 $(if
$(filter $(target
),$(gb_Jar_
$(group
))),\
206 $(call gb_Output_error
,gb_Helper_register_jars
: already registered
: $(target
)))))
207 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
208 $(call gb_Output_error
,gb_Helper_register_jars
: contains duplicates
: $(2)))
214 # $(call gb_Helper_register_jars,layer,jars)
215 define gb_Helper_register_jars
216 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS_NOTINSTALLED
)),)
217 $$(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.
))
219 $(call gb_Helper__register_jars
,$(1),$(2))
223 # $(call gb_Helper_register_jars_for_install,layer,installmodule,jars)
224 define gb_Helper_register_jars_for_install
225 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_jars_for_install
: no jars
- need
3 parameters
))
226 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS_INSTALLED
)),)
227 $$(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.
))
229 $(call gb_Helper__register_jars
,$(1),$(3))
231 gb_Jar_MODULE_
$(2) += $(3)
235 define gb_Helper__register_packages
236 $(foreach target
,$(1),\
237 $(if
$(filter $(target
),$(gb_Package_REGISTERED
)),\
238 $(call gb_Output_error
,gb_Helper_register_packages
: already registered
: $(target
))))
239 $(if
$(filter-out $(words $(1)),$(words $(sort $(1)))),\
240 $(call gb_Output_error
,gb_Helper_register_packages
: contains duplicates
: $(1)))
242 gb_Package_REGISTERED
+= $(1)
246 # $(call gb_Helper_register_packages,packages)
247 define gb_Helper_register_packages
248 $(call gb_Helper__register_packages
,$(1))
252 # $(call gb_Helper_register_packages_for_install,installmodule,packages)
253 define gb_Helper_register_packages_for_install
254 $(if
$(2),,$(call gb_Output_error
,gb_Helper_register_packages_for_install
: no packages
- need
2 parameters
))
255 $(call gb_Helper__register_packages
,$(2))
257 gb_Package_MODULE_
$(1) += $(2)
261 define gb_Helper_register_mos
262 gb_AllLangMoTarget_REGISTERED
+= $(1)
266 # TODO: this should be extended to handle auto-installation.
267 define gb_Helper_register_uiconfigs
268 gb_UIConfig_REGISTERED
+= $(1)
272 define gb_Helper_get_imagelists
273 $(foreach ui
,$(gb_UIConfig_REGISTERED
),$(call gb_UIConfig_get_imagelist_target
,$(ui
)))
276 # call gb_Helper_replace_if_different_and_touch,source,target,optional-touch-reference-file
277 define gb_Helper_replace_if_different_and_touch
278 if cmp
-s
$(1) $(2); then
rm $(1); \
279 else mv
$(1) $(2) $(if
$(3),&& touch
-r
$(3) $(2)); \
283 define gb_Helper_define_if_set
284 $(foreach def
,$(1),$(if
$(filter TRUE YES
,$($(def
))),-D
$(def
)))
287 define gb_Helper_execute
288 $(call gb_Executable_get_command
,$(firstword $(1))) $(wordlist
2,$(words $(1)),$(1))
291 # define gb_Helper_install registered-target target-to-install target-from-workdir
292 define gb_Helper_install
294 $(2) : $(3) |
$(dir $(2)).
dir
295 $(call gb_Deliver_add_deliverable
,$(2),$(3),$(2))
298 # use if the installed target is the final target
299 define gb_Helper_install_final
300 $(1) : $(2) |
$(dir $(1)).
dir
301 $(call gb_Deliver_add_deliverable
,$(1),$(2),$(1))
304 define gb_Helper_optional
305 $(if
$(filter $(1),$(BUILD_TYPE
)),$(2))
308 ifeq ($(WITH_LOCALES
),)
309 define gb_Helper_optional_locale
313 define gb_Helper_optional_locale
314 $(if
$(filter $(1) $(1)_
%,$(WITH_LOCALES
)),$(2))
318 define gb_Helper_optional_for_host
319 $(if
$(filter build
,$(gb_Side
)), \
320 $(if
$(filter $(1),$(BUILD_TYPE_FOR_HOST
)),$(2)), \
321 $(call gb_Output_error
,gb_Helper_optional_for_host
: Use only when gb_Side
=build
))
324 define gb_Helper_print_on_error
325 $(if
$(gb_QUIET_EXTERNAL
), \
327 ( ( $(1) ) > $(2) 2>&1 ||
( cat
$(2) && false
) ), \
328 ( TEMPFILE
=$(shell $(gb_MKTEMP
)) && ( $(1) ) > $$TEMPFILE 2>&1 \
330 ||
( cat
$$TEMPFILE && rm $$TEMPFILE && false
) )), \
334 # vim: set noet sw=4 ts=4: