# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- # # This file is part of the LibreOffice project. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. #
# UnpackedTarget class
# Handles unpacking of a tarball
# platform # gb_UnpackedTarget_TARFILE_LOCATION # NOTE: only for commands; targets should use TARFILE_LOCATION directly
# Location of internal copies of config.{guess,sub}.
gb_UnpackedTarball_CONFIGDIR := $(GBUILDDIR)
# Handles unpacking and patching of an external project # # The unpacked dir is recreated every time one of the patches, copied # files or the makefile changes.
# Convert line ending from dos to unix style for selected files # # This is done before applying patches, because patches expect unix # style line ending, and the files are converted back after that. The # files are relative to the unpacked path. # # gb_UnpackedTarball_fix_end_of_line unpacked file(s) define gb_UnpackedTarball_fix_end_of_line
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_FIX_EOL += $(addprefix $(gb_UnpackedTarball_workdir)/$(1)/,$(2))
endef
# Internal version of set_tarball, mostly to avoid repeated invocation of $(shell define gb_UnpackedTarball_set_tarball_internal
$(call gb_UnpackedTarget_UnpackedTarget,$(2),$(gb_UnpackedTarball_workdir)/$(1),$(3),$(4))
$(call gb_UnpackedTarball_get_target,$(1)) : $(call gb_UnpackedTarget_get_target,$(2))
$(call gb_UnpackedTarball_get_clean_target,$(1)) : $(call gb_UnpackedTarget_get_clean_target,$(2))
$(call gb_UnpackedTarget_get_target,$(2)) : $(call gb_UnpackedTarball_get_preparation_target,$(1))
$(if $(findstring in,$(5)),
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_IS_BIN_TARBALL := YES
$(call gb_ExternalProject_get_state_target,$(1),%) : UNPACKED_IS_BIN_TARBALL := YES)
$(if $(findstring out,$(5)),$(call gb_Module_get_target,$(4)) : $(TARFILE_LOCATION)/$(6)
$(TARFILE_LOCATION)/$(6) : $(call gb_Module_get_nonl10n_target,$(4))
$$(call gb_Output_announce,$(6),$(true),PKB,3)
$$(call gb_Trace_StartRange,$(6),PKB) if test ! -f "$$@" ; then cd $(gb_UnpackedTarball_workdir)/ && $(GNUTAR) -czf "$$@" $(1)/ || $(GNUTAR) -czf "$$@" $(1)/ ; else touch "$$@" ; fi
$$(call gb_Trace_EndRange,$(6),PKB)
)
# Set patch level to be used for all patches # # gb_UnpackedTarball_set_patchlevel unpacked level define gb_UnpackedTarball_set_patchlevel
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_PATCHLEVEL := $(2)
endef
# Add patch flags to be passed to patch for all patches cf. fdo#66826 # # gb_UnpackedTarball_set_patchlevel unpacked level define gb_UnpackedTarball_set_patchflags
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_PATCHFLAGS := $(2)
endef
# Add a patch to be applied on the unpacked files # # gb_UnpackedTarball_add_patch unpacked patch define gb_UnpackedTarball_add_patch
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_PATCHES += $(SRCDIR)/$(2)
$(call gb_UnpackedTarball_get_preparation_target,$(1)) : $(SRCDIR)/$(2)
endef
# Add several patches at once # # gb_UnpackedTarball_add_patches unpacked patch(es) define gb_UnpackedTarball_add_patches
$(foreach patch,$(2),$(call gb_UnpackedTarball_add_patch,$(1),$(patch)))
endef
# Add a file from source dir to the unpacked dir # # This function should not be used for overwriting existing files--use a # patch for that purpose. # # gb_UnpackedTarball_add_file unpacked destfile file define gb_UnpackedTarball_add_file
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_FILES += $(SRCDIR)/$(3)
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_DESTFILES += $(gb_UnpackedTarball_workdir)/$(1)/$(2)
$(call gb_UnpackedTarball_get_preparation_target,$(1)) : $(SRCDIR)/$(3)
endef
# Add several files(s) from source dir to the unpacked dir # # The files are added into the specified subdir. # # gb_UnpackedTarball_add_files unpacked subdir file(s) define gb_UnpackedTarball_add_files
$(foreach file,$(3),$(call gb_UnpackedTarball_add_file,$(1),$(2)/$(notdir $(file)),$(file)))
endef
# Set arbitrary shell command to be run during unpack # # The command is run at the very beginning, in freshly unpacked tarball. # The command is run in the unpacked directory. If more than one command # is used, care should be taken that the whole command fails if either # of the sub-commands fails. # # gb_UnpackedTarball_set_pre_action unpacked shell-command define gb_UnpackedTarball_set_pre_action
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_PRE_ACTION := $(strip $(2))
endef
# Set arbitrary shell command to be run during unpack # # The command is run at the very end: after patching, C++ extension # mangling and copying additional files in. The command is run in the # unpacked directory. If more than one command is used, care should be # taken that the whole command fails if either of the sub-commands # fails. # # NOTE: This is a bit hackish, but it is the easiest way to move files # around or delete files (typically because the file causes build # problems in the original location, c.f. clucene). This is doable by # using -E with patch (we use GNU patch anyway), but it would mean an # additional patch to maintain... # # gb_UnpackedTarball_set_post_action unpacked shell-command define gb_UnpackedTarball_set_post_action
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_POST_ACTION := $(strip $(2))
endef
define gb_UnpackedTarbal__make_pattern_rule
$(gb_UnpackedTarball_workdir)/$(1)/%$(2) :
$$(if $$(wildcard $$@),,$$(call gb_Output_error,file $$@ does not exist in the tarball))
$$(if $$(UNPACKED_MODE),chmod $$(UNPACKED_MODE) $$@ &&) \
touch $$@
define gb_UnpackedTarbal__make_file_rule
$(gb_UnpackedTarball_workdir)/$(1)/$(2) :
$$(if $$(wildcard $$@),,$$(call gb_Output_error,file $$@ does not exist in the tarball))
$$(if $$(UNPACKED_MODE),chmod $$(UNPACKED_MODE) $$@ &&) \
touch $$@
endef
# Mark a source file to be used outside of this module # # This results in the timestamp of the file being updated, so a possible # change is recognized properly by other files depending on it. The # update is run after possible post action. # # See description of class ExternalPackage for more information. # # gb_UnpackedTarball_mark_output_file unpacked file define gb_UnpackedTarball_mark_output_file
$(call gb_UnpackedTarball_get_final_target,$(1)) : $(gb_UnpackedTarball_workdir)/$(1)/$(2)
$(gb_UnpackedTarball_workdir)/$(1)/$(2) : $(call gb_UnpackedTarball_get_target,$(1))
$(gb_UnpackedTarball_workdir)/$(1)/$(2) : UNPACKED_MODE := 644
$(if $(suffix $(2)),\
$(call gb_UnpackedTarbal__ensure_pattern_rule,$(1),$(suffix $(2))),\
$(call gb_UnpackedTarbal__make_file_rule,$(1),$(2)) \
)
endef
# Mark several source files to be used outside of this module # # gb_UnpackedTarball_mark_output_files unpacked file(s) define gb_UnpackedTarball_mark_output_files
$(foreach file,$(2),$(call gb_UnpackedTarball_mark_output_file,$(1),$(file)))
endef
# Replace project's config.{guess,sub} files by internal copies # # This is useful if the project's config files are outdated and don't # allow build on some new arch. The internal copies are located at # gb_UnpackedTarball_CONFIGDIR. # # If the configs are placed somewhere else than in the top-level dir of # the project, pass the (relative) dir as second argument. (It can even # be a list of dirs, if the project contains multiple subprojects, each # with its own configure.) # # gb_UnpackedTarball_update_autoconf_configs unpacked dirs(s)? define gb_UnpackedTarball_update_autoconf_configs
$(call gb_UnpackedTarball_get_target,$(1)) : UNPACKED_CONFIG_DIRS += $(if $(strip $(2)),$(2),.)
endef
# force the rebuild of an external target # this only works when running as partial build. #
%.rebuild : if [ -f $(call gb_UnpackedTarball_get_target,$*) ] ; then \
touch $(call gb_UnpackedTarball_get_target,$*) ; \
$(MAKE) ;\ fi
%.genpatch : if [ -d $(gb_UnpackedTarball_workdir)/$* -a -d $(call gb_UnpackedTarball_get_pristine_dir,$*) ] ; then \
( \
patch_file=$$(pwd)/$*.new.patch.1; \
cd $(gb_UnpackedTarball_workdir)/ ; \
diff -ur $*.org $* > $$patch_file; \ echo"Patch $$patch_file generated" ; \
); \ else \ echo"Error: No pristine tarball available for $*" 1>&2 ; \ fi
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.