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 $(call gb_Trace_MakeMark
,$*,EPK
)
36 $(call gb_ExternalPackage_get_clean_target
,%) :
37 $(call gb_Output_announce
,$*,$(false
),EPK
,2)
38 rm -f
$(call gb_ExternalPackage_get_target
,$*)
40 # Create and register a new ExternalPackage
42 # The base directory of the package is the directory of the unpacked
45 # gb_ExternalPackage_ExternalPackage name unpacked
46 define gb_ExternalPackage_ExternalPackage
47 $(call gb_ExternalPackage_ExternalPackage_internal
,$(1),$(2))
49 $$(eval
$$(call gb_Module_register_target
,$(call gb_ExternalPackage_get_target
,$(1)),$(call gb_ExternalPackage_get_clean_target
,$(1))))
50 $(call gb_Helper_make_userfriendly_targets
,$(1),ExternalPackage
)
54 # Create a new ExternalPackage
56 # This function should only be used in implementations of other gbuild
59 # gb_ExternalPackage_ExternalPackage_internal name unpacked
60 define gb_ExternalPackage_ExternalPackage_internal
61 $(call gb_Package_Package_internal
,$(1),$(call gb_UnpackedTarball_get_dir
,$(2)))
62 $(call gb_Package_use_unpacked
,$(1),$(2))
64 $(call gb_ExternalPackage_get_target
,$(1)) : $(call gb_Package_get_target
,$(1))
65 $(call gb_ExternalPackage_get_target
,$(1)) :|
$(dir $(call gb_ExternalPackage_get_target
,$(1))).
dir
66 $(call gb_ExternalPackage_get_clean_target
,$(1)) : $(call gb_Package_get_clean_target
,$(1))
68 gb_ExternalPackage_UNPACKED_
$(1) := $(2)
72 # Set output dir for the package's files.
74 # Default is $(INSTROOT).
76 # gb_ExternalPackage_set_outdir package outdir
77 define gb_ExternalPackage_set_outdir
78 $(call gb_Package_set_outdir
,$(1),$(2))
82 # Mark a source file to be used outside of this module
84 # This results in the timestamp of the file being updated, so a possible
85 # change is recognized properly by other files depending on it.
87 # gb_ExternalPackage_mark_generated_file package file
88 define gb_ExternalPackage_mark_generated_file
89 $(call gb_UnpackedTarball_get_dir
,$(gb_ExternalPackage_UNPACKED_
$(1)))/$(2) : \
90 $(call gb_ExternalProject_get_target
,$(gb_ExternalPackage_PROJECT_
$(1)))
92 $(call gb_UnpackedTarbal__ensure_pattern_rule
,$(gb_ExternalPackage_UNPACKED_
$(1)),$(suffix $(2))),\
93 $(call gb_UnpackedTarbal__make_file_rule
,$(gb_ExternalPackage_UNPACKED_
$(1)),$(2)) \
98 # Mark several source files to be used outside of this module
100 # gb_ExternalProject_mark_generated_files package file(s)
101 define gb_ExternalPackage_mark_generated_files
102 $(foreach file
,$(2),$(call gb_ExternalPackage_mark_generated_file
,$(1),$(file
)))
106 define gb_ExternalPackage_add_symbolic_link
107 $(call gb_Package_add_symbolic_link
,$(1),$(2),$(3))
113 # See gb_Package_add_file for details.
115 # gb_ExternalPackage_add_file package dest src
116 define gb_ExternalPackage_add_file
117 $(if
$(4),$(call gb_Output_error
,gb_ExternalPackage_add_file
: $(1) 4: $(4)))
118 $(call gb_ExternalPackage_mark_generated_file
,$(1),$(3))
119 $(call gb_Package_add_file
,$(1),$(2),$(3))
123 # Add several files at once
125 # See gb_Package_add_files for details.
127 # gb_ExternalPackage_add_files package destdir file(s)
128 define gb_ExternalPackage_add_files
129 $(call gb_ExternalPackage_mark_generated_files
,$(1),$(3))
130 $(call gb_Package_add_files
,$(1),$(2),$(3))
134 # Add several files at once
136 # See gb_Package_add_files_with_dir for details.
138 # gb_ExternalPackage_add_files_with_dir package destdir file(s)
139 define gb_ExternalPackage_add_files_with_dir
140 $(call gb_ExternalPackage_mark_generated_files
,$(1),$(3))
141 $(call gb_Package_add_files_with_dir
,$(1),$(2),$(3))
145 define gb_ExternalPackage__add_file
146 $(call gb_UnpackedTarball_mark_output_file
,$(gb_ExternalPackage_UNPACKED_
$(1)),$(2))
150 # Add an unpacked file
152 # See gb_Package_add_file for details.
154 # gb_ExternalPackage_add_unpacked_file package dest src
155 define gb_ExternalPackage_add_unpacked_file
156 $(call gb_Package_add_file
,$(1),$(2),$(3))
157 $(call gb_ExternalPackage__add_file
,$(1),$(3))
161 define gb_ExternalPackage__add_files
162 $(foreach file
,$(2),$(call gb_ExternalPackage__add_file
,$(1),$(file
)))
166 # Add several unpacked files at once
168 # See gb_Package_add_files for details.
170 # gb_ExternalPackage_add_unpacked_files package destdir file(s)
171 define gb_ExternalPackage_add_unpacked_files
172 $(call gb_Package_add_files
,$(1),$(2),$(3))
173 $(call gb_ExternalPackage__add_files
,$(1),$(3))
177 # Add several unpacked files at once
179 # See gb_Package_add_files_with_dir for details.
181 # gb_ExternalPackage_add_unpacked_files_with_dir package destdir file(s)
182 define gb_ExternalPackage_add_unpacked_files_with_dir
183 $(call gb_Package_add_files_with_dir
,$(1),$(2),$(3))
184 $(call gb_ExternalPackage__add_files
,$(1),$(3))
188 # Package files from unpacked tarball of an external project
190 # gb_ExternalPackage_use_unpacked package unpacked
191 define gb_ExternalPackage_use_unpacked
192 $(call gb_Package_use_unpacked
,$(1),$(2))
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 $(if
$(gb_ExternalPackage_PROJECT_
$(1)),$(call gb_Output_error
,gb_ExternalPackage_use_external_project
: only one project allowed
))
203 gb_ExternalPackage_PROJECT_
$(1) := $(2)
207 # vim: set noet sw=4 ts=4: