bump product version to 4.1.6.2
[LibreOffice.git] / solenv / gbuild / Helper.mk
blobaac67b7699edd32e57df07aa0c475d396d8eb4ca
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 .PHONY : $(WORKDIR)/Misc/PHONY
29 $(gb_Helper_MISCDUMMY) :
30 @mkdir -p $(dir $@) && touch $@
32 ifeq ($(SRCDIR),$(BUILDDIR))
33 define gb_Helper_abbreviate_dirs
34 S=$(SRCDIR) && \
35 $(subst $(SRCDIR)/,$$S/,O=$(OUTDIR)) && \
36 $(subst $(SRCDIR)/,$$S/,W=$(WORKDIR)) && \
37 $(subst $(SRCDIR)/,$$S/,$(subst $(OUTDIR)/,$$O/,$(subst $(WORKDIR)/,$$W/,$(1))))
38 endef
39 else
40 define gb_Helper_abbreviate_dirs
41 S=$(SRCDIR) && \
42 $(subst $(SRCDIR)/,$$S/,B=$(BUILDDIR)) && \
43 $(subst $(SRCDIR)/,$$S/,$(subst $(BUILDDIR)/,$$B/,O=$(OUTDIR))) && \
44 $(subst $(SRCDIR)/,$$S/,$(subst $(BUILDDIR)/,$$B/,W=$(WORKDIR))) && \
45 $(subst $(SRCDIR)/,$$S/,$(subst $(BUILDDIR)/,$$B/,$(subst $(OUTDIR)/,$$O/,$(subst $(WORKDIR)/,$$W/,$(1)))))
46 endef
47 endif
49 define gb_Helper_abbreviate_dirs_native
50 $(call gb_Output_error,gb_Helper_abbreviate_dirs_native: use gb_Helper_abbreviate_dirs instead.)
51 endef
53 define gb_Helper_native_path
54 $(call gb_Output_error,gb_Helper_native_path: Do not use. Should not be necessary.)
55 endef
57 # cygwin seems to eat one backslash when executing command, thus replace with '\\'
58 define gb_Helper_windows_path
59 $(subst /,\\,$(1))
60 endef
62 define gb_Helper_make_clean_target
63 gb_$(1)_get_clean_target = $(WORKDIR)/Clean/$(1)/$$(1)
65 endef
67 define gb_Helper_make_outdir_clean_target
68 gb_$(1)_get_clean_target = $$(subst $(OUTDIR)/,$(WORKDIR)/Clean/OutDir/,$$(call gb_$(1)_get_target,$$(1)))
70 endef
72 define gb_Helper_make_dep_target
73 gb_$(1)_get_dep_target = $(WORKDIR)/Dep/$(1)/$$(1).d
75 endef
77 define gb_Helper_make_clean_targets
78 $(foreach targettype,$(1),\
79 $(call gb_Helper_make_clean_target,$(targettype)))
81 endef
83 define gb_Helper_make_outdir_clean_targets
84 $(foreach targettype,$(1),\
85 $(call gb_Helper_make_outdir_clean_target,$(targettype)))
87 endef
89 define gb_Helper_make_dep_targets
90 $(foreach targettype,$(1),\
91 $(call gb_Helper_make_dep_target,$(targettype)))
93 endef
95 define gb_Helper_get_outdir_clean_target
96 $$(subst $(OUTDIR)/,$(WORKDIR)/Clean/OutDir/,$(1))
97 endef
99 # e.g. 'make CppunitTest_sw_macros_test'
101 # gb_Helper_make_userfriendly_targets target class build-target? clean-target?
102 define gb_Helper_make_userfriendly_targets
103 .PHONY: $(2)_$(1) $(2)_$(1).clean
104 $(2)_$(1) : $(if $(3),$(3),$(call gb_$(2)_get_target,$(1)))
105 $(2)_$(1).clean : $(if $(4),$(4),$(call gb_$(2)_get_clean_target,$(1)))
107 endef
109 define gb_Helper_init_registries
110 gb_Executable_VALIDGROUPS := UREBIN SDK OOO NONE
111 gb_Library_VALIDGROUPS := OOOLIBS PLAINLIBS_NONE PLAINLIBS_URE PLAINLIBS_OOO PRIVATELIBS_URE RTVERLIBS UNOLIBS_URE UNOVERLIBS EXTENSIONLIBS
112 gb_Library_VALIDINSTALLMODULES := GRAPHICFILTER GNOME TDE KDE OOO URE WRITER
113 gb_StaticLibrary_VALIDGROUPS := PLAINLIBS
114 gb_Jar_VALIDGROUPS := URE OOO OXT NONE
116 $$(foreach group,$$(gb_Executable_VALIDGROUPS),$$(eval gb_Executable_$$(group) :=))
117 $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(eval gb_Library_$$(group) :=))
118 $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(eval gb_StaticLibrary_$$(group) :=))
119 $$(foreach group,$$(gb_Jar_VALIDGROUPS),$$(eval gb_Jar_$$(group) :=))
121 endef
123 define gb_Helper_collect_knownlibs
124 gb_Library_KNOWNLIBS := $$(foreach group,$$(gb_Library_VALIDGROUPS),$$(gb_Library_$$(group)))
125 gb_StaticLibrary_KNOWNLIBS := $$(foreach group,$$(gb_StaticLibrary_VALIDGROUPS),$$(gb_StaticLibrary_$$(group)))
126 gb_Executable_KNOWN := $$(foreach group,$$(gb_Executable_VALIDGROUPS),$$(gb_Executable_$$(group)))
127 gb_Jar_KNOWN := $$(foreach group,$$(gb_Jar_VALIDGROUPS),$$(gb_Jar_$$(group)))
129 endef
131 define gb_Helper_process_executable_registrations
132 $(foreach group,$(gb_Executable_VALIDGROUPS),\
133 $(foreach executable,$(gb_Executable_$(group)),\
134 $(if $(filter-out undefined,$(origin gb_Executable__register_$(executable))),\
135 $(call gb_Executable__register_$(executable)))))
137 endef
139 define gb_Helper_register_executables
140 ifeq ($$(filter $(1),$$(gb_Executable_VALIDGROUPS)),)
141 $$(eval $$(call gb_Output_error,$(1) is not a valid group for executables. Valid groups are: $$(gb_Executable_VALIDGROUPS)))
142 endif
143 $(foreach group,$(gb_Executable_VALIDGROUPS),\
144 $(foreach target,$(2),\
145 $(if $(filter $(target),$(gb_Executable_$(group))),\
146 $(call gb_Output_error,gb_Helper_register_executables: already registered: $(target)))))
147 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
148 $(call gb_Output_error,gb_Helper_register_executables: contains duplicates: $(2)))
150 gb_Executable_$(1) += $(2)
152 endef
154 define gb_Helper_register_libraries
155 ifeq ($$(filter $(1),$$(gb_Library_VALIDGROUPS)),)
156 $$(eval $$(call gb_Output_error,$(1) is not a valid group for libraries. Valid groups are: $$(gb_Library_VALIDGROUPS)))
157 endif
158 $(foreach group,$(gb_Library_VALIDGROUPS),\
159 $(foreach target,$(2),\
160 $(if $(filter $(target),$(gb_Library_$(group))),\
161 $(call gb_Output_error,gb_Helper_register_libraries: already registered: $(target)))))
162 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
163 $(call gb_Output_error,gb_Helper_register_libraries: contains duplicates: $(2)))
165 gb_Library_$(1) += $(2)
167 endef
169 # the first argument is the group, which sets rpaths etc.
170 # the second argument is the install module, which describes in which distro package/msi a lib should show up
171 define gb_Helper_register_libraries_for_install
172 ifeq ($$(filter $(2),$$(gb_Library_VALIDINSTALLMODULES)),)
173 $$(eval $$(call gb_Output_error,$(2) is not a valid install module for libraries. Valid groups are: $$(gb_Library_VALIDINSTALLMODULES)))
174 endif
175 $(call gb_Helper_register_libraries,$(1),$(3))
177 gb_Library_MODULE_$(2) += $(filter-out $(gb_MERGEDLIBS) $(gb_URELIBS),$(3))
179 endef
181 define gb_Helper_register_static_libraries
182 ifeq ($$(filter $(1),$$(gb_StaticLibrary_VALIDGROUPS)),)
183 $$(eval $$(call gb_Output_error,$(1) is not a valid group for static libraries. Valid groups are: $$(gb_StaticLibrary_VALIDGROUPS)))
184 endif
185 $(foreach group,$(gb_StaticLibrary_VALIDGROUPS),\
186 $(foreach target,$(2),\
187 $(if $(filter $(target),$(gb_StaticLibrary_$(group))),\
188 $(call gb_Output_error,gb_Helper_register_static_libraries: already registered: $(target)))))
189 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
190 $(call gb_Output_error,gb_Helper_register_static_libraries: contains duplicates: $(2)))
192 gb_StaticLibrary_$(1) += $(2)
194 endef
196 define gb_Helper_register_jars
197 ifeq ($$(filter $(1),$$(gb_Jar_VALIDGROUPS)),)
198 $$(eval $$(call gb_Output_error,$(1) is not a valid group for jars. Valid groups are: $$(gb_Jar_VALIDGROUPS)))
199 endif
200 $(foreach group,$(gb_Jar_VALIDGROUPS),\
201 $(foreach target,$(2),\
202 $(if $(filter $(target),$(gb_Jar_$(group))),\
203 $(call gb_Output_error,gb_Helper_register_jars: already registered: $(target)))))
204 $(if $(filter-out $(words $(2)),$(words $(sort $(2)))),\
205 $(call gb_Output_error,gb_Helper_register_jars: contains duplicates: $(2)))
207 gb_Jar_$(1) += $(2)
209 endef
211 define gb_Helper_define_if_set
212 $(foreach def,$(1),$(if $(filter TRUE YES,$($(def))),-D$(def)))
213 endef
215 define gb_Helper_execute
216 $(call gb_Executable_get_command,$(firstword $(1))) $(wordlist 2,$(words $(1)),$(1))
217 endef
219 # gb_Helper_OUTDIRLIBDIR is set by the platform to the path the dynamic linker need to use
220 # for libraries from the OUTDIR
222 define gb_Helper_optional
223 $(if $(filter $(1),$(BUILD_TYPE)),$(2))
224 endef
226 define gb_Helper_optional_for_host
227 $(if $(filter $(1),$(BUILD_TYPE_FOR_HOST)),$(2))
228 endef
230 define gb_Helper_print_on_error
231 $(if $(gb_QUIET_EXTERNAL),( $(1) ) > $(2) 2>&1 || ( cat $(2) && false ),$(1) )
232 endef
234 # vim: set noet sw=4 ts=4: