-prefix = $(HOME)
-bindir = $(prefix)/bin
-cmddir = $(prefix)/libexec/topgit
-sharedir = $(prefix)/share/topgit
-hooksdir = $(cmddir)/hooks
+prefix ?= $(HOME)
+bindir := $(prefix)/bin
+cmddir := $(prefix)/libexec/topgit
+sharedir := $(prefix)/share/topgit
+hooksdir := $(cmddir)/hooks
-commands_in = tg-create.sh tg-delete.sh tg-export.sh tg-info.sh tg-patch.sh tg-summary.sh tg-update.sh
+commands_in := $(wildcard tg-*.sh)
hooks_in = hooks/pre-commit.sh
-commands_out = $(patsubst %.sh,%,$(commands_in))
-hooks_out = $(patsubst %.sh,%,$(hooks_in))
-help_out = $(patsubst %.sh,%.txt,$(commands_in))
+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) $(help_out)
-tg $(commands_out) $(hooks_out): % : %.sh
+tg $(commands_out) $(hooks_out): % : %.sh Makefile
@echo "[SED] $@"
@sed -e 's#@cmddir@#$(cmddir)#g;' \
-e 's#@hooksdir@#$(hooksdir)#g' \