source: trunk/server/source4/heimdal_build/lexyacc.sh

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 1.8 KB
Line 
1#!/bin/bash
2
3# rebuild our heimdal lex/yacc files. Run this manually if you update heimdal
4
5lexfiles="heimdal/lib/asn1/lex.l heimdal/lib/hx509/sel-lex.l heimdal/lib/com_err/lex.l"
6yaccfiles="heimdal/lib/asn1/asn1parse.y heimdal/lib/hx509/sel-gram.y heimdal/lib/com_err/parse.y"
7
8set -e
9
10LEX="lex"
11YACC="yacc"
12
13top=$PWD
14
15call_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 $LEX $lfile || exit 1
28
29 if [ -r lex.yy.c ]; then
30 echo "#include \"config.h\"" > $base.c
31 sed -e "s|lex\.yy\.c|$cfile|" lex.yy.c >> $base.c
32 rm -f $base.yy.c
33 elif [ -r $base.yy.c ]; then
34 echo "#include \"config.h\"" > $base.c
35 sed -e "s|$base\.yy\.c|$cfile|" $base.yy.c >> $base.c
36 rm -f $base.yy.c
37 elif [ -r $base.c ]; then
38 mv $base.c $base.c.tmp
39 echo "#include \"config.h\"" > $base.c
40 sed -e "s|$base\.yy\.c|$cfile|" $base.c.tmp >> $base.c
41 rm -f $base.c.tmp
42 elif [ ! -r base.c ]; then
43 echo "$base.c nor $base.yy.c nor lex.yy.c generated."
44 exit 1
45 fi
46 cd $top
47}
48
49
50call_yacc() {
51 yfile="$1"
52
53 echo "Calling $YACC on $yfile"
54
55 dir=$(dirname $yfile)
56 base=$(basename $yfile .y)
57 cfile=$base".c"
58 yfile=$base".y"
59
60 cd $dir
61
62 $YACC -d $yfile || exit 1
63 if [ -r y.tab.h -a -r y.tab.c ];then
64 sed -e "/^#/!b" -e "s|y\.tab\.h|$cfile|" -e "s|\"$base.y|\"$cfile|" y.tab.h > $base.h
65 sed -e "s|y\.tab\.c|$cfile|" -e "s|\"$base.y|\"$cfile|" y.tab.c > $base.c
66 rm -f y.tab.c y.tab.h
67 elif [ ! -r $base.h -a ! -r $base.c]; then
68 echo "$base.h nor $base.c generated."
69 exit 1
70 fi
71 cd $top
72}
73
74
75
76for lfile in $lexfiles; do
77 call_lex $lfile
78done
79
80for yfile in $yaccfiles; do
81 call_yacc $yfile
82done
Note: See TracBrowser for help on using the repository browser.