forked from libMesh/libmesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·183 lines (151 loc) · 5.97 KB
/
bootstrap
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env bash
#
# bootstrap: Utility to easy autoconf/automake toolchain setup on
# checkout from revision control.
#
# Copyright (c) 2002 Daniel Elstner <daniel.elstner@gmx.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License VERSION 2 as
# published by the Free Software Foundation. You are not allowed to
# use any other version of the license; unless you got the explicit
# permission from the author to do so.
#
# 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
dir=$(echo "$0" | sed 's,[^/]*$,,')
test "${dir}" = "" && dir='.'
if test "$(cd "${dir}" 2>/dev/null && pwd)" != "$(pwd)"; then
echo "This script must be executed directly from the source directory."
exit 1
fi
#########################################################################################
function check_autotool_prerequisites ()
{
# prerequisite versions
automake_major=1
automake_minor=16
automake_subminor=5
autoconf_major=2
autoconf_minor=71
build_autotools=0
autoreconf=$(which autoreconf 2>/dev/null)
if test "$autoreconf" != ""; then
if test -x $autoreconf; then
autoconf_version=$($autoreconf --version | grep " $autoconf_major\." | cut -d"." -f2)
if test $autoconf_version -lt $autoconf_minor; then
echo "Autoconf Version $autoconf_major.$autoconf_version too old, building a new one..."
build_autotools=1
else
version_id=$($autoreconf --version 2>&1 | grep "(GNU Autoconf)")
echo "Using autoconf ($version_id)"
fi
else
build_autotools=1
fi
else
build_autotools=1
fi
libtool=$(which glibtool 2>/dev/null)
if test "$libtool" = ""; then
libtool=$(which libtool 2>/dev/null)
fi
if test "$libtool" != ""; then
if test -x $libtool; then
libtool_version=$($libtool --version 2>&1 | grep "(GNU libtool)")
case "$libtool_version" in
*2.4* | *2.2*)
echo "Using libtool ($libtool_version)"
;;
*)
echo "Indaequate Libtool ($libtool_version), building a new one..."
build_autotools=1
esac
else
build_autotools=1
fi
else
build_autotools=1
fi
automake=$(which automake 2>/dev/null)
if test "$automake" != ""; then
if test -x $automake; then
automake_minor_version=$($automake --version | grep " $automake_major\." | cut -d"." -f2)
if test $automake_minor_version -lt $automake_minor; then
echo "Automake Version $automake_major.$automake_minor_version too old, building a new one..."
build_autotools=1
else
automake_subminor_version=$($automake --version | grep " $automake_major\." | cut -d"." -f3)
version_id=$($automake --version 2>&1 | grep "(GNU automake)")
if test $automake_subminor_version -lt $automake_subminor; then
echo "Automake Version $version_id too old, building a new one..."
build_autotools=1
else
echo "Using automake ($version_id)"
fi
fi
else
build_autotools=1
fi
else
build_autotools=1
fi
return $build_autotools
}
#########################################################################################
check_autotool_prerequisites
build_autotools=$?
#########################################################################################
for arg in $@; do
if test "x$arg" = "x--build-autotools"; then
echo "building autotools at user request"
build_autotools=1
fi
done
#########################################################################################
if test "$build_autotools" = "1"; then
# when there is no autoreconf try to actually build one.
echo "Inadequate autotools in your path, I'll build new ones..."
top_srcdir=$(pwd)
autotools_distdir=$top_srcdir/contrib/autotools
if test -d $autotools_distdir; then
# set the path to use the new tools as they are installed.
# for example, the new autoconf is needed to build automake.
PATH=$autotools_distdir/bin:$PATH
for tool in autoconf-2.71 automake-1.16.5 libtool-2.4.7 ; do
cd $autotools_distdir
echo " building $tool in $autotools_distdir"
tar zxf $tool.tar.gz
cd $tool && ./configure --prefix=$autotools_distdir >/dev/null && make install >/dev/null
cd .. && rm -rf $tool
done
cd $top_srcdir
if test -x $autotools_distdir/bin/autoreconf -a -x $autotools_distdir/bin/automake -a -x $autotools_distdir/bin/libtool; then
echo " "
echo " --> successfully installed autoreconf in $autotools_distdir/bin - please update your PATH and try again!"
echo " "
PATH=$autotools_distdir/bin:$PATH ./$0
exit 0
fi
fi
fi
#########################################################################################
autoreconf=$(which autoreconf 2>/dev/null)
# prefer autoreconf when it is available
if test "$autoreconf" != ""; then
if test -x $autoreconf; then
$autoreconf -iv --force
patch -p1 <build-aux/compile.patch
exit 0
fi
fi
# # now recursively call bootstrap with the autotools in our path
# export PATH=$autotools_distdir/bin:$PATH
# which autoreconf
# $0