~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to source4/build/make/yacc_compile.sh

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
YACC="$1"
 
4
SRC="$2"
 
5
DEST="$3"
 
6
 
 
7
dir=`dirname $SRC`
 
8
file=`basename $SRC`
 
9
base=`basename $SRC .y`
 
10
if [ -z "$YACC" ]; then
 
11
        # if $DEST is more recent than $SRC, we can just touch
 
12
        # otherwise we touch but print out warnings
 
13
        if [ -r $DEST ]; then
 
14
                if [ x`find $SRC -newer $DEST -print` = x$SRC ]; then
 
15
                        echo "warning: yacc not found - cannot generate $SRC => $DEST" >&2
 
16
                        echo "warning: yacc not found - only updating the timestamp of $DEST" >&2
 
17
                fi
 
18
                touch $DEST;
 
19
                exit;
 
20
        fi
 
21
        echo "error: yacc not found - cannot generate $SRC => $DEST" >&2
 
22
        exit 1;
 
23
fi
 
24
# if $DEST is more recent than $SRC, we can just touch
 
25
if [ -r $DEST ]; then
 
26
        if [ x`find $SRC -newer $DEST -print` != x$SRC ]; then
 
27
                touch $DEST;
 
28
                exit;
 
29
        fi
 
30
fi
 
31
TOP=`pwd`
 
32
echo "info: running $YACC -d $file"
 
33
if cd $dir && $YACC -d $file; then
 
34
        if [ -r y.tab.h -a -r y.tab.c ];then
 
35
                echo "info: move y.tab.h to $base.h"
 
36
                sed -e "/^#/!b" -e "s|y\.tab\.h|$SRC|" -e "s|\"$base.y|\"$SRC|"  y.tab.h > $base.h
 
37
                echo "info: move y.tab.c to $base.c"
 
38
                sed -e "s|y\.tab\.c|$SRC|" -e "s|\"$base.y|\"$SRC|" y.tab.c > $base.c
 
39
                rm -f y.tab.c y.tab.h
 
40
        elif [ ! -r $base.h -a ! -r $base.c]; then
 
41
                echo "$base.h nor $base.c generated."
 
42
                exit 1
 
43
        fi
 
44
fi
 
45
cd $TOP