forked from tima/perl-amazon-s3
-
Notifications
You must be signed in to change notification settings - Fork 7
/
bootstrap
executable file
·123 lines (100 loc) · 2.93 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
#!/usr/bin/env bash
# -*- mode: sh; -*
function _bump {
version=$(mktemp)
# if it's M.m.r or M.rr
eval $(echo perl -ne "'chomp; \$p=$1; \$r=\$_; @v=split /\./, $r; if ( @v == 3) { \$v[2]=0 if \$p == 1; \$v[1] = \$v[2] = 0 unless \$p; \$v[\$p]++; print join(\".\", @v);}else{printf q{%5.2f}, \$r+.01;}'" VERSION) > $version
test -e "$version" && mv $version VERSION
echo -n "rebuilding for VERSION: $(cat VERSION)..."
if test -x bootstrap; then
if ./bootstrap && ./configure; then
make clean
make
fi
fi
}
function bump {
[ "$1" = "major" ] && _bump 0 && exit;
[ "$1" = "minor" ] && _bump 1 && exit;
[ "$1" = "release" ] && _bump 2 && exit;
}
function bump_major {
bump 0
}
function bump_minor {
bump 1
}
function bump_release {
bump 2
}
# Usage:
# bootstrap [ AUTORECONF_ARG ... ]
#
# Example 1:
# $ ./bootstrap
#
# Example 2:
# $ ./bootstrap --verbose
#
# Example 3:
# $ ./bootstrap --debug
declare -r PROG='bootstrap'
if [ "$1" = "bump" ]; then
bump $2
exit
fi
_run_on_dir=$( cd "$(dirname "$0")" ; pwd -P )
if test $? -ne 0; then
printf "${PROG} (ERROR): was unable to determine realpath of prog \"%s\"\n" \
"$0" 1>&2
exit 1
fi
# sanity check that our configure.ac file exists
_configure_ac="${_run_on_dir}/configure.ac"
test -f "${_configure_ac}" || {
printf "${PROG} (ERROR): file does not exist: \"%s\"\n" "${_configure_ac}" 1>&2
exit 1
}
# sanity check that our include dir exists
_include_dir="${_run_on_dir}/autotools"
test -d "${_include_dir}" || {
printf "${PROG} (ERROR): m4 macro include directory does not exist: \"%s\"\n" \
"${_include_dir}" 1>&2
exit 1
}
test -n "$DEBUG" && set -x
# From autoreconf(1):
# "The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
# AUTOPOINT, LIBTOOLIZE are honored."
#
# We use these to allow us to easily use the correct versions of the GNU
# autotools. Note: On some systems, the tools are /only/ installed with their
# version number suffixes, so the default names, such as 'aclocal' won't work.
AM_VERSION=$(automake --version | grep "^automake" | awk '{print $4}' | sed 's/^\([0-9]\+\.[0-9]\+\)\.[0-9]\+$/\1/;')
if test "$(which aclocal)"; then
export ACLOCAL="aclocal"
elif test "$(which aclocal-$AM_VERSION)"; then
export ACLOCAL="aclocal-$AM_VERSION"
else
echo "no aclocal found"
exit 1
fi
if test "$(which automake)"; then
export AUTOMAKE="automake"
elif test "$(which automake-$AM_VERSION)"; then
export AUTOMAKE="automake-$AM_VERSION"
else
echo "no automake found"
fi
# use the VERSION file in the project to set the PACKAGE_VERSION
#if test -z "$VERSION"; then
# test -e VERSION && VERSION=$(cat VERSION)
#fi
# --force: consider all files obsolete (ignores timestamps)
# --warnings=all
VERSION="$VERSION" autoreconf \
"--include=${_include_dir}" \
"$@" \
--force \
-i \
"${_configure_ac}"