Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / ExternalPackage.mk
blob670106bd95bdad2905b092c55a11de0641a04b82
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 # Create and register a new ExternalPackage
41 # The base directory of the package is the directory of the unpacked
42 # tarball.
44 # gb_ExternalPackage_ExternalPackage name unpacked
45 define gb_ExternalPackage_ExternalPackage
46 $(call gb_ExternalPackage_ExternalPackage_internal,$(1),$(2))
48 $$(eval $$(call gb_Module_register_target,$(call gb_ExternalPackage_get_target,$(1)),$(call gb_ExternalPackage_get_clean_target,$(1))))
49 $(call gb_Helper_make_userfriendly_targets,$(1),ExternalPackage)
51 endef
53 # Create a new ExternalPackage
55 # This function should only be used in implementations of other gbuild
56 # classes.
58 # gb_ExternalPackage_ExternalPackage_internal name unpacked
59 define gb_ExternalPackage_ExternalPackage_internal
60 $(call gb_Package_Package_internal,$(1),$(call gb_UnpackedTarball_get_dir,$(2)))
61 $(call gb_Package_use_unpacked,$(1),$(2))
63 $(call gb_ExternalPackage_get_target,$(1)) : $(call gb_Package_get_target,$(1))
64 $(call gb_ExternalPackage_get_target,$(1)) :| $(dir $(call gb_ExternalPackage_get_target,$(1))).dir
65 $(call gb_ExternalPackage_get_clean_target,$(1)) : $(call gb_Package_get_clean_target,$(1))
67 gb_ExternalPackage_UNPACKED_$(1) := $(2)
69 endef
71 # Set output dir for the package's files.
73 # Default is $(INSTROOT).
75 # gb_ExternalPackage_set_outdir package outdir
76 define gb_ExternalPackage_set_outdir
77 $(call gb_Package_set_outdir,$(1),$(2))
79 endef
81 # Mark a source file to be used outside of this module
83 # This results in the timestamp of the file being updated, so a possible
84 # change is recognized properly by other files depending on it.
86 # gb_ExternalPackage_mark_generated_file package file
87 define gb_ExternalPackage_mark_generated_file
88 $(call gb_UnpackedTarball_get_dir,$(gb_ExternalPackage_UNPACKED_$(1)))/$(2) : \
89 $(call gb_ExternalProject_get_target,$(gb_ExternalPackage_PROJECT_$(1)))
90 $(if $(suffix $(2)),\
91 $(call gb_UnpackedTarbal__ensure_pattern_rule,$(gb_ExternalPackage_UNPACKED_$(1)),$(suffix $(2))),\
92 $(call gb_UnpackedTarbal__make_file_rule,$(gb_ExternalPackage_UNPACKED_$(1)),$(2)) \
95 endef
97 # Mark several source files to be used outside of this module
99 # gb_ExternalProject_mark_generated_files package file(s)
100 define gb_ExternalPackage_mark_generated_files
101 $(foreach file,$(2),$(call gb_ExternalPackage_mark_generated_file,$(1),$(file)))
103 endef
105 define gb_ExternalPackage_add_symbolic_link
106 $(call gb_Package_add_symbolic_link,$(1),$(2),$(3))
108 endef
110 # Add a file
112 # See gb_Package_add_file for details.
114 # gb_ExternalPackage_add_file package dest src
115 define gb_ExternalPackage_add_file
116 $(if $(4),$(call gb_Output_error,gb_ExternalPackage_add_file: $(1) 4: $(4)))
117 $(call gb_ExternalPackage_mark_generated_file,$(1),$(3))
118 $(call gb_Package_add_file,$(1),$(2),$(3))
120 endef
122 # Add several files at once
124 # See gb_Package_add_files for details.
126 # gb_ExternalPackage_add_files package destdir file(s)
127 define gb_ExternalPackage_add_files
128 $(call gb_ExternalPackage_mark_generated_files,$(1),$(3))
129 $(call gb_Package_add_files,$(1),$(2),$(3))
131 endef
133 # Add several files at once
135 # See gb_Package_add_files_with_dir for details.
137 # gb_ExternalPackage_add_files_with_dir package destdir file(s)
138 define gb_ExternalPackage_add_files_with_dir
139 $(call gb_ExternalPackage_mark_generated_files,$(1),$(3))
140 $(call gb_Package_add_files_with_dir,$(1),$(2),$(3))
142 endef
144 define gb_ExternalPackage__add_file
145 $(call gb_UnpackedTarball_mark_output_file,$(gb_ExternalPackage_UNPACKED_$(1)),$(2))
147 endef
149 # Add an unpacked file
151 # See gb_Package_add_file for details.
153 # gb_ExternalPackage_add_unpacked_file package dest src
154 define gb_ExternalPackage_add_unpacked_file
155 $(call gb_Package_add_file,$(1),$(2),$(3))
156 $(call gb_ExternalPackage__add_file,$(1),$(3))
158 endef
160 define gb_ExternalPackage__add_files
161 $(foreach file,$(2),$(call gb_ExternalPackage__add_file,$(1),$(file)))
163 endef
165 # Add several unpacked files at once
167 # See gb_Package_add_files for details.
169 # gb_ExternalPackage_add_unpacked_files package destdir file(s)
170 define gb_ExternalPackage_add_unpacked_files
171 $(call gb_Package_add_files,$(1),$(2),$(3))
172 $(call gb_ExternalPackage__add_files,$(1),$(3))
174 endef
176 # Add several unpacked files at once
178 # See gb_Package_add_files_with_dir for details.
180 # gb_ExternalPackage_add_unpacked_files_with_dir package destdir file(s)
181 define gb_ExternalPackage_add_unpacked_files_with_dir
182 $(call gb_Package_add_files_with_dir,$(1),$(2),$(3))
183 $(call gb_ExternalPackage__add_files,$(1),$(3))
185 endef
187 # Package files from unpacked tarball of an external project
189 # gb_ExternalPackage_use_unpacked package unpacked
190 define gb_ExternalPackage_use_unpacked
191 $(call gb_Package_use_unpacked,$(1),$(2))
193 endef
195 # Package files from build of an external project
197 # gb_ExternalPackage_use_external_project package external
198 define gb_ExternalPackage_use_external_project
199 $(call gb_Package_use_external_project,$(1),$(2))
201 $(if $(gb_ExternalPackage_PROJECT_$(1)),$(call gb_Output_error,gb_ExternalPackage_use_external_project: only one project allowed))
202 gb_ExternalPackage_PROJECT_$(1) := $(2)
204 endef
206 # vim: set noet sw=4 ts=4: