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

3
4
5
# Exit status.
status=0

Benoit Perrot's avatar
Benoit Perrot committed
6
7
8
# Any tool failure is a failure of the script.
set -e

9
10
: ${BISON=@BISON@}

11
12
# bison++ INPUT OUTPUT OPTIONS
# ----------------------------
Benoit Perrot's avatar
Benoit Perrot committed
13
14

me=$(basename $0)
15
move_if_change='@abs_srcdir@/move-if-change'
Benoit Perrot's avatar
Benoit Perrot committed
16
17

input=$1
18
input_base=$(basename "$input")
Benoit Perrot's avatar
Benoit Perrot committed
19
20
shift
output=$1
21
22
23
output_base=$(basename "$output")
output_dir=$(dirname "$output")
output_dir_abs=$(cd "$output_dir" && pwd)
Benoit Perrot's avatar
Benoit Perrot committed
24
shift
25
options="$@"
Benoit Perrot's avatar
Benoit Perrot committed
26
27
28
29
30
31
32
33
34
35
36

# 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.
37
tmp=$output_base.dir
Benoit Perrot's avatar
Benoit Perrot committed
38
39
40
41
42
rm -rf $tmp
mkdir $tmp

# Compile in this dir.
# Don't use `ln -s' as its semantics of paths sucks.
43
cp $input $tmp
Benoit Perrot's avatar
Benoit Perrot committed
44
cd $tmp
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
set +e
$BISON $options $input_base -o $output_base
status=$?
set -e

if test $status = 0; then
    for file in *
    do
	case $file in
	$input_base)
	    # Leave it here.
	    ;;
	*)
	    # Fix doxygen tags.
	    perl -pi -e "s|\Q\\file $file\E\b|\\\\file parse/$file|g;" "$file"
	    $move_if_change "$file" "$output_dir_abs/$file"
	    ;;
	esac
    done
fi
Benoit Perrot's avatar
Benoit Perrot committed
65
66
67
68

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