Whamcloud - gitweb
Make compile_et and mk_cmds safe from directory pathnames that
[tools/e2fsprogs.git] / lib / et / compile_et.sh.in
1 #!/bin/sh
2 #
3 #
4 AWK=@AWK@
5 DIR="${DIR-@datadir@/et}"
6 ET_DIR="@ET_DIR@"
7
8 if test "x$1" = x ; then
9     echo "Usage: compile_et file"
10     exit 1
11 fi
12
13 if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then
14     DIR="$ET_DIR"
15 #    echo "Falling back to $DIR..."
16     if test ! -f "$DIR/et_h.awk" -o ! -f "$DIR/et_c.awk" ; then
17         echo "compile_et: Couldn't find compile_et's template files."
18         exit 1
19     fi
20 fi
21
22 ROOT=`echo $1 | sed -e s/.et$//`
23 BASE=`basename $ROOT`
24
25 if test ! -f "$ROOT.et" ; then
26     echo "compile_et: $ROOT.et: File not found"
27     exit 1;
28 fi
29
30 $AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h" "$ROOT.et"
31 $AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c" "$ROOT.et"