bump product version to 4.1.6.2
[LibreOffice.git] / solenv / gbuild / ExternalPackage.mk
blob1a2abefaf66461062d28819338258204deae18e7
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/.
10 # ExternalPackage class
12 # This class extends Package to reliably deliver header files (and
13 # possibly other kinds of files) from unpacked tarballs. The problem
14 # with using Package is that the unpacked files' timestamps do not
15 # depend on the extraction time; when the project's tarball is updated,
16 # some header files might have been changed, but it is likely their
17 # timestamps will be older than these of the headers delivered from the
18 # previous version, so the delivered headers will not be updated.
20 # Uff, I hope this is at least partially understandable :-)
22 # Note: An ExternalPackage object can be used in functions that expect a
23 # Package (e.g., gb_LinkTarget_use_package(s)).
25 $(dir $(call gb_ExternalPackage_get_target,%)).dir :
26 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
28 $(dir $(call gb_ExternalPackage_get_target,%))%/.dir :
29 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
31 $(call gb_ExternalPackage_get_target,%) :
32 $(call gb_Output_announce,$*,$(true),EPK,2)
33 touch $@
35 $(call gb_ExternalPackage_get_clean_target,%) :
36 $(call gb_Output_announce,$*,$(false),EPK,2)
37 rm -f $(call gb_ExternalPackage_get_target,$*)
39 # Get name of the Package used for delivering files for install to $(INSTDIR).
40 gb_ExternalPackage_get_packagename = ExternalPackage/$(1)
42 # Create and register a new ExternalPackage
44 # The base directory of the package is the directory of the unpacked
45 # tarball.
47 # gb_ExternalPackage_ExternalPackage name unpacked
48 define gb_ExternalPackage_ExternalPackage
49 $(call gb_ExternalPackage_ExternalPackage_internal,$(1),$(2))
51 $$(eval $$(call gb_Module_register_target,$(call gb_ExternalPackage_get_target,$(1)),$(call gb_ExternalPackage_get_clean_target,$(1))))
52 $(call gb_Helper_make_userfriendly_targets,$(1),ExternalPackage)
54 endef
56 # Create a new ExternalPackage
58 # This function should only be used in implementations of other gbuild
59 # classes.
61 # gb_ExternalPackage_ExternalPackage_internal name unpacked
62 define gb_ExternalPackage_ExternalPackage_internal
63 $(call gb_Package_Package_internal,$(1),$(call gb_UnpackedTarball_get_dir,$(2)))
64 $(call gb_Package_use_unpacked,$(1),$(2))
66 ifneq ($(gb_RUNNABLE_INSTDIR),)
67 $(call gb_ExternalPackage__ExternalPackage_package,$(1),$(call gb_ExternalPackage_get_packagename,$(1)),$(2))
68 endif
70 $(call gb_ExternalPackage_get_target,$(1)) : $(call gb_Package_get_target,$(1))
71 $(call gb_ExternalPackage_get_target,$(1)) :| $(dir $(call gb_ExternalPackage_get_target,$(1))).dir
72 $(call gb_ExternalPackage_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(1))
74 gb_ExternalPackage_UNPACKED_$(1) := $(2)
76 endef
78 # gb_ExternalPackage__ExternalPackage_package package inst-package unpacked
79 define gb_ExternalPackage__ExternalPackage_package
80 $(call gb_Package_Package_internal,$(2),$(call gb_UnpackedTarball_get_dir,$(3)))
81 $(call gb_Package_set_outdir,$(2),$(INSTDIR))
82 $(call gb_Package_use_unpacked,$(2),$(3))
84 endef
86 # Set output dir for the package's files.
88 # Default is $(OUTDIR).
90 # gb_ExternalPackage_set_outdir package outdir
91 define gb_ExternalPackage_set_outdir
92 $(call gb_Package_set_outdir,$(1),$(2))
94 endef
96 # Mark a source file to be used outside of this module
98 # This results in the timestamp of the file being updated, so a possible
99 # change is recognized properly by other files depending on it.
101 # gb_ExternalPackage_mark_generated_file package file
102 define gb_ExternalPackage_mark_generated_file
103 $(call gb_UnpackedTarball_get_dir,$(gb_ExternalPackage_UNPACKED_$(1)))/$(2) : \
104 $(call gb_ExternalProject_get_target,$(gb_ExternalPackage_PROJECT_$(1)))
105 $(if $(suffix $(2)),\
106 $(call gb_UnpackedTarbal__ensure_pattern_rule,$(gb_ExternalPackage_UNPACKED_$(1)),$(suffix $(2))),\
107 $(call gb_UnpackedTarbal__make_file_rule,$(gb_ExternalPackage_UNPACKED_$(1)),$(2)) \
110 endef
112 # Mark several source files to be used outside of this module
114 # gb_ExternalProject_mark_generated_files package file(s)
115 define gb_ExternalPackage_mark_generated_files
116 $(foreach file,$(2),$(call gb_ExternalProject_mark_generated_file,$(1),$(file)))
118 endef
120 # Add a file
122 # See gb_Package_add_file for details.
124 # gb_ExternalPackage_add_file package dest src
125 define gb_ExternalPackage_add_file
126 $(call gb_ExternalPackage_mark_generated_file,$(1),$(3))
127 $(call gb_Package_add_file,$(1),$(2),$(3))
129 endef
131 # Add several files at once
133 # See gb_Package_add_files for details.
135 # gb_ExternalPackage_add_files package destdir file(s)
136 define gb_ExternalPackage_add_files
137 $(call gb_ExternalPackage_mark_generated_files,$(1),$(3))
138 $(call gb_Package_add_files,$(1),$(2),$(3))
140 endef
142 # Add several files at once
144 # See gb_Package_add_files_with_dir for details.
146 # gb_ExternalPackage_add_files_with_dir package destdir file(s)
147 define gb_ExternalPackage_add_files_with_dir
148 $(call gb_ExternalPackage_mark_generated_files,$(1),$(3))
149 $(call gb_Package_add_files_with_dir,$(1),$(2),$(3))
151 endef
153 define gb_ExternalPackage__add_file
154 $(call gb_UnpackedTarball_mark_output_file,$(gb_ExternalPackage_UNPACKED_$(1)),$(2))
156 endef
158 # Add an unpacked file
160 # See gb_Package_add_file for details.
162 # gb_ExternalPackage_add_unpacked_file package dest src
163 define gb_ExternalPackage_add_unpacked_file
164 $(call gb_Package_add_file,$(1),$(2),$(3))
165 $(call gb_ExternalPackage__add_file,$(1),$(3))
167 endef
169 define gb_ExternalPackage__add_files
170 $(foreach file,$(2),$(call gb_ExternalPackage__add_file,$(1),$(file)))
172 endef
174 # Add several unpacked files at once
176 # See gb_Package_add_files for details.
178 # gb_ExternalPackage_add_unpacked_files package destdir file(s)
179 define gb_ExternalPackage_add_unpacked_files
180 $(call gb_Package_add_files,$(1),$(2),$(3))
181 $(call gb_ExternalPackage__add_files,$(1),$(3))
183 endef
185 # Add several unpacked files at once
187 # See gb_Package_add_files_with_dir for details.
189 # gb_ExternalPackage_add_unpacked_files_with_dir package destdir file(s)
190 define gb_ExternalPackage_add_unpacked_files_with_dir
191 $(call gb_Package_add_files_with_dir,$(1),$(2),$(3))
192 $(call gb_ExternalPackage__add_files,$(1),$(3))
194 endef
196 # Package files from build of an external project
198 # gb_ExternalPackage_use_external_project package external
199 define gb_ExternalPackage_use_external_project
200 $(call gb_Package_use_external_project,$(1),$(2))
202 ifneq ($(gb_RUNNABLE_INSTDIR),)
203 $(call gb_Package_use_external_project,$(call gb_ExternalPackage_get_packagename,$(1)),$(2))
204 endif
206 $(if $(gb_ExternalPackage_PROJECT_$(1)),$(call gb_Output_error,gb_ExternalPackage_use_external_project: only one project allowed))
207 gb_ExternalPackage_PROJECT_$(1) := $(2)
209 endef
211 # gb_ExternalPackage__add_file_for_install package package-inst dest dest-inst src
212 define gb_ExternalPackage__add_file_for_install
213 $(call gb_ExternalPackage_add_file,$(1),$(3),$(5))
215 ifneq ($(gb_RUNNABLE_INSTDIR),)
216 $(call gb_ExternalPackage_add_file,$(2),$(4),$(5))
217 $(call gb_ExternalPackage_get_target,$(1)) : $(call gb_Package_get_target,$(2))
218 $(call gb_ExternalPackage_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(2))
219 endif
221 endef
223 # Add a (dynamic) library that is a part of the installation.
225 # This function is very similar to gb_ExternalPackage_add_file, except
226 # that it also allows to deliver the library to its proper place in
227 # $(INSTDIR).
229 # The last argument is the name under which the library was registered.
230 # It is used to determine layer, if the library is not in layer OOO.
232 # gb_ExternalPackage_add_library_for_install package dest src library?
233 define gb_ExternalPackage_add_library_for_install
234 $(call gb_ExternalPackage__add_file_for_install,$(1),$(call gb_ExternalPackage_get_packagename,$(1)),$(2),$(if $(4),$(call gb_Library_get_instdir,$(4)),$(gb_Package_PROGRAMDIRNAME))/$(notdir $(2)),$(3))
236 endef
238 # Add several libraries for install at once.
240 # gb_ExternalPackage_add_libraries_for_install package destdir file(s)
241 define gb_ExternalPackage_add_libraries_for_install
242 $(foreach file,$(3),$(call gb_ExternalPackage_add_library_for_install,$(1),$(2)/$(notdir $(file)),$(file)))
244 endef
246 # Add a jar that is a part of the installation.
248 # This function works just like to gb_ExternalPackage_add_file, except
249 # that it also allows to deliver the jar to its proper place in
250 # $(INSTDIR).
252 # gb_ExternalPackage_add_jar_for_install package dest src
253 define gb_ExternalPackage_add_jar_for_install
254 $(call gb_ExternalPackage__add_file_for_install,$(1),$(call gb_ExternalPackage_get_packagename,$(1)),$(2),$(gb_Package_PROGRAMDIRNAME)/classes/$(notdir $(2)),$(3))
256 endef
258 # Add several jars for install at once.
260 # gb_ExternalPackage_add_jars_for_install package destdir file(s)
261 define gb_ExternalPackage_add_jars_for_install
262 $(foreach file,$(3),$(call gb_ExternalPackage_add_jar_for_install,$(1),$(2)/$(notdir $(file)),$(file)))
264 endef
266 # vim: set noet sw=4 ts=4: