-
Notifications
You must be signed in to change notification settings - Fork 13
/
autogen.sh
executable file
·96 lines (79 loc) · 1.77 KB
/
autogen.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
#!/bin/bash -efu
OPT=
[ "${1-}" != '-f' ] || OPT=--force
fatal()
{
printf >&2 '%s\n' "$*"
exit 1
}
setvars()
{
local varname="$1"; shift
eval "prog_$varname=\"\$1\""; shift
eval "version_matcher_$varname=\"\$1\""; shift
eval "version_pattern_$varname=\"\$1\""; shift
eval "args_$varname=\"\$@\""
}
getvars()
{
eval "prog=\"\$prog_$1\""
eval "version_matcher=\"\${version_matcher_$1:-gnu_version_matcher}\""
eval "version_pattern=\"\$version_pattern_$1\""
eval "args=\"\$args_$1\""
}
get_version()
{
"$prog" --version </dev/null 2>/dev/null | head -1 | "$version_matcher"
}
gnu_version_matcher()
{
sed -n -e 's/^.* \([0-9]\+\(\.[0-9]\+\)*\)$/\1/p'
}
vars=
register()
{
setvars "$@"
vars="$vars $1"
}
foreach()
{
local varname
for varname in $vars; do
getvars "$varname"
"$@"
done
}
check_program()
{
type -p "$prog" >/dev/null 2>&1 ||
fatal "ERROR: You must have $varname installed to build the make-initrd."
if [ -n "$version_pattern" ]; then
local version="$(get_version "$varname")"
[ -n "${version##$version_pattern}" ] ||
return 0
fatal "You must have $varname version >= $version_pattern, but you have $version ."
fi
}
show_version()
{
printf ' %10s: version ' "$prog"
get_version "$varname"
}
execute()
{
eval "set -- \$args_$varname"
printf 'RUN: %s\n' "$prog $*"
"$prog" "$@" || exit 1
}
register aclocal "${ACLOCAL:-aclocal}" '' '' $OPT
register autoconf "${AUTOCONF:-autoconf}" '' '' $OPT
register autoheader "${AUTOHEADER:-autoheader}" '' '' $OPT
printf '\n%s' 'Checking build-system utilities: '
foreach check_program
printf 'OK\n'
printf '\n%s\n' 'Generating build-system with:'
foreach show_version
printf '\n'
rm -rf autom4te.cache
foreach execute
printf '\n%s\n\n' "Now type '${0%/*}/configure' and 'make' to compile."