1#!/bin/sh 2# 3# 4 5datarootdir=@datarootdir@ 6DIR="${DIR-@datadir@/ss}" 7SS_DIR="@SS_DIR@" 8AWK=@AWK@ 9SED=@SED@ 10 11for 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 23if test "x$1" = x ; then 24 echo "Usage: mk_cmds file" 25 exit 1 26fi 27 28if test -n "$_SS_DIR_OVERRIDE" ; then 29 DIR="$_SS_DIR_OVERRIDE"; 30fi 31 32if test ! -f $DIR/ct_c.sed || test ! -f $DIR/ct_c.awk ; then 33 DIR="$SS_DIR" 34# echo "Falling back to $DIR..." 35 if test ! -f "$DIR/ct_c.sed" || test ! -f "$DIR/ct_c.awk" ; then 36 echo "mk_cmds: Couldn't find mk_cmds's template files." 37 exit 1 38 fi 39fi 40 41FILE="$1" 42ROOT=`echo $1 | sed -e s/.ct$//` 43BASE=`basename "$ROOT"` 44TMP="ct$$.c" 45 46if test ! -f "$FILE" ; then 47 echo "mk_cmds: $FILE: File not found" 48 exit 1; 49fi 50 51${SED} -f "${DIR}/ct_c.sed" "${FILE}" \ 52 | ${AWK} -f "${DIR}/ct_c.awk" "rootname=${ROOT}" "outfile=${TMP}" - 53 54if grep "^#__ERROR_IN_FILE" "${TMP}" > /dev/null; then 55 rm "${TMP}" 56 exit 1 57else 58 rm -f "${BASE}.c" 59 mv -f "${TMP}" "${BASE}.c" 60 chmod -w "${BASE}.c" 61 exit 0 62fi 63