blob: 572966cf4304db52781f1ed69cb4af3a89f953bc [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001#!/bin/sh
2#
3#
4
Theodore Ts'ob6b65c32006-10-22 00:14:26 -04005datarootdir=@datarootdir@
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +00006DIR="${DIR-@datadir@/ss}"
Theodore Ts'o7eb06692001-09-16 23:29:17 -04007SS_DIR="@SS_DIR@"
Theodore Ts'o3839e651997-04-26 13:21:57 +00008AWK=@AWK@
9SED=@SED@
10
Theodore Ts'o05155f92006-11-12 10:43:31 -050011for as_var in \
12 LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
13 LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
14 LC_TELEPHONE LC_TIME
15do
16 if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
17 eval $as_var=C; export $as_var
18 else
19 $as_unset $as_var
20 fi
21done
22
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +000023if test "x$1" = x ; then
24 echo "Usage: mk_cmds file"
25 exit 1
26fi
27
Theodore Ts'o1f00aaf2000-07-04 12:34:34 +000028if test -n "$_SS_DIR_OVERRIDE" ; then
Theodore Ts'o7eb06692001-09-16 23:29:17 -040029 DIR="$_SS_DIR_OVERRIDE";
Theodore Ts'o1f00aaf2000-07-04 12:34:34 +000030fi
31
Theodore Ts'o56eb4d42004-09-17 19:54:22 -040032if test ! -f $DIR/ct_c.sed || test ! -f $DIR/ct_c.awk ; then
Theodore Ts'o7eb06692001-09-16 23:29:17 -040033 DIR="$SS_DIR"
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +000034# echo "Falling back to $DIR..."
Theodore Ts'o56eb4d42004-09-17 19:54:22 -040035 if test ! -f "$DIR/ct_c.sed" || test ! -f "$DIR/ct_c.awk" ; then
Theodore Ts'o169cb541998-08-01 04:33:31 +000036 echo "mk_cmds: Couldn't find mk_cmds's template files."
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +000037 exit 1
38 fi
39fi
40
Theodore Ts'o7eb06692001-09-16 23:29:17 -040041FILE="$1"
Theodore Ts'o3839e651997-04-26 13:21:57 +000042ROOT=`echo $1 | sed -e s/.ct$//`
Theodore Ts'o7eb06692001-09-16 23:29:17 -040043BASE=`basename "$ROOT"`
44TMP="ct$$.c"
Theodore Ts'o3839e651997-04-26 13:21:57 +000045
Theodore Ts'o7eb06692001-09-16 23:29:17 -040046if test ! -f "$FILE" ; then
Theodore Ts'o4b4df792007-06-30 20:05:41 -040047 echo "mk_cmds: $FILE: File not found"
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +000048 exit 1;
49fi
50
Theodore Ts'o7eb06692001-09-16 23:29:17 -040051${SED} -f "${DIR}/ct_c.sed" "${FILE}" \
52 | ${AWK} -f "${DIR}/ct_c.awk" "rootname=${ROOT}" "outfile=${TMP}" -
Theodore Ts'o3839e651997-04-26 13:21:57 +000053
Theodore Ts'o7eb06692001-09-16 23:29:17 -040054if grep "^#__ERROR_IN_FILE" "${TMP}" > /dev/null; then
55 rm "${TMP}"
Theodore Ts'o3839e651997-04-26 13:21:57 +000056 exit 1
57else
Theodore Ts'o7eb06692001-09-16 23:29:17 -040058 rm -f "${BASE}.c"
Andreas Dilger3f5ef962006-08-05 14:41:00 -040059 mv -f "${TMP}" "${BASE}.c"
60 chmod -w "${BASE}.c"
Theodore Ts'o3839e651997-04-26 13:21:57 +000061 exit 0
62fi