|
| 1 | +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- |
| 2 | +# |
| 3 | +# This file is part of the LibreOffice project. |
| 4 | +# |
| 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/. |
| 8 | +# |
| 9 | + |
| 10 | +# AllLangZip class |
| 11 | + |
| 12 | +# Handles creation of a bunch of zip files with content dependent on |
| 13 | +# language |
| 14 | + |
| 15 | +gb_AllLangZip_LANGS := $(gb_WITH_LANG) |
| 16 | + |
| 17 | +$(dir $(call gb_AllLangZip_get_target,%)).dir : |
| 18 | + $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) |
| 19 | + |
| 20 | +$(call gb_AllLangZip_get_target,%) : |
| 21 | + $(call gb_Output_announce,$*,$(true),ALZ,4) |
| 22 | + touch $@ |
| 23 | + |
| 24 | +.PHONY : $(call gb_AllLangZip_get_clean_target,%) |
| 25 | +$(call gb_AllLangZip_get_clean_target,%) : |
| 26 | + $(call gb_Output_announce,$*,$(true),ALZ,4) |
| 27 | + rm -f $(call gb_AllLangZip_get_target,$*) |
| 28 | + |
| 29 | +# Define a new zip group |
| 30 | +# |
| 31 | +# NOTE: we cannot add dependencies on the child zips here: Zip fails if |
| 32 | +# the source directory does not exist and we cannot test its existence |
| 33 | +# because the directory might be generated. So we postpone the |
| 34 | +# dependency creation to gb_AllLangZip_add_file. |
| 35 | +# |
| 36 | +# gb_AllLangZip_AllLangZip group srcdir |
| 37 | +define gb_AllLangZip_AllLangZip |
| 38 | +$(foreach lang,$(gb_AllLangZip_LANGS),$(call gb_Zip_Zip_internal,$(1)_$(lang),$(2)/$(lang))) |
| 39 | + |
| 40 | +$(call gb_AllLangZip_get_target,$(1)) :| $(dir $(call gb_AllLangZip_get_target,$(1))).dir |
| 41 | + |
| 42 | +$$(eval $$(call gb_Module_register_target,$(call gb_AllLangZip_get_target,$(1)),$(call gb_AllLangZip_get_clean_target,$(1)))) |
| 43 | + |
| 44 | +endef |
| 45 | + |
| 46 | +define gb_AllLangZip__add_to_zip |
| 47 | +$(call gb_Zip_add_file,$(2),$(3)) |
| 48 | +$(call gb_AllLangZip_get_target,$(1)) : $(call gb_Zip_get_outdir_target,$(2)) |
| 49 | +$(call gb_AllLangZip_get_clean_target,$(1)) : $(call gb_Zip_get_clean_target,$(2)) |
| 50 | + |
| 51 | +endef |
| 52 | + |
| 53 | +define gb_AllLangZip__add_file_impl |
| 54 | +$(if $(filter $(2),$(gb_AllLangZip_LANGS)),$(call gb_AllLangZip__add_to_zip,$(1),$(1)_$(2),$(3))) |
| 55 | + |
| 56 | +endef |
| 57 | + |
| 58 | +define gb_AllLangZip__add_file |
| 59 | +$(call gb_AllLangZip__add_file_impl,$(1),$(firstword $(2)),$(subst $() $(),/,$(wordlist 2,$(words $(2)),$(2)))) |
| 60 | + |
| 61 | +endef |
| 62 | + |
| 63 | +# Add a file to one of the child zips |
| 64 | +# |
| 65 | +# The language is taken from the first component of the file name. The |
| 66 | +# file is only added if there is a zip defined for the language (i.e., |
| 67 | +# if we are building with the language). |
| 68 | +# |
| 69 | +# gb_AllLangZip_add_file target file |
| 70 | +define gb_AllLangZip_add_file |
| 71 | +$(call gb_AllLangZip__add_file,$(1),$(subst /, ,$(2))) |
| 72 | + |
| 73 | +endef |
| 74 | + |
| 75 | +# Add several files to the child zips at once |
| 76 | +# |
| 77 | +# gb_AllLangZip_add_files target file(s) |
| 78 | +define gb_AllLangZip_add_files |
| 79 | +$(foreach file,$(2),$(call gb_AllLangZip_add_file,$(1),$(file))) |
| 80 | + |
| 81 | +endef |
| 82 | + |
| 83 | +# Add extra dependency that must exist before the archives can be created |
| 84 | +# |
| 85 | +# gb_AllLangZip_add_dependency target dep |
| 86 | +define gb_AllLangZip_add_dependency |
| 87 | +$(foreach lang,$(gb_AllLangZip_LANGS),$(call gb_Zip_add_dependency,$(1)_$(lang),$(2))) |
| 88 | + |
| 89 | +endef |
| 90 | + |
| 91 | +# Add extra dependencies that must exist before the archives can be created |
| 92 | +# |
| 93 | +# gb_AllLangZip_add_dependencies target dep(s) |
| 94 | +define gb_AllLangZip_add_dependencies |
| 95 | +$(foreach dependency,$(2),$(call gb_AllLangZip_add_dependency,$(1),$(dependency))) |
| 96 | + |
| 97 | +endef |
| 98 | + |
| 99 | +# vim: set noet sw=4 ts=4: |
0 commit comments