r18322: fixed a compilation problem on AIX caused by lex not putting config.h
[sfrench/samba-autobuild/.git] / source4 / script / lex_compile.sh
1 #!/bin/sh
2
3 LEX="$1"
4 SRC="$2"
5 DEST="$3"
6
7 dir=`dirname $SRC`
8 file=`basename $SRC`
9 base=`basename $SRC .l`
10 if [ -z "$LEX" ]; then
11         echo "lex not found - not regenerating $DEST"
12         exit;
13 fi
14 if [ -r $DEST ]; then
15         if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then
16                 exit;
17         fi
18 fi
19 TOP=`pwd`
20 if cd $dir && $LEX $file; then
21         if [ -r $base.yy.c ];then
22                 # we must guarantee that config.h comes first
23                 echo "#include \"config.h\"" > $base.c
24                 sed '/^#/ s|$base.yy\.c|$DEST|' $base.yy.c >> $base.c
25                 rm -f $base.yy.c
26         fi
27 fi
28 cd $TOP