For PR automake/358:
[platform/upstream/automake.git] / bootstrap
1 #! /bin/sh
2
3 # This script helps bootstrap automake, when checked out from CVS.
4 #
5 # Copyright 2002 Free Software Foundation, Inc.
6 # written by Pavel Roskin <proski@gnu.org> September 2002
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software Foundation,
20 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22
23 # Don't ignore failures
24 set -e
25
26 # Find perl.  Not as good as autoconf would do, but good enough.
27 if test -z "$PERL"; then
28         PERL="`which perl 2>/dev/null`"
29 fi
30
31 if test -z $PERL; then
32         echo "Cannot find perl" 2>&1
33         exit 1
34 fi
35
36 # Variables to substitute
37 VERSION=`sed -ne '/AC_INIT/s/^[^[]*\[[^[]*\[\([^]]*\)\].*$/\1/p' configure.in`
38 PACKAGE=automake
39 datadir=.
40
41 # Read the rule for calculating APIVERSION and execute it
42 apiver_cmd=`sed -ne 's/\[\[/[/g;s/\]\]/]/g;/^APIVERSION=/p' configure.in`
43 eval $apiver_cmd
44
45 # Sanity checks
46 if test -z "$VERSION"; then
47         echo "Cannot find VERSION" 2>&1
48         exit 1
49 fi
50
51 if test -z "$APIVERSION"; then
52         echo "Cannot find VERSION" 2>&1
53         exit 1
54 fi
55
56 # Make a dummy versioned directory for aclocal
57 rm -rf aclocal-$APIVERSION
58 mkdir aclocal-$APIVERSION
59 rm -rf automake-$APIVERSION
60 ln -s lib automake-$APIVERSION
61
62 # Create temporary replacement for aclocal
63 sed -e "s%@PERL@%$PERL%g" \
64     -e "s%@VERSION@%$VERSION%g" \
65     -e "s%@APIVERSION@%$APIVERSION%g" \
66     -e "s%@PACKAGE@%$PACKAGE%g" \
67     -e "s%@datadir@%$datadir%g" \
68     aclocal.in >aclocal.tmp
69
70 # Create temporary replacement for amversion.m4
71 sed -e "s%@PERL@%$PERL%g" \
72     -e "s%@VERSION@%$VERSION%g" \
73     -e "s%@APIVERSION@%$APIVERSION%g" \
74     -e "s%@PACKAGE@%$PACKAGE%g" \
75     -e "s%@datadir@%$datadir%g" \
76     m4/amversion.in >aclocal-$APIVERSION/amversion-tmp.m4
77
78 # Run aclocal
79 $PERL ./aclocal.tmp -I aclocal-$APIVERSION -I m4
80
81 # Create temporary replacement for automake
82 sed -e "s%@PERL@%$PERL%g" \
83     -e "s%@VERSION@%$VERSION%g" \
84     -e "s%@APIVERSION@%$APIVERSION%g" \
85     -e "s%@PACKAGE@%$PACKAGE%g" \
86     -e "s%@datadir@%$datadir%g" \
87     automake.in >automake.tmp
88
89 # Run automake
90 $PERL ./automake.tmp
91
92 # Remove temporary files and directories
93 rm -rf aclocal-$APIVERSION automake-$APIVERSION
94 rm -f aclocal.tmp automake.tmp