-
Notifications
You must be signed in to change notification settings - Fork 0
/
autogen
executable file
·105 lines (95 loc) · 1.8 KB
/
autogen
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
#!/bin/sh
# trace
trace() { echo "autogen: $*"; }
die() { echo "autogen:ERROR: $*" >&2; exit 1; }
# usage
usage()
{
cat <<EOF
USAGE: sh ./autogen [COMMAND]
COMMANDS:
-b, --boot bootstrap package (default command)
-c, --clean cleanup package
-h, --help print this message and exit
EOF
}
# proc_scan
proc_scan()
{
trace "scanning configure.ac..."
local out="`_proc_dump`"
echo "$out"
eval "$out"
}
# _proc_dump
_proc_dump()
{
local regex='/^[ \t]*@@\(.*\)@@[ \t]*$/!d;
s,,\1,g;'
_dump_conf <configure.ac \
| m4 \
| sed -e "$regex"
}
# _dump_conf
_dump_conf()
{
cat <<EOF
changequote(\`[', \`]')
define(AC_INIT,
[@@PACKAGE='\$1'@@]
[@@VERSION='\$2'@@]
)
define(LT_INIT, [@@USE_LIBTOOL=1@@])
@@USE_LIBTOOL=0@@
EOF
local line
while read line; do
if echo "$line" | grep -Eq '\\$'; then
echo -n "$line" | sed -e 's,\\$, '
else
echo "$line"
fi
done
# [TODO] assert line == ''
}
# proc_boot
proc_boot()
{
proc_scan
trace "bootstrapping package '$PACKAGE' $VERSION"
# [fixme]
echo '[TODO]' >ChangeLog
if test -f autogen.pre-hook; then
trace "pre-hook..."
sh ./autogen.pre-hook || die "pre-hook failed"
fi
trace "aclocal..."
aclocal || die "aclocal failed"
test $USE_LIBTOOL -eq 0 || {
trace "libtoolize...";
libtoolize || die "libtoolize failed"; }
trace "automake..."
automake --gnu --add-missing || die "automake failed"
trace "autoconf..."
autoconf || die "autoconf failed"
trace "all done!"
}
# main
main()
{
# parse command line
local cmd='boot'
while test $# -gt 0; do
case "$1" in
-h|-help|--help) usage; exit 0;;
*) echo "autogen:ERROR: invalid option: '$1'" >&2; exit 1;;
esac
done
# go
case "$cmd" in
boot) proc_boot;;
*) echo "autogen:ERROR: !? cmd='$cmd'" >&2; exit 1;;
esac
}
# exec
main "${@}"