1#! /bin/sh
2
3# Allow invocation from a separate build directory; in that case, we change
4# to the source directory to run the auto*, then change back before running configure
5srcdir=`dirname "$0"`
6test -z "$srcdir" && srcdir=.
7
8ORIGDIR=`pwd`
9cd "$srcdir" || exit 1
10
11if [ ! -f README ]; then
12    ln -s README.rst README
13fi
14
15touch ChangeLog
16touch AUTHORS
17
18if test -z "$(which libtoolize)" && test -z "$(which glibtoolize)"; then
19    echo "Error: libtoolize was not found on your system. Cannot continue."
20    if test "$(uname)" = "Darwin"; then
21        echo "On Darwin, this is named glibtoolize"
22    fi
23    exit 1
24fi
25
26if [ -d .git ]; then
27    git submodule init
28    git submodule update
29
30    cd src/libbson
31    NOCONFIGURE=1 ./autogen.sh
32    cd ../../
33elif [ ! -f src/libbson/autogen.sh ]; then
34    echo "Not a release archive or a git clone"
35    echo "Please download mongoc from https://github.com/mongodb/mongo-c-driver/releases"
36    exit 1
37fi
38
39if test -z `which autoreconf`; then
40    echo "Error: autoreconf not found, please install it."
41    exit 1
42fi
43autoreconf --force --verbose --install -I build/autotools $ACLOCAL_FLAGS|| exit $?
44rm -rf autom4te.cache
45
46cd "$ORIGDIR" || exit 1
47
48if test -z "$NOCONFIGURE"; then
49    "$srcdir"/configure $AUTOGEN_CONFIGURE_ARGS "$@" || exit $?
50fi
51