-
Notifications
You must be signed in to change notification settings - Fork 6
/
bootstrap.sh
executable file
·143 lines (113 loc) · 3.99 KB
/
bootstrap.sh
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
#!/usr/bin/env bash
# Written and placed in public domain by Jeffrey Walton
# Autotools sucks. My condolences you have to work with it.
if ! command -v aclocal >/dev/null 2>&1; then
echo "aclocal not found. Bootstrap will probably fail"
fi
if ! command -v automake >/dev/null 2>&1; then
echo "automake not found. Bootstrap will probably fail"
fi
if ! command -v autoupdate >/dev/null 2>&1; then
echo "autoupdate not found. Bootstrap will probably fail"
fi
if ! command -v autoconf >/dev/null 2>&1; then
echo "autoconf not found. Bootstrap will probably fail"
fi
if ! command -v autoreconf >/dev/null 2>&1; then
echo "autoreconf not found. Bootstrap will probably fail"
fi
if ! command -v file >/dev/null 2>&1; then
echo "file not found. Bootstrap will probably fail"
fi
if ! command -v wget >/dev/null 2>&1; then
if ! command -v curl >/dev/null 2>&1; then
echo "wget and curl not found. Updates will probably fail"
fi
fi
#############################################################################
# Default tools
GREP=grep
SED=sed
AWK=awk
# Fixup, Solaris and friends
if [ -d /usr/xpg4/bin ]; then
SED=/usr/xpg4/bin/sed
AWK=/usr/xpg4/bin/awk
GREP=/usr/xpg4/bin/grep
elif [ -d /usr/bin/posix ]; then
SED=/usr/bin/posix/sed
AWK=/usr/bin/posix/awk
GREP=/usr/bin/posix/grep
fi
if command -v wget >/dev/null 2>&1; then
FETCH_CMD="wget -q -O"
elif command -v curl >/dev/null 2>&1; then
FETCH_CMD="curl -L -s -o"
else
FETCH_CMD="curl-and-wget-not-found"
fi
# Fixup for sed and "illegal byte sequence"
IS_DARWIN=`uname -s 2>&1 | "$GREP" -i -c darwin`
if [ "$IS_DARWIN" -ne 0 ]; then
LC_ALL=C; export LC_ALL
fi
#############################################################################
# https://www.gnu.org/software/automake/faq/autotools-faq.html#What-does-_002e_002fbootstrap-or-_002e_002fautogen_002esh-do_003f and
# http://www.fifi.org/doc/autobook/html/autobook_43.html
# This recipe does not work: aclocal && automake --gnu --add-missing && autoconf
# For some reason build-aux is now missing. Autotools really sucks.
mkdir -p m4 build-aux
echo "Running aclocal"
if ! aclocal >/dev/null 2>&1; then
echo "aclocal failed."
exit 1
fi
echo "Running autoupdate"
if ! autoupdate >/dev/null 2>&1; then
echo "autoupdate failed."
exit 1
fi
# Run autoreconf twice on failure. Also see
# https://github.com/tracebox/tracebox/issues/57
echo "Running autoreconf"
if ! autoreconf --force --install >/dev/null 2>&1; then
echo "autoreconf failed, running again."
if ! autoreconf --force --install >/dev/null 2>&1; then
echo "autoreconf failed, again."
exit 1
fi
fi
# Create the configure script
if ! autoconf >/dev/null 2>&1; then
echo "autoconf failed."
exit 1
fi
#############################################################################
# Update config.sub config.guess. GNU recommends using the latest for all projects.
# https://www.gnu.org/software/gettext/manual/html_node/config_002eguess.html
echo "Updating config.sub"
if ${FETCH_CMD} config.sub.new \
'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub' >/dev/null 2>&1; then
# Solaris removes +w, can't overwrite
chmod +w build-aux/config.sub
mv config.sub.new build-aux/config.sub
chmod +x build-aux/config.sub
if [ "$IS_DARWIN" -ne 0 ] && [ command -v xattr >/dev/null 2>&1 ]; then
echo "Removing config.sub quarantine"
xattr -d "com.apple.quarantine" build-aux/config.sub >/dev/null 2>&1
fi
fi
echo "Updating config.guess"
if ${FETCH_CMD} config.guess.new \
'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess' >/dev/null 2>&1; then
# Solaris removes +w, can't overwrite
chmod +w build-aux/config.guess
mv config.guess.new build-aux/config.guess
chmod +x build-aux/config.guess
if [ "$IS_DARWIN" -ne 0 ] && [ command -v xattr >/dev/null 2>&1 ]; then
echo "Removing config.guess quarantine"
xattr -d "com.apple.quarantine" build-aux/config.guess >/dev/null 2>&1
fi
fi
#############################################################################
exit 0