s4:librpc/rpc: remember some smbXcli_* pointers within struct dcerpc_pipe_connect
[samba.git] / source4 / heimdal_build / lexyacc.sh
1 #!/bin/bash
2
3 # rebuild our heimdal lex/yacc files. Run this manually if you update heimdal
4
5 lexfiles="heimdal/lib/asn1/lex.l heimdal/lib/hx509/sel-lex.l heimdal/lib/com_err/lex.l"
6 yaccfiles="heimdal/lib/asn1/asn1parse.y heimdal/lib/hx509/sel-gram.y heimdal/lib/com_err/parse.y"
7
8 set -e
9
10 LEX="lex"
11 YACC="yacc"
12
13 top=$PWD
14
15 call_lex() {
16     lfile="$1"
17
18     echo "Calling $LEX on $lfile"
19
20     dir=$(dirname $lfile)
21     base=$(basename $lfile .l)
22     cfile=$base".c"
23     lfile=$base".l"
24
25     cd $dir
26
27     # --noline specified because line directives cause more bother than they solve (issues with lcov finding the source files)
28     $LEX --noline $lfile || exit 1
29
30     if [ -r lex.yy.c ]; then
31         echo "#include \"config.h\"" > $base.c
32         grep -v "^#line" lex.yy.c >> $base.c
33         rm -f $base.yy.c
34     elif [ -r $base.yy.c ]; then
35         echo "#include \"config.h\"" > $base.c
36         grep -v "^#line" $base.yy.c >> $base.c
37         rm -f $base.yy.c
38     elif [ -r $base.c ]; then
39         mv $base.c $base.c.tmp
40         echo "#include \"config.h\"" > $base.c
41         grep -v "^#line" $base.c.tmp >> $base.c
42         rm -f $base.c.tmp
43     elif [ ! -r base.c ]; then
44         echo "$base.c nor $base.yy.c nor lex.yy.c generated."
45         exit 1
46     fi
47     cd $top
48 }
49
50
51 call_yacc() {
52     yfile="$1"
53
54     echo "Calling $YACC on $yfile"
55
56     dir=$(dirname $yfile)
57     base=$(basename $yfile .y)
58     cfile=$base".c"
59     yfile=$base".y"
60
61     cd $dir
62
63     # -l specified because line directives cause more bother than they solve (issues with lcov finding the source files)
64     $YACC -l -d $yfile || exit 1
65     if [ -r y.tab.h -a -r y.tab.c ];then
66         cat y.tab.h > $base.h
67         cat y.tab.c > $base.c
68         rm -f y.tab.c y.tab.h
69     elif [ ! -r $base.h -a ! -r $base.c]; then
70         echo "$base.h nor $base.c generated."
71         exit 1
72     fi
73     cd $top
74 }
75
76
77
78 for lfile in $lexfiles; do
79     call_lex $lfile
80 done
81
82 for yfile in $yaccfiles; do
83     call_yacc $yfile
84 done