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)_
$(1) $(2)_
$(1).
clean
92 $(2)_
$(1) : $(if
$(3),$(3),$(call gb_
$(2)_get_target
,$(1)))
93 $(2)_
$(1).
clean : $(if
$(4),$(4),$(call gb_
$(2)_get_clean_target
,$(1)))
97 define gb_Helper_init_registries
98 gb_Executable_VALIDGROUPS_INSTALLED
:= UREBIN SDK OOO
99 gb_Executable_VALIDGROUPS_NOTINSTALLED
:= NONE
100 gb_Executable_VALIDGROUPS
:= UREBIN SDK OOO NONE
101 gb_Library_VALIDGROUPS_INSTALLED
:= OOOLIBS PLAINLIBS_URE PLAINLIBS_OOO PRIVATELIBS_URE RTVERLIBS UNOVERLIBS PLAINLIBS_SHLXTHDL
102 gb_Library_VALIDGROUPS_NOTINSTALLED
:= PLAINLIBS_NONE EXTENSIONLIBS
103 gb_Library_VALIDGROUPS
:= OOOLIBS PLAINLIBS_URE PLAINLIBS_OOO PRIVATELIBS_URE RTVERLIBS UNOVERLIBS PLAINLIBS_SHLXTHDL PLAINLIBS_NONE EXTENSIONLIBS
104 gb_Jar_VALIDGROUPS_INSTALLED
:= URE OOO
105 gb_Jar_VALIDGROUPS_NOTINSTALLED
:= OXT NONE
106 gb_Jar_VALIDGROUPS
:= URE OOO OXT NONE
108 $$(foreach group
,$$(gb_Executable_VALIDGROUPS
),$$(eval gb_Executable_
$$(group
) :=))
109 $$(foreach group
,$$(gb_Library_VALIDGROUPS
),$$(eval gb_Library_
$$(group
) :=))
110 $$(foreach group
,$$(gb_Jar_VALIDGROUPS
),$$(eval gb_Jar_
$$(group
) :=))
114 define gb_Helper_collect_knownlibs
115 gb_Library_KNOWNLIBS
:= $$(foreach group
,$$(gb_Library_VALIDGROUPS
),$$(gb_Library_
$$(group
)))
116 gb_Executable_KNOWN
:= $$(foreach group
,$$(gb_Executable_VALIDGROUPS
),$$(gb_Executable_
$$(group
)))
117 gb_Jar_KNOWN
:= $$(foreach group
,$$(gb_Jar_VALIDGROUPS
),$$(gb_Jar_
$$(group
)))
121 define gb_Helper_process_executable_registrations
122 $(foreach group
,$(gb_Executable_VALIDGROUPS
),\
123 $(foreach executable
,$(gb_Executable_
$(group
)),\
124 $(if
$(filter-out undefined
,$(origin gb_Executable__register_
$(executable
))),\
125 $(call gb_Executable__register_
$(executable
)))))
129 define gb_Helper__register_executables
130 $(foreach group
,$(gb_Executable_VALIDGROUPS
),\
131 $(foreach target
,$(2),\
132 $(if
$(filter $(target
),$(gb_Executable_
$(group
))),\
133 $(call gb_Output_error
,gb_Helper_register_executables
: already registered
: $(target
)))))
134 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
135 $(call gb_Output_error
,gb_Helper_register_executables
: contains duplicates
: $(2)))
137 gb_Executable_
$(1) += $(2)
141 # $(call gb_Helper_register_executables,layer,exes)
142 define gb_Helper_register_executables
143 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS_NOTINSTALLED
)),)
144 $$(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.
))
146 $(call gb_Helper__register_executables
,$(1),$(2))
150 # $(call gb_Helper_register_executables_for_install,layer,installmodule,exes)
151 define gb_Helper_register_executables_for_install
152 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_executables_for_install
: no executables
- need
3 parameters
))
153 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS_INSTALLED
)),)
154 $$(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.
))
156 $(call gb_Helper__register_executables
,$(1),$(3))
158 gb_Executable_MODULE_
$(2) += $(3)
162 define gb_Helper__register_libraries
163 $(foreach group
,$(gb_Library_VALIDGROUPS
),\
164 $(foreach target
,$(2),\
165 $(if
$(filter $(target
),$(gb_Library_
$(group
))),\
166 $(call gb_Output_error
,gb_Helper_register_libraries
: already registered
: $(target
)))))
167 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
168 $(call gb_Output_error
,gb_Helper_register_libraries
: contains duplicates
: $(2)))
170 gb_Library_
$(1) += $(2)
174 # $(call gb_Helper_register_libraries,layer,libs)
175 define gb_Helper_register_libraries
176 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS_NOTINSTALLED
)),)
177 $$(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.
))
179 $(call gb_Helper__register_libraries
,$(1),$(2))
183 # the first argument is the group, which sets rpaths etc.
184 # the second argument is the install module, which describes in which distro package/msi a lib should show up
185 # UGLY: for versioned libraries "sdk" module is hard-coded for now
186 # $(call gb_Helper_register_libraries_for_install,layer,installmodule,libs)
187 define gb_Helper_register_libraries_for_install
188 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_libraries_for_install
: no libraries
- need
3 parameters
))
189 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS_INSTALLED
)),)
190 $$(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.
))
192 $(call gb_Helper__register_libraries
,$(1),$(3))
194 gb_Library_MODULE_
$(2) += $(filter-out $(gb_MERGEDLIBS
),$(3))
196 $(if
$(filter UNOVERLIBS RTVERLIBS
,$(1)),\
197 gb_SdkLinkLibrary_MODULE_sdk
+= $(3))
201 define gb_Helper__register_jars
202 $(foreach group
,$(gb_Jar_VALIDGROUPS
),\
203 $(foreach target
,$(2),\
204 $(if
$(filter $(target
),$(gb_Jar_
$(group
))),\
205 $(call gb_Output_error
,gb_Helper_register_jars
: already registered
: $(target
)))))
206 $(if
$(filter-out $(words $(2)),$(words $(sort $(2)))),\
207 $(call gb_Output_error
,gb_Helper_register_jars
: contains duplicates
: $(2)))
213 # $(call gb_Helper_register_jars,layer,jars)
214 define gb_Helper_register_jars
215 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS_NOTINSTALLED
)),)
216 $$(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.
))
218 $(call gb_Helper__register_jars
,$(1),$(2))
222 # $(call gb_Helper_register_jars_for_install,layer,installmodule,jars)
223 define gb_Helper_register_jars_for_install
224 $(if
$(3),,$(call gb_Output_error
,gb_Helper_register_jars_for_install
: no jars
- need
3 parameters
))
225 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS_INSTALLED
)),)
226 $$(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.
))
228 $(call gb_Helper__register_jars
,$(1),$(3))
230 gb_Jar_MODULE_
$(2) += $(3)
234 # $(call gb_Helper_register_packages_for_install,installmodule,packages)
235 define gb_Helper_register_packages_for_install
236 $(if
$(2),,$(call gb_Output_error
,gb_Helper_register_packages_for_install
: no packages
- need
2 parameters
))
238 gb_Package_MODULE_
$(1) += $(2)
242 # call gb_Helper_replace_if_different_and_touch,source,target,optional-touch-reference-file
243 define gb_Helper_replace_if_different_and_touch
244 if cmp
-s
$(1) $(2); then
rm $(1); \
245 else mv
$(1) $(2) $(if
$(3),&& touch
-r
$(3) $(2)); \
249 define gb_Helper_define_if_set
250 $(foreach def
,$(1),$(if
$(filter TRUE YES
,$($(def
))),-D
$(def
)))
253 define gb_Helper_execute
254 $(call gb_Executable_get_command
,$(firstword $(1))) $(wordlist
2,$(words $(1)),$(1))
257 # define gb_Helper_install registered-target target-to-install target-from-workdir
258 define gb_Helper_install
260 $(2) : $(3) |
$(dir $(2)).
dir
261 $(call gb_Deliver_add_deliverable
,$(2),$(3),$(2))
264 # use if the installed target is the final target
265 define gb_Helper_install_final
266 $(1) : $(2) |
$(dir $(1)).
dir
267 $(call gb_Deliver_add_deliverable
,$(1),$(2),$(1))
270 define gb_Helper_optional
271 $(if
$(filter $(1),$(BUILD_TYPE
)),$(2))
274 ifeq ($(WITH_LOCALES
),)
275 define gb_Helper_optional_locale
279 define gb_Helper_optional_locale
280 $(if
$(filter $(1) $(1)_
%,$(WITH_LOCALES
)),$(2))
284 define gb_Helper_optional_for_host
285 $(if
$(filter $(1),$(BUILD_TYPE_FOR_HOST
)),$(2))
288 define gb_Helper_print_on_error
289 $(if
$(gb_QUIET_EXTERNAL
),( $(1) ) > $(2) 2>&1 ||
( cat
$(2) && false
),$(1) )
292 # vim: set noet sw=4 ts=4: