bugs: a hardware solution is probably the best long-term approach for the
[libale.git] / bootstrap
blobe89d4a34cf36755798b0cb575bf52ea63281f670
1 #!/bin/bash
3 # Copyright 2008 David Hilvert <dhilvert@gmail.com>
5 # This file is part of libale.
7 # libale is free software: you can redistribute it and/or modify it under the
8 # terms of the GNU Affero General Public License as published by the Free
9 # Software Foundation, either version 3 of the License, or (at your option)
10 # any later version.
12 # libale is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
15 # more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with libale. If not, see <http://www.gnu.org/licenses/>.
20 ###
21 ### 'bootstrap' generates build files for distribution.
22 ###
24 function bootstrap_error {
25 exit 1
29 # If a version argument is given, generate a tarball.
32 if test "x$1" = "x-v"; then
33 BOOTSTRAP_VERSION=$2
35 if test "x$BOOTSTRAP_VERSION" = "x"; then
36 echo "bootstrap: -v requires a version argument."
37 bootstrap_error
40 SOURCE_DIR=`pwd`
42 REMOTE_REPO=`./version.sh git-repo`
44 GENERIC_PACKAGE_NAME=`./version.sh package-name`
46 PACKAGE_NAME="$GENERIC_PACKAGE_NAME-$BOOTSTRAP_VERSION"
48 TEMPDIR=`mktemp -d`
50 cd $TEMPDIR
52 if test $SOURCE_DIR = `pwd`; then
53 echo "$0: could not change directory from source."
54 cd $SOURCE_DIR
55 bootstrap_error
58 if ! git clone "$SOURCE_DIR" "$PACKAGE_NAME" && ! git clone "$REMOTE_REPO" "$PACKAGE_NAME"; then
59 echo "$0: Could not perform git clone."
60 cd $SOURCE_DIR
61 rm -rf $TEMPDIR
62 bootstrap_error
65 cd $PACKAGE_NAME
67 if ! git checkout $BOOTSTRAP_VERSION && ! git checkout origin/$BOOTSTRAP_VERSION; then
69 echo "$0: Could not check out version $BOOTSTRAP_VERSION."
70 cd $SOURCE_DIR
71 rm -rf $TEMPDIR
72 bootstrap_error
75 mv .git ../git-moved-$BOOTSTRAP_VERSION
77 if grep ":version:" VERSION; then
78 (echo ":%s/^:version:.*/:version: $BOOTSTRAP_VERSION/"; echo ":wq") | ex VERSION
79 elif test -e VERSION; then
80 echo "$BOOTSTRAP_VERSION" > VERSION
83 if test -e bootstrap && (! chmod a+x bootstrap || ! ./bootstrap); then
84 echo "$0: Nested bootstrap failed."
85 cd $SOURCE_DIR
86 rm -rf $TEMPDIR
87 bootstrap_error
90 cd ..
92 tar czf $PACKAGE_NAME.tar.gz $PACKAGE_NAME
94 cd $SOURCE_DIR
96 mv $TEMPDIR/$PACKAGE_NAME.tar.gz .
98 rm -rf $TEMPDIR
100 echo "Bootstrapped package created as $PACKAGE_NAME.tar.gz."
102 exit 0
106 # Check for the existence of a configure script.
109 if test -e configure && test "x$1" != "x-r"; then
110 echo
111 echo "To install:"
112 echo "1) Run './configure'."
113 echo "2) Run 'make'."
114 echo "3) Run 'make install'."
115 echo ""
116 echo "* To regenerate configure, run '$0 -r'"
117 echo
118 bootstrap_error
122 # Look for files we might need.
125 if ! test -e /usr/share/aclocal/ax_cflags_warn_all.m4; then
126 echo "Cannot find /usr/share/aclocal/ax_cflags_warn_all.m4. Is aclocal installed?"
127 bootstrap_error
130 if ! which autoreconf &> /dev/null; then
131 echo "Cannot find autoreconf. Is autoconf installed?"
132 bootstrap_error
135 if ! which automake &> /dev/null; then
136 echo "Cannot find automake."
137 bootstrap_error
140 if ! which libtool &> /dev/null; then
141 echo "Cannot find libtool."
142 bootstrap_error
146 # Add autoconf archive files.
149 cp /usr/share/aclocal/ax_cflags_warn_all.m4 m4/.
150 cp /usr/share/aclocal/ac_c_long_long.m4 m4/.
153 # Run autotools' bootstrap script, adding things that automake thinks are
154 # missing, among other things (--install).
157 autoreconf --install
160 # Indicate that we're done.
163 echo ""
164 echo "Done."
167 # Tell the user what to do next.
170 echo
171 echo "To install:"
172 echo "1) Run './configure'."
173 echo "2) Run 'make'."
174 echo "3) Run 'make install'."