summaryrefslogtreecommitdiff
path: root/lexer-gcc-3.1.sh
blob: 1898f27eb8b5f9cefc9ba97d3806cd8a5de0430e (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
#
# script documenting fixes for flex-2.5.4 and gcc-3.1

set -e

FLEXLEXER=OK

if [ -z "$FLEXLEXER" ]; then

includes="$HOME/usr/include $PREFIX/include /usr/local/include /usr/include" 

for i in $includes; do
    file=$i/FlexLexer.h
    if [ -f "$file" ]; then
	break
    else
	file=
    fi
done

if [ -z "$file" ]; then
    cat <<EOF
FlexLexer.h not found in $includes

Please install flex, or find and fix FlexLexer.h by hand.
EOF
    exit 1
fi

fi # flexlexer

if [ -n "$CONF" ]; then
    CONFIGSUFFIX=-$CONF
    SETCONF="CONF=$CONF "
    setconf="conf=$CONF "
    ENABLECONFIG="--enable-config=$CONF "
fi    
outdir=out$CONFIGSUFFIX

if [ -z "$FLEXLEXER" ]; then

echo -n "Copying and fixing $file... "
mkdir -p lily/$outdir
rm -f lily/$outdir/FlexLexer.h
perl -p -e 's/iostream.h/iostream/g;' \
    -e 's/\bistream\b/std::istream/g;' \
    -e 's/\bostream\b/std::ostream/' \
    $file > lily/$outdir/FlexLexer.h
echo "done"

fi # flexlexer

if [ -f GNUmakefile ]; then
    file=lily/$outdir/lexer.cc
    echo -n "Generating and fixing $file... "
    rm -f $file
    make conf=$CONF -C lily $outdir/lexer.cc > /dev/null 2>&1 || true

    mv $file $file.orig
    perl -p -e 's/\bcin\b/std::cin/g;' \
	-e 's/\bcout\b/std::cout/g;' \
	-e 's/\bcerr\b/std::cerr/g' \
	$file.orig > $file
    echo "done"
fi

cat <<EOF

Remove config.cache before rerunning ./configure

Reconfigure, refix, and make doing something like:

    rm -f config.cache
    CPPFLAGS=-I$(pwd)/lily/$outdir ./configure $ENABLECONFIG
    $SETCONF$0
    make $setconf
EOF