summaryrefslogtreecommitdiff
path: root/bootstrap
blob: 3d6267e48fbac27a355453e04587c43ba7a71a9e (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#! /bin/sh

# This script helps bootstrap automake, when checked out from CVS.
#
# Copyright (C) 2002, 2003  Free Software Foundation, Inc.
# written by Pavel Roskin <proski@gnu.org> September 2002
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


# Don't ignore failures
set -e

# Find perl.  Code based on Autoconf, but without non-POSIX support.
if test -z "$PERL"; then
	save_IFS=$IFS
	IFS=:
	for dir in $PATH; do
		IFS=$save_IFS
		test -z "$dir" && dir=.
		if test -x "$dir/perl"; then
			PERL="$dir/perl"
			break
		fi
	done
fi

if test -z "$PERL"; then
	echo "Cannot find perl" 2>&1
	exit 1
fi

# Variables to substitute
VERSION=`sed -ne '/AC_INIT/s/^[^[]*\[[^[]*\[\([^]]*\)\].*$/\1/p' configure.in`
PACKAGE=automake
datadir=.

# Override SHELL.  This is required on DJGPP so that Perl's system()
# uses bash, not COMMAND.COM which doesn't quote arguments properly.
# It's not used otherwise.
if test -n $DJGPP; then
    BOOTSTRAP_SHELL=/dev/env/DJDIR/bin/bash.exe
else
    BOOTSTRAP_SHELL=/bin/sh
fi

# Read the rule for calculating APIVERSION and execute it
apiver_cmd=`sed -ne 's/\[\[/[/g;s/\]\]/]/g;/^APIVERSION=/p' configure.in`
eval $apiver_cmd

# Sanity checks
if test -z "$VERSION"; then
	echo "Cannot find VERSION" 2>&1
	exit 1
fi

if test -z "$APIVERSION"; then
	echo "Cannot find VERSION" 2>&1
	exit 1
fi

# Make a dummy versioned directory for aclocal
rm -rf aclocal-$APIVERSION
mkdir aclocal-$APIVERSION
rm -rf automake-$APIVERSION
# Can't use `ln -s lib automake-$APIVERSION',
# that would create a lib.exe stub under DJGPP 2.03.
mkdir automake-$APIVERSION
cp -rf lib/* automake-$APIVERSION

# Create temporary replacement for aclocal
sed -e "s%@PERL@%$PERL%g" \
    -e "s%@VERSION@%$VERSION%g" \
    -e "s%@APIVERSION@%$APIVERSION%g" \
    -e "s%@PACKAGE@%$PACKAGE%g" \
    -e "s%@datadir@%$datadir%g" \
    -e "s%@SHELL@%$BOOTSTRAP_SHELL%g" \
    aclocal.in >aclocal.tmp

# Create temporary replacement for amversion.m4
sed -e "s%@PERL@%$PERL%g" \
    -e "s%@VERSION@%$VERSION%g" \
    -e "s%@APIVERSION@%$APIVERSION%g" \
    -e "s%@PACKAGE@%$PACKAGE%g" \
    -e "s%@datadir@%$datadir%g" \
    m4/amversion.in >aclocal-$APIVERSION/amversion-tmp.m4

# Run aclocal
$PERL ./aclocal.tmp -I aclocal-$APIVERSION -I m4

# Create temporary replacement for automake
sed -e "s%@PERL@%$PERL%g" \
    -e "s%@VERSION@%$VERSION%g" \
    -e "s%@APIVERSION@%$APIVERSION%g" \
    -e "s%@PACKAGE@%$PACKAGE%g" \
    -e "s%@datadir@%$datadir%g" \
    -e "s%@SHELL@%$BOOTSTRAP_SHELL%g" \
    automake.in >automake.tmp

# Run automake
$PERL ./automake.tmp

# Remove temporary files and directories
rm -rf aclocal-$APIVERSION automake-$APIVERSION
rm -f aclocal.tmp automake.tmp