bison++.in 1.09 KB
Newer Older
Benoit Perrot's avatar
Benoit Perrot committed
1
2
3
4
5
#! /bin/sh

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

6
7
: ${BISON=@BISON@}

Benoit Perrot's avatar
Benoit Perrot committed
8
9
10
11
# bison++ SRCDIR INPUT OUTPUT OPTIONS
# -----------------------------------

me=$(basename $0)
12
move_if_change='@abs_srcdir@/move-if-change'
Benoit Perrot's avatar
Benoit Perrot committed
13
14

srcdir=$1
15
abs_srcdir=$(cd $srcdir && pwd)
Benoit Perrot's avatar
Benoit Perrot committed
16
17
18
19
20
shift
input=$1
shift
output=$1
shift
21
options="-d -ra $@"
Benoit Perrot's avatar
Benoit Perrot committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

# 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
41
$BISON $options $input -o $output
42

Benoit Perrot's avatar
Benoit Perrot committed
43
44
45
for file in *
do
  case $file in
46
47
48
49
50
51
52
53
    $input)
      # Leave it here.
      ;;
    *)
      # Fix doxygen tags.
      perl -pi -e "s|\Q\\file $file\E\b|\\\\file parse/$file|g;" "$file"
      $move_if_change "$file" "$abs_srcdir/$file"
      ;;
Benoit Perrot's avatar
Benoit Perrot committed
54
55
56
57
58
59
  esac
done

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