Whamcloud - gitweb
ChangeLog, MCONFIG.in, configure.in, configure:
[tools/e2fsprogs.git] / lib / ss / mk_cmds.sh.in
1 #!/bin/sh
2 #
3 #
4
5 DIR="${DIR-@datadir@/ss}"
6 SS_DIR=@SS_DIR@
7 AWK=@AWK@
8 SED=@SED@
9
10 if test "x$1" = x ; then
11     echo "Usage: mk_cmds file"
12     exit 1
13 fi
14
15 if test ! -f $DIR/ct_c.sed -o ! -f $DIR/ct_c.awk ; then
16     DIR=$SS_DIR
17 #    echo "Falling back to $DIR..."
18     if test ! -f $DIR/ct_c.sed -o ! -f $DIR/ct_c.awk ; then
19         echo "mk_cmds: Couldn't find mk_cmds's template files."
20         exit 1
21     fi
22 fi
23
24 FILE=$1
25 ROOT=`echo $1 | sed -e s/.ct$//`
26 BASE=`basename $ROOT`
27 TMP=ct$$.c
28
29 if test ! -f $FILE ; then
30     echo "$FILE: File not found"
31     exit 1;
32 fi
33
34 ${SED} -f ${DIR}/ct_c.sed  ${FILE} \
35         | ${AWK} -f ${DIR}/ct_c.awk rootname=${ROOT} outfile=${TMP} -
36
37 if grep "^#__ERROR_IN_FILE" ${TMP} > /dev/null; then
38         rm ${TMP}
39         exit 1
40 else
41         rm -f ${BASE}.c
42         mv ${TMP} ${BASE}.c
43         exit 0
44 fi