bison++ 936 Bytes
Newer Older
Benoit Perrot's avatar
Benoit Perrot committed
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
#! /bin/sh

# Any tool failure is a failure of the script.
set -e

# bison++ SRCDIR INPUT OUTPUT OPTIONS
# -----------------------------------

me=$(basename $0)
auxdir=$(cd $(dirname $0) && pwd)

srcdir=$1
shift
input=$1
shift
output=$1
shift
options="-S lalr1.cc $@"

# Alexandre Duret-Lutz also notes that in VPATH-builds $(srcdir) can
# be an absolute path depending on how ./configure is called ...
# In that case

#   bison $(srcdir)/parsetiger.yy [...]

# will hard code the path in the maintainer's tree.  Hence, do not use
# paths with Bison, chdir there.

# A tmp dir.
tmp=$output.dir
rm -rf $tmp
mkdir $tmp

# Compile in this dir.
# Don't use `ln -s' as its semantics of paths sucks.
cp $srcdir/$input $tmp
cd $tmp
bison $options -S lalr1.cc $input -o $output
for file in *
do
  case $file in
    $input) ;;
         *) $auxdir/move-if-change $file ../$srcdir/$file;;
  esac
done

# Get rid of the tmp dir.
cd ..
rm -rf $tmp