Merge branch 'msvc'
[platform/upstream/automake.git] / bootstrap
1 #! /bin/sh
2
3 # This script helps bootstrap automake, when checked out from git.
4 #
5 # Copyright (C) 2002, 2003, 2004, 2007, 2008, 2010 Free Software
6 # Foundation, Inc.
7 # Originally written by Pavel Roskin <proski@gnu.org> September 2002.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 # Don't ignore failures.
23 set -e
24
25 # Set program basename.
26 me=`echo "$0" | sed 's,^.*/,,'`
27
28 # Let user choose which version of autoconf, autom4te and perl to use.
29 : ${AUTOCONF=autoconf}
30 export AUTOCONF  # might be used by aclocal and/or automake
31 : ${AUTOM4TE=autom4te}
32 export AUTOM4TE  # ditto
33 : ${PERL=perl}
34
35 # Variables to substitute.
36 VERSION=`sed -ne '/AC_INIT/s/^[^[]*\[[^[]*\[\([^]]*\)\].*$/\1/p' configure.ac`
37 PACKAGE=automake
38 datadir=.
39 PERL_THREADS=0
40
41 # Override SHELL.  This is required on DJGPP so that Perl's system()
42 # uses bash, not COMMAND.COM which doesn't quote arguments properly.
43 # It's not used otherwise.
44 if test -n "$DJDIR"; then
45   BOOTSTRAP_SHELL=/dev/env/DJDIR/bin/bash.exe
46 else
47   BOOTSTRAP_SHELL=/bin/sh
48 fi
49
50 # Read the rule for calculating APIVERSION and execute it.
51 apiver_cmd=`sed -ne 's/\[\[/[/g;s/\]\]/]/g;/^APIVERSION=/p' configure.ac`
52 eval "$apiver_cmd"
53
54 # Sanity checks.
55 if test -z "$VERSION"; then
56   echo "$me: cannot find VERSION" >&2
57   exit 1
58 fi
59
60 if test -z "$APIVERSION"; then
61   echo "$me: cannot find APIVERSION" >&2
62   exit 1
63 fi
64
65 # Make a dummy versioned directory for aclocal.
66 rm -rf aclocal-$APIVERSION
67 mkdir aclocal-$APIVERSION
68 if test -d automake-$APIVERSION; then
69   find automake-$APIVERSION -exec chmod u+wx '{}' ';'
70 fi
71 rm -rf automake-$APIVERSION
72 # Can't use `ln -s lib automake-$APIVERSION', that would create a
73 # lib.exe stub under DJGPP 2.03.
74 mkdir automake-$APIVERSION
75 cp -rf lib/* automake-$APIVERSION
76
77 dosubst ()
78 {
79   rm -f $2
80   in=`echo $1 | sed 's,^.*/,,'`
81   sed -e "s%@APIVERSION@%$APIVERSION%g" \
82       -e "s%@PACKAGE@%$PACKAGE%g" \
83       -e "s%@PERL@%$PERL%g" \
84       -e "s%@PERL_THREADS@%$PERL_THREADS%g" \
85       -e "s%@SHELL@%$BOOTSTRAP_SHELL%g" \
86       -e "s%@VERSION@%$VERSION%g" \
87       -e "s%@datadir@%$datadir%g" \
88       -e "s%@configure_input@%Generated from $in; do not edit by hand.%g" \
89       $1 > $2
90   chmod a-w $2
91 }
92
93 # Create temporary replacement for lib/Automake/Config.pm.
94 dosubst automake-$APIVERSION/Automake/Config.in \
95         automake-$APIVERSION/Automake/Config.pm
96
97 # Create temporary replacement for aclocal.
98 dosubst aclocal.in aclocal.tmp
99
100 # Overwrite amversion.m4.
101 dosubst m4/amversion.in m4/amversion.m4
102
103 # Create temporary replacement for automake.
104 dosubst automake.in automake.tmp
105
106 # Create tests/parallel-tests.am.
107 cd tests
108 $BOOTSTRAP_SHELL ./gen-parallel-tests > parallel-tests.am
109 cd ..
110
111 # Run the autotools.
112 $PERL ./aclocal.tmp -I m4
113 $AUTOCONF
114 $PERL ./automake.tmp
115
116 # Remove temporary files and directories.
117 rm -rf aclocal-$APIVERSION automake-$APIVERSION
118 rm -f aclocal.tmp automake.tmp