]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: extract script to build executable
authorPatrick Steinhardt <ps@pks.im>
Wed, 19 Feb 2025 12:34:30 +0000 (13:34 +0100)
committerPatrick Steinhardt <ps@pks.im>
Thu, 20 Feb 2025 07:52:07 +0000 (08:52 +0100)
Extract the scrip that "builds" Gitk from our Makefile so that we can
reuse it in Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Makefile
generate-tcl.sh [new file with mode: 0755]

index e1f0aff4a191d305be6a69c8befe1c2975c1debe..3a3c56c318bad6e30e5f4a14b9fb8fefb621ed96 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,7 @@ gitk_libdir   ?= $(sharedir)/gitk/lib
 msgsdir    ?= $(gitk_libdir)/msgs
 msgsdir_SQ  = $(subst ','\'',$(msgsdir))
 
+SHELL_PATH ?= /bin/sh
 TCL_PATH ?= tclsh
 TCLTK_PATH ?= wish
 INSTALL ?= install
@@ -64,9 +65,7 @@ clean::
 
 gitk-wish: gitk GIT-TCLTK-VARS
        $(QUIET_GEN)$(RM) $@ $@+ && \
-       sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \
-       chmod +x $@+ && \
-       mv -f $@+ $@
+       $(SHELL_PATH) ./generate-tcl.sh "$(TCLTK_PATH_SQ)" "$<" "$@"
 
 $(PO_TEMPLATE): gitk
        $(XGETTEXT) -kmc -LTcl -o $@ gitk
diff --git a/generate-tcl.sh b/generate-tcl.sh
new file mode 100755 (executable)
index 0000000..46bba6d
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+WISH=$(echo "$1" | sed 's/|/\\|/g')
+INPUT="$2"
+OUTPUT="$3"
+
+sed -e "1,3s|^exec .* \"\$0\"|exec $WISH \"\$0\"|" "$INPUT" >"$OUTPUT"+
+chmod a+x "$OUTPUT"+
+mv "$OUTPUT"+ "$OUTPUT"