Updates from ddm4
[awesomized/libmemcached] / bootstrap.sh
index b8c45e5137d50fbd79ea0674094cbac6cd8bb744..eb16db255d8082fa3c9f867035f60e938c364270 100755 (executable)
 # (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 
+die() { echo "$@"; exit 1; }
+
+run() {
+  echo "\`$@' $ARGS"
+  $@ $ARGS
+} 
+
+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
+
+AUTORECONF=autoreconf
+
+# 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 MAKE in order to override "make"
+if [ -z "$MAKE" ]
+then 
   MAKE="make"
 fi
 
-if test -n $MAKE_J; then 
+# Set ENV MAKE_J in order to override "-j2"
+if [ -z "$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;
+# 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 distclean
+fi
+
+run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute $LIBTOOLIZE"
+run $AUTORECONF $AUTORECONF_FLAGS || die "Can't execute $AUTORECONF"
 
-rm -r -f autom4te.cache/ config.h config.log config.status configure
-./config/autorun.sh
-if [ $(uname) = "Darwin" ];
+# If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV
+if [ $(uname) = "Darwin" ]
 then
-  ./configure CC=clang CXX=clang++ --enable-assert
+  CC=clang CXX=clang++ ./configure $DEBUG $ASSERT $PREFIX || die "configure failed to run"
 else
-  ./configure --enable-assert
+  ./configure $DEBUG $ASSERT $PREFIX || die "configure failed to run"
 fi
 
-if test -z $JENKINS_URL; then 
-$MAKE $MAKE_J
+# 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"