PREFIX = $(HOME)
bindir = $(PREFIX)/bin
cmddir = $(PREFIX)/libexec/topgit
+sharedir = $(PREFIX)/share/topgit
hooksdir = $(cmddir)/hooks
commands_out = $(patsubst %.sh,%,$(commands_in))
hooks_out = $(patsubst %.sh,%,$(hooks_in))
+help_out = $(patsubst %.sh,%.txt,$(commands_in))
-all:: tg $(commands_out) $(hooks_out)
+all:: tg $(commands_out) $(hooks_out) $(help_out)
tg $(commands_out) $(hooks_out): % : %.sh
@echo "[SED] $@"
@sed -e 's#@cmddir@#$(cmddir)#g;' \
-e 's#@hooksdir@#$(hooksdir)#g' \
-e 's#@bindir@#$(bindir)#g' \
+ -e 's#@sharedir@#$(sharedir)#g' \
$@.sh >$@+ && \
chmod +x $@+ && \
mv $@+ $@
+$(help_out): README
+ ./create-help.sh `echo $@ | sed -e 's/tg-//' -e 's/\.txt//'`
install:: all
install tg "$(bindir)"
install $(commands_out) "$(cmddir)"
install -d -m 755 "$(hooksdir)"
install $(hooks_out) "$(hooksdir)"
+ install -d -m 755 "$(sharedir)"
+ install $(help_out) "$(sharedir)"
clean::
- rm -f tg $(commands_out) $(hooks_out)
+ rm -f tg $(commands_out) $(hooks_out) $(help_out)
--- /dev/null
+#!/bin/sh
+
+# Create the tg-foo.txt files which contain help for the tg-foo command.
+
+if [ $# -ne 1 ] ; then
+ echo "Usage: $0 tgcommand" 1>&2
+ exit 1
+fi
+
+< README awk '
+ BEGIN { incommand = 0; }
+ /^tg '"$1"'$/ { incommand = 1; next; }
+ /^tg/ { incommand = 0; next; }
+ /^~/ { next; } # Ignore the title underlines.
+ { if (incommand) { print $0; } }
+' > tg-"$1".txt
+
git symbolic-ref HEAD "$_base"
}
+# Show the help messages.
+do_help()
+{
+ if [ -z "$1" ] ; then
+ echo "TopGit v0.1 - A different patch queue manager"
+ echo "Usage: tg (create|delete|info|patch|summary|update|help) ..."
+ elif [ -f "@sharedir@/tg-$1.txt" ] ; then
+ cat "@sharedir@/tg-$1.txt"
+ else
+ echo "`basename $0`: no help for $1" 1>&2
+ fi
+}
+
## Initial setup
case "$cmd" in
help)
- echo "TopGit v0.1 - A different patch queue manager"
- echo "Usage: tg (create|delete|info|patch|summary|update|help) ..."
+ do_help "$1"
exit 1;;
create|delete|info|patch|summary|update)
. "@cmddir@"/tg-$cmd;;