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
)))
119 gb_Fuzzers_KNOWN
:= $$(filter %fuzzer
,$$(foreach group
,$$(gb_Executable_VALIDGROUPS
),$$(gb_Executable_
$$(group
))))
123 define gb_Helper_process_executable_registrations
124 $(foreach group
,$(gb_Executable_VALIDGROUPS
),\
125 $(foreach executable
,$(gb_Executable_
$(group
)),\
126 $(if
$(filter-out undefined
,$(origin gb_Executable__register_
$(executable
))),\
127 $(call gb_Executable__register_
$(executable
)))))
131 define gb_Helper__register_executables
132 $(foreach group
,$(gb_Executable_VALIDGROUPS
),\
133 $(foreach target
,$(2),\
134 $(if
$(filter $(target
),$(gb_Executable_
$(group
))),\
135 $(call gb_Output_error
,gb_Helper_register_executables
: already registered
: $(target
)))))
136 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
137 $(call gb_Output_error
,gb_Helper_register_executables
: contains duplicates
: $(2)))
139 gb_Executable_
$(1) += $(2)
143 # $(call gb_Helper_register_executables,layer,exes)
144 define gb_Helper_register_executables
145 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS_NOTINSTALLED
)),)
146 $$(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.
))
148 $(call gb_Helper__register_executables
,$(1),$(2))
152 # $(call gb_Helper_register_executables_for_install,layer,installmodule,exes)
153 define gb_Helper_register_executables_for_install
154 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_executables_for_install
: no executables
- need
3 parameters
))
155 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS_INSTALLED
)),)
156 $$(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.
))
158 $(call gb_Helper__register_executables
,$(1),$(3))
160 gb_Executable_MODULE_
$(2) += $(3)
164 define gb_Helper__register_libraries
165 $(foreach group
,$(gb_Library_VALIDGROUPS
),\
166 $(foreach target
,$(2),\
167 $(if
$(filter $(target
),$(gb_Library_
$(group
))),\
168 $(call gb_Output_error
,gb_Helper_register_libraries
: already registered
: $(target
)))))
169 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
170 $(call gb_Output_error
,gb_Helper_register_libraries
: contains duplicates
: $(2)))
172 gb_Library_
$(1) += $(2)
176 # $(call gb_Helper_register_libraries,layer,libs)
177 define gb_Helper_register_libraries
178 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS_NOTINSTALLED
)),)
179 $$(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.
))
181 $(call gb_Helper__register_libraries
,$(1),$(2))
185 # the first argument is the group, which sets rpaths etc.
186 # the second argument is the install module, which describes in which distro package/msi a lib should show up
187 # UGLY: for versioned libraries "sdk" module is hard-coded for now
188 # $(call gb_Helper_register_libraries_for_install,layer,installmodule,libs)
189 define gb_Helper_register_libraries_for_install
190 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_libraries_for_install
: no libraries
- need
3 parameters
))
191 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS_INSTALLED
)),)
192 $$(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.
))
194 $(call gb_Helper__register_libraries
,$(1),$(3))
196 gb_Library_MODULE_
$(2) += $(filter-out $(gb_MERGEDLIBS
),$(3))
198 $(if
$(filter UNOVERLIBS RTVERLIBS
,$(1)),\
199 gb_SdkLinkLibrary_MODULE_sdk
+= $(3))
203 # a plugin is a library, why can't be dynamically linked and must be dlopen'd, but must be linked static
204 define gb_Helper_register_plugins_for_install
205 $(call gb_Helper_register_libraries_for_install
,$(1),$(2),$(3))
206 gb_Library_KNOWNPLUGINS
+= $(3)
210 define gb_Helper__register_jars
211 $(foreach group
,$(gb_Jar_VALIDGROUPS
),\
212 $(foreach target
,$(2),\
213 $(if
$(filter $(target
),$(gb_Jar_
$(group
))),\
214 $(call gb_Output_error
,gb_Helper_register_jars
: already registered
: $(target
)))))
215 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
216 $(call gb_Output_error
,gb_Helper_register_jars
: contains duplicates
: $(2)))
222 # $(call gb_Helper_register_jars,layer,jars)
223 define gb_Helper_register_jars
224 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS_NOTINSTALLED
)),)
225 $$(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.
))
227 $(call gb_Helper__register_jars
,$(1),$(2))
231 # $(call gb_Helper_register_jars_for_install,layer,installmodule,jars)
232 define gb_Helper_register_jars_for_install
233 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_jars_for_install
: no jars
- need
3 parameters
))
234 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS_INSTALLED
)),)
235 $$(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.
))
237 $(call gb_Helper__register_jars
,$(1),$(3))
239 gb_Jar_MODULE_
$(2) += $(3)
243 define gb_Helper__register_packages
244 $(foreach target
,$(1),\
245 $(if
$(filter $(target
),$(gb_Package_REGISTERED
)),\
246 $(call gb_Output_error
,gb_Helper_register_packages
: already registered
: $(target
))))
247 $(if
$(filter-out $(words $(1)),$(words $(sort $(1)))),\
248 $(call gb_Output_error
,gb_Helper_register_packages
: contains duplicates
: $(1)))
250 gb_Package_REGISTERED
+= $(1)
254 # $(call gb_Helper_register_packages,packages)
255 define gb_Helper_register_packages
256 $(call gb_Helper__register_packages
,$(1))
260 # $(call gb_Helper_register_packages_for_install,installmodule,packages)
261 define gb_Helper_register_packages_for_install
262 $(if
$(2),,$(call gb_Output_error
,gb_Helper_register_packages_for_install
: no packages
- need
2 parameters
))
263 $(call gb_Helper__register_packages
,$(2))
265 gb_Package_MODULE_
$(1) += $(2)
269 define gb_Helper_register_mos
270 gb_AllLangMoTarget_REGISTERED
+= $(1)
274 # TODO: this should be extended to handle auto-installation.
275 define gb_Helper_register_uiconfigs
276 gb_UIConfig_REGISTERED
+= $(1)
280 define gb_Helper_get_imagelists
281 $(foreach ui
,$(gb_UIConfig_REGISTERED
),$(call gb_UIConfig_get_imagelist_target
,$(ui
)))
284 # call gb_Helper_replace_if_different_and_touch,source,target,optional-touch-reference-file
285 define gb_Helper_replace_if_different_and_touch
286 if cmp
-s
$(1) $(2); then
rm $(1); \
287 else mv
$(1) $(2) $(if
$(3),&& touch
-r
$(3) $(2)); \
291 # call gb_Helper_copy_if_different_and_touch,source,target,optional-touch-reference-file
292 define gb_Helper_copy_if_different_and_touch
293 if
! cmp
-s
$(1) $(2); then \
294 cp
$(1) $(2) $(if
$(3),&& touch
-r
$(3) $(2)); \
298 define gb_Helper_define_if_set
299 $(foreach def
,$(1),$(if
$(filter TRUE YES
,$($(def
))),-D
$(def
)))
302 define gb_Helper_execute
303 $(call gb_Executable_get_command
,$(firstword $(1))) $(wordlist
2,$(words $(1)),$(1))
306 # define gb_Helper_install registered-target target-to-install target-from-workdir
307 define gb_Helper_install
309 $(2) : $(3) |
$(dir $(2)).
dir
310 $(call gb_Deliver_add_deliverable
,$(2),$(3),$(2))
313 # use if the installed target is the final target
314 define gb_Helper_install_final
315 $(1) : $(2) |
$(dir $(1)).
dir
316 $(call gb_Deliver_add_deliverable
,$(1),$(2),$(1))
319 # call gb_Helper_optional,build_type,if-true,if-false
320 define gb_Helper_optional
321 $(if
$(filter $(1),$(BUILD_TYPE
)),$(2),$(3))
324 # call gb_Helper_optionals_or,build_types,if-true,if-false
325 define gb_Helper_optionals_or
326 $(call gb_Helper_optional
,$(1),$(2),$(3))
329 # call gb_Helper_optionals_and,build_types,if-true,if-false
330 define gb_Helper_optionals_and
331 $(if
$(strip $(filter-out $(filter $(1),$(BUILD_TYPE
)),$(1))),$(3),$(2))
334 ifeq ($(WITH_LOCALES
),)
335 define gb_Helper_optional_locale
339 define gb_Helper_optional_locale
340 $(if
$(filter $(1) $(1)_
%,$(WITH_LOCALES
)),$(2))
344 define gb_Helper_print_on_error
345 $(if
$(gb_QUIET_EXTERNAL
), \
347 ( ( $(1) ) > $(2) 2>&1 ||
( cat
$(2) && false
) ), \
348 ( TEMPFILE
=$(shell $(gb_MKTEMP
)) && ( $(1) ) > $$TEMPFILE 2>&1 \
350 ||
( cat
$$TEMPFILE && rm $$TEMPFILE && false
) )), \
354 # vim: set noet sw=4 ts=4: