blob: 96772c78da67c2a6cdd95645cde8eb6f431109b4 [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001#!/bin/sh
2#
3#
Theodore Ts'ob6b65c32006-10-22 00:14:26 -04004
5datarootdir=@datarootdir@
Theodore Ts'o3839e651997-04-26 13:21:57 +00006AWK=@AWK@
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +00007DIR="${DIR-@datadir@/et}"
Theodore Ts'o7eb06692001-09-16 23:29:17 -04008ET_DIR="@ET_DIR@"
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +00009
Theodore Ts'o91835c12003-03-30 22:26:13 -050010if test "$1" = "--build-tree" ; then
11 shift;
12 DIR="$ET_DIR"
13fi
14
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +000015if test "x$1" = x ; then
16 echo "Usage: compile_et file"
17 exit 1
18fi
19
Theodore Ts'o05155f92006-11-12 10:43:31 -050020for as_var in \
21 LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
22 LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
23 LC_TELEPHONE LC_TIME
24do
25 if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
26 eval $as_var=C; export $as_var
27 else
28 $as_unset $as_var
29 fi
30done
31
Theodore Ts'o56eb4d42004-09-17 19:54:22 -040032if test ! -f "$DIR/et_h.awk" || test ! -f "$DIR/et_c.awk" ; then
Theodore Ts'o7eb06692001-09-16 23:29:17 -040033 DIR="$ET_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/et_h.awk" || test ! -f "$DIR/et_c.awk" ; then
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +000036 echo "compile_et: Couldn't find compile_et's template files."
37 exit 1
38 fi
39fi
Theodore Ts'o3839e651997-04-26 13:21:57 +000040
41ROOT=`echo $1 | sed -e s/.et$//`
42BASE=`basename $ROOT`
43
Theodore Ts'o7eb06692001-09-16 23:29:17 -040044if test ! -f "$ROOT.et" ; then
Theodore Ts'oe5fa0e31998-04-01 02:18:45 +000045 echo "compile_et: $ROOT.et: File not found"
46 exit 1;
47fi
48
Theodore Ts'o153b4492005-05-06 09:42:34 -040049$AWK -f "${DIR}/et_h.awk" "outfile=${BASE}.h.$$" "outfn=${BASE}.h" "$ROOT.et"
50if test -f ${BASE}.h && cmp -s ${BASE}.h.$$ ${BASE}.h ; then
Andreas Dilger3f5ef962006-08-05 14:41:00 -040051 rm -f ${BASE}.h.$$
Theodore Ts'o153b4492005-05-06 09:42:34 -040052else
Andreas Dilger3f5ef962006-08-05 14:41:00 -040053 mv -f ${BASE}.h.$$ ${BASE}.h
54 chmod -w ${BASE}.h
Theodore Ts'o153b4492005-05-06 09:42:34 -040055fi
56$AWK -f "${DIR}/et_c.awk" "outfile=${BASE}.c.$$" "outfn=${BASE}.c" "$ROOT.et"
57if test -f ${BASE}.c && cmp -s ${BASE}.c.$$ ${BASE}.c ; then
Andreas Dilger3f5ef962006-08-05 14:41:00 -040058 rm -f ${BASE}.c.$$
Theodore Ts'o153b4492005-05-06 09:42:34 -040059else
Andreas Dilger3f5ef962006-08-05 14:41:00 -040060 mv -f ${BASE}.c.$$ ${BASE}.c
61 chmod -w ${BASE}.c
Theodore Ts'o153b4492005-05-06 09:42:34 -040062fi