poppler: Upgrade 24.05.0
[LibreOffice.git] / solenv / gbuild / GeneratedPackage.mk
blob92f17643698992a0a86921e49b7f47aeacb5ad7d
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 # class GeneratedPackage
12 # Enables to deliver whole directories (of generated files) to instdir.
14 # GeneratedPackage shall be used as a substitution for Package when the
15 # names of the produced files are not known in advance (in older times,
16 # we used Zip in these places). It shall only be used to deliver files
17 # for installation.
19 # If you know the filenames in advance, use Package. Laziness is not an
20 # excuse.
22 gb_GeneratedPackage__get_srcdir = $(lastword $(subst <>, ,$(1)))
23 gb_GeneratedPackage__get_destdir = $(firstword $(subst <>, ,$(1)))
25 $(dir $(call gb_GeneratedPackage_get_target,%)).dir :
26 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
28 $(dir $(call gb_GeneratedPackage_get_target,%))%.dir :
29 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
31 # require all added directories to exist
32 $(call gb_GeneratedPackage_get_target,%) :| $(foreach pair,$(PACKAGE_DIRS),$(PACKAGE_SOURCEDIR)/$(call gb_GeneratedPackage__get_srcdir,$(pair)))
34 # split in two commands to avoid running into commandline/environment size limits
35 # on windows with all languages the processing of help can truncate the find command otherwise
36 $(call gb_GeneratedPackage_get_target,%) :
37 $(call gb_Output_announce,$*,$(true),GPK,2)
38 $(call gb_Trace_StartRange,$*,GPK)
39 $(if $(PACKAGE_DIRS),,$(call gb_Output_error,no dirs were added))
40 $(call gb_Helper_abbreviate_dirs,\
41 rm -rf $(foreach pair,$(PACKAGE_DIRS),$(call gb_GeneratedPackage__get_destdir,$(pair))) \
42 && mkdir -p $(foreach pair,$(PACKAGE_DIRS),$(dir $(call gb_GeneratedPackage__get_destdir,$(pair)))) \
43 $(foreach pair,$(PACKAGE_DIRS),&& cp -R $(PACKAGE_SOURCEDIR)/$(call gb_GeneratedPackage__get_srcdir,$(pair)) $(call gb_GeneratedPackage__get_destdir,$(pair))) \
45 $(call gb_Helper_abbreviate_dirs,\
46 $(FIND) $(foreach pair,$(PACKAGE_DIRS),$(call gb_GeneratedPackage__get_destdir,$(pair))) \( -type f -o -type l \) -print | LC_ALL=C $(SORT) > $@ \
48 $(call gb_Trace_EndRange,$*,GPK)
50 .PHONY : $(call gb_GeneratedPackage_get_clean_target,%)
51 $(call gb_GeneratedPackage_get_clean_target,%) :
52 $(call gb_Output_announce,$*,$(false),GPK,2)
53 rm -rf $(call gb_GeneratedPackage_get_target,$*) $(PACKAGE_DIRS)
55 # Create a generated package.
57 # gb_GeneratedPackage_GeneratedPackage package srcdir
58 define gb_GeneratedPackage_GeneratedPackage
59 $(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_DIRS :=
60 $(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_SOURCEDIR := $(2)
61 $(call gb_GeneratedPackage_get_clean_target,$(1)) : PACKAGE_DIRS :=
63 $(call gb_GeneratedPackage_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
64 $(call gb_GeneratedPackage_get_target,$(1)) :| $(dir $(call gb_GeneratedPackage_get_target,$(1))).dir
66 $$(eval $$(call gb_Module_register_target,$(call gb_GeneratedPackage_get_target,$(1)),$(call gb_GeneratedPackage_get_clean_target,$(1))))
67 $(call gb_Helper_make_userfriendly_targets,$(1),GeneratedPackage)
69 endef
71 # Depend on a custom target.
73 # gb_GeneratedPackage_use_customtarget package custom-target
74 define gb_GeneratedPackage_use_customtarget
75 $(call gb_GeneratedPackage_get_target,$(1)) : $(call gb_CustomTarget_get_target,$(2))
77 endef
79 # Depend on an unpacked tarball.
81 # gb_GeneratedPackage_use_unpacked package unpacked
82 define gb_GeneratedPackage_use_unpacked
83 $(call gb_GeneratedPackage_get_target,$(1)) : $(call gb_UnpackedTarball_get_target,$(2))
85 endef
87 # Depend on an external project.
89 # gb_GeneratedPackage_use_external_project package project
90 define gb_GeneratedPackage_use_external_project
91 $(call gb_GeneratedPackage_get_target,$(1)) : $(call gb_ExternalProject_get_target,$(2))
93 endef
95 # Add a dir to the package.
97 # The srcdir will be copied to instdir as destdir.
99 # gb_GeneratedPackage_add_dir package destdir srcdir
100 define gb_GeneratedPackage_add_dir
101 $(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_DIRS += $(strip $(2))<>$(strip $(3))
102 $(call gb_GeneratedPackage_get_clean_target,$(1)) : PACKAGE_DIRS += $(2)
104 endef
106 # vim: set noet sw=4 ts=4: