homepage/install

81 lines
1012 B
Plaintext
Raw Normal View History

2015-03-20 18:32:15 -06:00
#! /bin/sh
DESTDIR=${1:-/home/neale/public_html}
cd $(dirname $0)
older () {
tgt=$1
[ -f "$tgt" ] || exit 0
for src in "$@"; do
[ "$src" -nt "$tgt" ] && return 0
done
return 1
}
2015-03-20 18:32:15 -06:00
html () {
target=$DESTDIR/${1%mdwn}html
if older $target $1 tmpl/*; then
echo "HTML $1"
mkdir -p $(dirname $target)
./tmpl/mdwntohtml < $1 > $target
fi
}
copy () {
target=$DESTDIR/$1
if older $target $1; then
echo "COPY $1"
mkdir -p $(dirname $target)
cp $1 $target
fi
}
cc () {
target=$DESTDIR/${1%.c}
if older $target $1; then
echo "CC $1"
gcc -o $target $1
fi
}
gc () {
2015-10-29 08:43:15 -06:00
target=$DESTDIR/${1%.go}
2015-03-20 18:32:15 -06:00
if older $target $1; then
echo "GO $1"
go build -o $target $1
fi
}
install () {
fd=$(dirname $fn)
echo "SUBINSTALL $fd"
(cd $fd && ./install $DESTDIR/$fd)
}
git ls-files | while read fn; do
case "$fn" in
.*|*/.*|*~|install)
;;
*/install)
install $fn
;;
*.mdwn)
html $fn
;;
*.cgi.c)
cc $fn
;;
*.cgi.go)
gc $fn
;;
*)
copy $fn
;;
esac
done