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>
main
Patrick Steinhardt 2025-02-19 13:34:30 +01:00
parent e76b53ef23
commit 0d4fe3047f
2 changed files with 13 additions and 3 deletions

View File

@ -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

11
generate-tcl.sh Executable file
View File

@ -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"