X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=bootstrap.sh;h=5cb6d35e3e3cb5ce610d03770974216e88bed29d;hb=1a2beb5b75e3c08596fc3f94b214df7b9dd0143a;hp=b8c45e5137d50fbd79ea0674094cbac6cd8bb744;hpb=8a971e97129f99102be7452b91865325d58b4a70;p=awesomized%2Flibmemcached diff --git a/bootstrap.sh b/bootstrap.sh index b8c45e51..5cb6d35e 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -31,25 +31,123 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -if test -n $MAKE; then - MAKE="make" -fi - -if test -n $MAKE_J; then - MAKE_J="-j2" -fi - -if test -f configure; then $MAKE $MAKE_J clean; $MAKE $MAKE_J merge-clean; $MAKE $MAKE_J distclean; fi; - -rm -r -f autom4te.cache/ config.h config.log config.status configure -./config/autorun.sh -if [ $(uname) = "Darwin" ]; -then - ./configure CC=clang CXX=clang++ --enable-assert -else - ./configure --enable-assert -fi - -if test -z $JENKINS_URL; then -$MAKE $MAKE_J -fi +die() { echo "$@"; exit 1; } + +command_exists () { + type "$1" &> /dev/null ; +} + +run() { + echo $TESTS_ENVIRONMENT + echo "\`$@' $ARGS" + $@ $ARGS +} + +bootstrap() { + if [ -d .git ] + then + AUTORECONF_FLAGS="--install --force --verbose -Wall -Werror" + elif [ -d .bzr ] + then + AUTORECONF_FLAGS="--install --force --verbose -Wall -Werror" + elif [ -d .svn ] + then + AUTORECONF_FLAGS="--install --force --verbose -Wall -Werror" + elif [ -d .hg ] + then + AUTORECONF_FLAGS="--install --force --verbose -Wall -Werror" + else + AUTORECONF_FLAGS="--install --force --verbose -Wall" + fi + + LIBTOOLIZE_FLAGS="--force --verbose" + + if [ $(uname) = "Darwin" ] + then + LIBTOOLIZE=glibtoolize + elif [ -z "$LIBTOOLIZE" ] + then + LIBTOOLIZE=libtoolize + fi + + AUTOMAKE=automake + AUTORECONF=autoreconf + + AUTOMAKE_FLAGS=--add-missing + + + # Set ENV DEBUG in order to enable debugging + if [ -n "$DEBUG" ] + then + DEBUG="--enable-debug" + fi + + # Set ENV ASSERT in order to enable assert + if [ -n "$ASSERT" ] + then + ASSERT="--enable-assert" + fi + + # Set ENV VALGRIND in order to enable assert + if [ -n "$VALGRIND" ] && command_exists valgrind + then + VALGRIND="valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE" + TESTS_ENVIRONMENT="$VALGRIND" + fi + + # Set ENV MAKE in order to override "make" + if [ -z "$MAKE" ] + then + MAKE="make" + fi + + # Set ENV MAKE_J in order to override "-j2" + if [ -z "$MAKE_J" ] + then + MAKE_J="-j2" + fi + + # Set ENV PREFIX in order to set --prefix for ./configure + if [ -n "$PREFIX" ] + then + PREFIX="--prefix=$PREFIX" + fi + + if [ -f Makefile ] + then + $MAKE $MAKE_J maintainer-clean + fi + + run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute $LIBTOOLIZE" + run $AUTOMAKE $AUTOMAKE_FLAGS || die "Can't execute $AUTORECONF" + run $AUTORECONF $AUTORECONF_FLAGS || die "Can't execute $AUTORECONF" + + # If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV + if [ $(uname) = "Darwin" ] + then + CC=clang CXX=clang++ ./configure $DEBUG $ASSERT $PREFIX || die "configure failed to run" + else + ./configure $DEBUG $ASSERT $PREFIX || die "configure failed to run" + fi + + if [[ -n "$TESTS_ENVIRONMENT" ]] && [[ -f libtool ]] + then + TESTS_ENVIRONMENT="./libtool --mode=execute $TESTS_ENVIRONMENT" + export TESTS_ENVIRONMENT + fi + + if [ -f docs/conf.py ] + then + run $MAKE $MAKE_J man || die "Can't execute make" + fi + + # Set ENV MAKE_TARGET in order to override default of "all" + if [ -z "$MAKE_TARGET" ] + then + MAKE_TARGET="all" + fi + + run $MAKE $MAKE_J $MAKE_TARGET || die "Can't execute make" +} + +bootstrap