compile_et.sh.in revision b6b65c3de480c8e17c2bf9ab12196c7dde325380
1#!/bin/sh
2#
3#
4
5datarootdir=@datarootdir@
6AWK=@AWK@
7DIR="${DIR-@datadir@/et}"
8ET_DIR="@ET_DIR@"
9
10if test "$1" = "--build-tree" ; then
11    shift;
12    DIR="$ET_DIR"
13fi
14
15if test "x$1" = x ; then
16    echo "Usage: compile_et file"
17    exit 1
18fi
19
20if test ! -f "$DIR/et_h.awk" || test ! -f "$DIR/et_c.awk" ; then
21    DIR="$ET_DIR"
22#    echo "Falling back to $DIR..."
23    if test ! -f "$DIR/et_h.awk" || test ! -f "$DIR/et_c.awk" ; then
24	echo "compile_et: Couldn't find compile_et's template files."
25	exit 1
26    fi
27fi
28
29ROOT=`echo $1 | sed -e s/.et$//`
30BASE=`basename $ROOT`
31
32if test ! -f "$ROOT.et" ; then
33    echo "compile_et: $ROOT.et: File not found"
34    exit 1;
35fi
36
37$AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h.$$" "outfn=${BASE}.h" "$ROOT.et"
38if test -f ${BASE}.h && cmp -s ${BASE}.h.$$ ${BASE}.h ; then
39    rm -f ${BASE}.h.$$
40else
41    mv -f ${BASE}.h.$$ ${BASE}.h
42    chmod -w ${BASE}.h
43fi
44$AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c.$$" "outfn=${BASE}.c" "$ROOT.et"
45if test -f ${BASE}.c && cmp -s ${BASE}.c.$$ ${BASE}.c ; then
46    rm -f ${BASE}.c.$$
47else
48    mv -f ${BASE}.c.$$ ${BASE}.c
49    chmod -w ${BASE}.c
50fi
51