gitk: extract script to build executable

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>

Patrick Steinhardt committed Feb 19, 2025 at 13:34 UTC 0d4fe3047f98eaab927964d84ec114bfd504ab0f
2 files changed +13 -3
Makefile
+2 -3
@@ -8,6 +8,7 @@ gitk_libdir ?= $(sharedir)/gitk/lib
8 msgsdir ?= $(gitk_libdir)/msgs
9 msgsdir_SQ = $(subst ','\'',$(msgsdir))
10
11 +SHELL_PATH ?= /bin/sh
12 TCL_PATH ?= tclsh
13 TCLTK_PATH ?= wish
14 INSTALL ?= install
@@ -64,9 +65,7 @@ clean::
65
66 gitk-wish: gitk GIT-TCLTK-VARS
67 $(QUIET_GEN)$(RM) $@ $@+ && \
67 - sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \
68 - chmod +x $@+ && \
69 - mv -f $@+ $@
68 + $(SHELL_PATH) ./generate-tcl.sh "$(TCLTK_PATH_SQ)" "$<" "$@"
69
70 $(PO_TEMPLATE): gitk
71 $(XGETTEXT) -kmc -LTcl -o $@ gitk
generate-tcl.sh new
+11
@@ -0,0 +1,11 @@
1 +#!/bin/sh
2 +
3 +set -e
4 +
5 +WISH=$(echo "$1" | sed 's/|/\\|/g')
6 +INPUT="$2"
7 +OUTPUT="$3"
8 +
9 +sed -e "1,3s|^exec .* \"\$0\"|exec $WISH \"\$0\"|" "$INPUT" >"$OUTPUT"+
10 +chmod a+x "$OUTPUT"+
11 +mv "$OUTPUT"+ "$OUTPUT"