From: Patrick Steinhardt Date: Wed, 09 Oct 2024 14:56:45 GMT Subject: [RFC PATCH v2 13/24] Makefile: extract script to massage Perl scripts Message-ID: <7f567d7ce237460e37b8eae29d14c453f95f3e94.1728485139.git.ps@pks.im> In-Reply-To: Extract the script to inject various build-time parameters into our Perl scripts into a standalone script. This is done such that we can reuse it in other build systems. Signed-off-by: Patrick Steinhardt --- Makefile | 10 +--------- generate-perl.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) create mode 100755 generate-perl.sh diff --git a/Makefile b/Makefile index 0d542c58f3a..50fbc4f29d0 100644 --- a/Makefile +++ b/Makefile @@ -2605,15 +2605,7 @@ endif PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir) $(SCRIPT_PERL_GEN): % : %.perl GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE - $(QUIET_GEN) \ - sed -e '1{' \ - -e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \ - -e ' r GIT-PERL-HEADER' \ - -e ' G' \ - -e '}' \ - -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ - $< >$@+ && \ - chmod +x $@+ && \ + $(QUIET_GEN)$(SHELL_PATH) generate-perl.sh $(GIT_VERSION) GIT-PERL-HEADER "$(PERL_PATH_SQ)" "$<" "$@+" && \ mv $@+ $@ PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES)) diff --git a/generate-perl.sh b/generate-perl.sh new file mode 100755 index 00000000000..b9e04d6f42a --- /dev/null +++ b/generate-perl.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +if test $# -ne 5 +then + echo "USAGE: $0 " >&2 + exit 1 +fi + +GIT_VERSION="$1" +PERL_HEADER="$2" +PERL_PATH="$3" +PERL_SCRIPT="$4" +OUT="$5" + +sed -e '1{' \ + -e " s|#!.*perl|#!$PERL_PATH|" \ + -e " r $PERL_HEADER" \ + -e ' G' \ + -e '}' \ + -e "s/@@GIT_VERSION@@/$GIT_VERSION/g" \ + "$PERL_SCRIPT" >"$OUT" +chmod a+x "$OUT" -- 2.47.0.rc1.33.g90fe3800b9.dirty