source: branches/samba-3.5.x/source4/build/make/lex_compile.sh

Last change on this file was 414, checked in by Herwig Bauernfeind, 16 years ago

Samba 3.5.0: Initial import

File size: 1.7 KB
Line 
1#!/bin/sh
2
3LEX="$1"
4SRC="$2"
5DEST="$3"
6shift 3
7ARGS="$*"
8
9dir=`dirname $SRC`
10file=`basename $SRC`
11base=`basename $SRC .l`
12if [ -z "$LEX" ]; then
13 # if $DEST is more recent than $SRC, we can just touch
14 # otherwise we touch but print out warnings
15 if [ -r $DEST ]; then
16 if [ x`find $SRC -newer $DEST -print` = x$SRC ]; then
17 echo "warning: lex not found - cannot generate $SRC => $DEST" >&2
18 echo "warning: lex not found - only updating the timestamp of $DEST" >&2
19 fi
20 touch $DEST;
21 exit;
22 fi
23 echo "error: lex not found - cannot generate $SRC => $DEST" >&2
24 exit 1;
25fi
26# if $DEST is more recent than $SRC, we can just touch
27if [ -r $DEST ]; then
28 if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then
29 touch $DEST;
30 exit;
31 fi
32fi
33TOP=`pwd`
34echo "info: running $LEX $ARGS $file"
35if cd $dir && $LEX $ARGS $file; then
36 if [ -r lex.yy.c ];then
37 # we must guarantee that config.h comes first
38 echo "info: move lex.yy.c to $base.c"
39 echo "#include \"config.h\"" > $base.c
40 sed -e "s|lex\.yy\.c|$DEST|" lex.yy.c >> $base.c
41 rm -f $base.yy.c
42 elif [ -r $base.yy.c ];then
43 # we must guarantee that config.h comes first
44 echo "info: move $base.yy.c to $base.c"
45 echo "#include \"config.h\"" > $base.c
46 sed -e "s|$base\.yy\.c|$DEST|" $base.yy.c >> $base.c
47 rm -f $base.yy.c
48 elif [ -r $base.c ];then
49 # we must guarantee that config.h comes first
50 echo "info: add #include \"config.h\" to $base.c"
51 mv $base.c $base.c.tmp
52 echo "#include \"config.h\"" > $base.c
53 sed -e "s|$base\.yy\.c|$DEST|" $base.c.tmp >> $base.c
54 rm -f $base.c.tmp
55 elif [ ! -r base.c ]; then
56 echo "$base.c nor $base.yy.c nor lex.yy.c generated."
57 exit 1
58 fi
59fi
60cd $TOP
Note: See TracBrowser for help on using the repository browser.