blob: d608c1c2a90884ae698ead726a64cd2d977503ad (
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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
#!/bin/sh
#
# $Id: autogen.sh,v 1.22.2.6 2015/03/11 17:10:10 devzero2000 Exp $
# autogen.sh: autogen.sh script for popt projects
#
# Copyright (c) 2010-2015 Elia Pinto <devzero2000@rpm5.org>
#
# This program have the same copyright notice as popt
# itself
#
# Global Function and Variables
#
_PROGNAME="$0"
#
red=; grn=; lgn=; blu=; std=;
test "X$$TERM" != Xdumb \
&& test -t 1 2>/dev/null \
&& { \
red='[0;31m'; \
grn='[0;32m'; \
lgn='[1;32m'; \
blu='[1;34m'; \
std='[m'; \
}
#
# git repository for autoconf config.guess and config.sub
#
_CONFIG_URL="http://git.savannah.gnu.org/gitweb/"
_CONFIG_GUESS_URL="${_CONFIG_URL}?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"
_CONFIG_SUB_URL="${_CONFIG_URL}?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"
Die() {
color="$red"
echo "${color}${_PROGNAME}: Error: $@${std}" >&2
exit 1
}
Notice() {
color="$grn"
echo "${color}${_PROGNAME}: $@${std}"
}
# Function Used for checking the Version Used for building
#
# Note this deviates from the version comparison in automake
# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
# but this should suffice as we won't be specifying old
# version formats or redundant trailing .0 in bootstrap.conf.
# If we did want full compatibility then we should probably
# use m4_version_compare from autoconf.
sort_ver() { # sort -V is not generally available
ver1="$1"
ver2="$2"
# split on '.' and compare each component
i=1
while : ; do
p1=$(echo "$ver1" | cut -d. -f$i)
p2=$(echo "$ver2" | cut -d. -f$i)
if [ ! "$p1" ]; then
echo "$1 $2"
break
elif [ ! "$p2" ]; then
echo "$2 $1"
break
elif [ ! "$p1" = "$p2" ]; then
if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
echo "$2 $1"
elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
echo "$1 $2"
else # numeric, then lexicographic comparison
lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
if [ "$lp" = "$p2" ]; then
echo "$1 $2"
else
echo "$2 $1"
fi
fi
break
fi
i=$(($i+1))
done
}
get_version() {
app=$1
$app --version >/dev/null 2>&1 || return 1
$app --version 2>&1 |
sed -n '# extract version within line
s/.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
t done
# extract version at start of line
s/^\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
t done
d
:done
#the following essentially does s/5.005/5.5/
s/\.0*\([1-9]\)/.\1/g
p
q'
}
check_versions() {
ret=0
while read app req_ver; do
# Honor $APP variables ($TAR, $AUTOCONF, etc.)
appvar=`echo $app | tr '[a-z]' '[A-Z]'`
test "$appvar" = TAR && appvar=AMTAR
eval "app=\${$appvar-$app}"
inst_ver=$(get_version $app)
if [ ! "$inst_ver" ]; then
echo "Error: '$app' not found" >&2
ret=1
elif [ ! "$req_ver" = "-" ]; then
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
if [ ! "$latest_ver" = "$inst_ver" ]; then
echo "Error: '$app' version == $inst_ver is too old" >&2
echo " '$app' version >= $req_ver is required" >&2
ret=1
fi
fi
done
return $ret
}
print_versions() {
echo "Program Min_version"
echo "----------------------"
printf "$buildreq"
echo "----------------------"
# can't depend on column -t
}
usage ( ) {
cat <<EOF
Usage: ${_PROGNAME} [-h|--help] [-d|--download]
--help Help on $NAME_OF_AUTOGEN usage
--download Download the latest config.guess from gnulib
EOF
return 0
}
download_gnulib_config_guess () {
config_guess_temp="config.guess.$$.download"
config_sub_temp="config.sub.$$.download"
ret=1
for __cmd in wget curl fetch ; do
${__cmd} --version > /dev/null 2>&1
ret=$?
if [ ! $ret = 0 ] ; then
continue
fi
__cmd_version=`${__cmd} --version | head -n 1 | sed -e 's/^[^0-9]\+//' -e 's/ .*//'`
opts=""
case ${__cmd} in
wget)
opts="--timeout=5 -O"
;;
curl)
opts="--max-time=5 -o"
;;
fetch)
opts="-t 5 -f"
;;
esac
eval "$__cmd \"${_CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" > /dev/null 2>&1
if [ $? = 0 ] ; then
mv -f "${config_guess_temp}" ${_aux_dir}/config.guess
eval "$__cmd \"${_CONFIG_SUB_URL}\" $opts \"${config_sub_temp}\"" > /dev/null 2>&1
if [ $? = 0 ] ; then
mv -f "${config_sub_temp}" ${_aux_dir}/config.sub
ret=0
break
fi
fi
done
if [ ! $ret = 0 ] ; then
Notice "Warning: config.{guess,sub} download failed from ${_CONFIG_URL}"
rm -f "${config_guess_temp}"
rm -f "${config_sub_temp}"
fi
}
#######################
# Begin Bootstrapping
#######################
# Build prerequisites
buildreq="\
autoconf 2.63
automake 1.14.1
autopoint -
gettext 0.19
libtool 1.5.22
"
##################
# argument check #
##################
ARGS="$*"
#
for arg in $ARGS ; do
case "x$arg" in
x--help) usage && exit 0;;
x-[dD]) DOWNLOAD=yes ;;
x--download) DOWNLOAD=yes ;;
*)
echo "${_PROGNAME}:Unknown option: $arg"
echo
usage
exit 1
;;
esac
done
echo
Notice "Bootstrapping popt build system..."
echo
# Guess whether we are using configure.ac or configure.in
if test -f configure.ac; then
conffile="configure.ac"
elif test -f configure.in; then
conffile="configure.in"
else
Die "could not find configure.ac or configure.in"
echo
fi
#
# detect the aux dir
# for config.{sub,guess}
aux_dir="`grep AC_CONFIG_AUX_DIR $conffile | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
if test ! -d "$_aux_dir"
then
_aux_dir=.
fi
#
if ! printf "$buildreq" | check_versions; then test -f README-prereq &&
test -f README-prereq &&
echo
echo "See README-prereq for notes on obtaining these prerequisite programs:" >&2
echo
print_versions
exit 1
fi
# Libtool
libtoolize=`which glibtoolize 2>/dev/null`
case $libtoolize in
/*) ;;
*) libtoolize=`which libtoolize 2>/dev/null`
case $libtoolize in
/*) ;;
*) libtoolize=libtoolize
esac
esac
if test -z "$libtoolize"; then
Die "libtool not found."
echo
fi
find . -name "autom4te.cache" | xargs rm -rf
[ ! -d m4 ] && mkdir m4
[ ! -d build-aux ] && mkdir build-aux
autoreconf -vfi
po_dir=./po
LANG=C
ls "$po_dir"/*.po 2>/dev/null |
sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
#
[ ${DOWNLOAD} = "yes" ] && download_gnulib_config_guess
echo
Notice "done. Now you can run './configure'."
#######################
# End Bootstrapping
#######################
|