Bump version to 6.4.7.2.M8
[LibreOffice.git] / solenv / gbuild / GeneratedPackage.mk
blob527c3b5bfb9138871b1ebe9e369193ac95aa7826
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 $(if $(PACKAGE_DIRS),,$(call gb_Output_error,no dirs were added))
39 $(call gb_Helper_abbreviate_dirs,\
40 rm -rf $(foreach pair,$(PACKAGE_DIRS),$(call gb_GeneratedPackage__get_destdir,$(pair))) \
41 && mkdir -p $(foreach pair,$(PACKAGE_DIRS),$(dir $(call gb_GeneratedPackage__get_destdir,$(pair)))) \
42 $(foreach pair,$(PACKAGE_DIRS),&& cp -R $(PACKAGE_SOURCEDIR)/$(call gb_GeneratedPackage__get_srcdir,$(pair)) $(call gb_GeneratedPackage__get_destdir,$(pair))) \
44 $(call gb_Helper_abbreviate_dirs,\
45 $(FIND) $(foreach pair,$(PACKAGE_DIRS),$(call gb_GeneratedPackage__get_destdir,$(pair))) \( -type f -o -type l \) -print | LC_ALL=C $(SORT) > $@ \
48 .PHONY : $(call gb_GeneratedPackage_get_clean_target,%)
49 $(call gb_GeneratedPackage_get_clean_target,%) :
50 $(call gb_Output_announce,$*,$(false),GPK,2)
51 rm -rf $(call gb_GeneratedPackage_get_target,$*) $(PACKAGE_DIRS)
53 # Create a generated package.
55 # gb_GeneratedPackage_GeneratedPackage package srcdir
56 define gb_GeneratedPackage_GeneratedPackage
57 $(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_DIRS :=
58 $(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_SOURCEDIR := $(2)
59 $(call gb_GeneratedPackage_get_clean_target,$(1)) : PACKAGE_DIRS :=
61 $(call gb_GeneratedPackage_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
62 $(call gb_GeneratedPackage_get_target,$(1)) :| $(dir $(call gb_GeneratedPackage_get_target,$(1))).dir
64 $$(eval $$(call gb_Module_register_target,GeneratedPackage_$(1),$(call gb_GeneratedPackage_get_target,$(1)),$(call gb_GeneratedPackage_get_clean_target,$(1))))
65 $(call gb_Helper_make_userfriendly_targets,$(1),GeneratedPackage)
67 endef
69 # Depend on a custom target.
71 # gb_GeneratedPackage_use_customtarget package custom-target
72 define gb_GeneratedPackage_use_customtarget
73 $(call gb_GeneratedPackage_get_target,$(1)) : $(call gb_CustomTarget_get_target,$(2))
75 endef
77 # Depend on an unpacked tarball.
79 # gb_GeneratedPackage_use_unpacked package unpacked
80 define gb_GeneratedPackage_use_unpacked
81 $(call gb_GeneratedPackage_get_target,$(1)) : $(call gb_UnpackedTarball_get_target,$(2))
83 endef
85 # Depend on an external project.
87 # gb_GeneratedPackage_use_external_project package project
88 define gb_GeneratedPackage_use_external_project
89 $(call gb_GeneratedPackage_get_target,$(1)) : $(call gb_ExternalProject_get_target,$(2))
91 endef
93 # Add a dir to the package.
95 # The srcdir will be copied to instdir as destdir.
97 # gb_GeneratedPackage_add_dir package destdir srcdir
98 define gb_GeneratedPackage_add_dir
99 $(call gb_GeneratedPackage_get_target,$(1)) : PACKAGE_DIRS += $(strip $(2))<>$(strip $(3))
100 $(call gb_GeneratedPackage_get_clean_target,$(1)) : PACKAGE_DIRS += $(2)
102 endef
104 # vim: set noet sw=4 ts=4: