+ run_configure #install_buid_dir
+
+ make_target 'install'
+
+ make_target 'installcheck'
+
+ make_target 'uninstall'
+
+ rm -r -f $INSTALL_LOCATION
+ make 'distclean'
+
+ if [ -f 'Makefile' ]; then
+ die "ASSERT Makefile should not exist"
+ fi
+
+ restore_BUILD
+ safe_popd
+}
+
+function make_darwin_malloc ()
+{
+ run_configure_if_required
+
+ old_MallocGuardEdges=$MallocGuardEdges
+ MallocGuardEdges=1
+ old_MallocErrorAbort=$MallocErrorAbort
+ MallocErrorAbort=1
+ old_MallocScribble=$MallocScribble
+ MallocScribble=1
+
+ make_check
+
+ MallocGuardEdges=$old_MallocGuardEdges
+ MallocErrorAbort=$old_MallocErrorAbort
+ MallocScribble=$old_MallocScribble
+}
+
+function snapshot_check ()
+{
+ if [ ! -f "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
+ make_for_snapshot
+ fi
+
+ if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
+ assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
+ fi
+}
+
+# This will reset our environment, and make sure built files are available.
+function make_for_snapshot ()
+{
+ # Make sure it is clean
+ make_maintainer_clean
+
+ run_configure
+ make_target 'dist'
+ make_target 'distclean'
+
+ # We should have a configure, but no Makefile at the end of this exercise
+ assert_no_file 'Makefile'
+ assert_exec_file 'configure'
+
+ snapshot_check
+}
+
+function check_mingw ()
+{
+ command_exists 'mingw64-configure'
+ ret=$?
+ if [ "$ret" -ne 0 ]; then
+ return 1
+ fi
+
+ command_exists 'mingw64-make'
+ ret=$?
+ if [ "$ret" -ne 0 ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+function check_clang ()
+{
+ command_exists 'clang'
+ ret=$?
+ if [ "$ret" -ne 0 ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+function check_clang_analyzer ()
+{
+ command_exists 'scan-build'
+ ret=$?
+ if [ "$ret" -ne 0 ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+function make_skeleton ()
+{
+ run_configure
+ ret=$?
+
+ if [ $ret -eq 0 ]; then
+ assert_file 'Makefile'
+
+ make_target 'all' 'warn'
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ warn "$MAKE failed"
+ else
+ if [[ -n "$DISPLAY" ]]; then
+ if command_exists 'wine'; then
+ TESTS_ENVIRONMENT='wine'
+ fi
+ fi
+
+ if [[ -n "$TESTS_ENVIRONMENT" ]]; then
+ make_target 'check' 'warn' || warn "$MAKE check failed"
+ ret=$?
+ fi
+ fi
+
+ if $jenkins_build_environment; then
+ make_target 'clean' 'warn'
+ fi
+ fi
+
+ return $ret
+}
+
+function make_for_mingw ()
+{
+ if ! check_mingw; then
+ return 1
+ fi
+
+ # Make sure it is clean
+ if [ -f Makefile -o -f configure ]; then
+ make_maintainer_clean
+ fi
+
+ run_autoreconf
+
+ save_BUILD
+
+ CONFIGURE='mingw64-configure'
+ MAKE='mingw64-make'
+ CONFIGURE_ARGS='--enable-static --disable-shared'
+
+ make_skeleton
+ ret=$?
+
+ restore_BUILD
+
+ return $ret
+}
+
+function make_for_clang ()
+{
+ if ! check_clang; then
+ return 1
+ fi
+
+ # Make sure it is clean
+ if [ -f Makefile -o -f configure ]; then
+ make_maintainer_clean
+ fi
+
+ run_autoreconf
+
+ save_BUILD
+
+ CC=clang CXX=clang++
+ export CC CXX
+
+ make_skeleton
+ ret=$?
+
+ make_target 'check'
+
+ restore_BUILD
+
+ return $ret
+}
+
+function make_for_clang_analyzer ()
+{
+ if ! check_clang; then
+ return 1
+ fi
+
+ if ! check_clang_analyzer; then
+ die 'clang-analyzer was not found'
+ fi
+
+ # Make sure it is clean
+ if [ -f Makefile -o -f configure ]; then
+ make_maintainer_clean
+ fi
+
+ run_autoreconf
+
+ save_BUILD
+
+ CC=clang CXX=clang++
+ export CC CXX
+ CONFIGURE_ARGS='--enable-debug'
+
+ make_skeleton
+ ret=$?
+
+ make_target 'clean' 'warn'
+
+ scan-build -o clang-html make -j4 -k
+
+ restore_BUILD
+
+ return $ret
+}
+
+# If we are locally testing, we should make sure the environment is setup correctly
+function check_for_jenkins ()
+{
+ if ! $jenkins_build_environment; then
+ echo "Not inside of jenkins"
+
+ if [ -f 'configure' ]; then
+ make_maintainer_clean
+ fi
+
+ if $BOOTSTRAP_SNAPSHOT; then
+ make_for_snapshot
+ fi
+ fi
+}
+
+function make_universe ()
+{
+ make_for_snapshot
+ make_valgrind
+ make_gdb
+ make_rpm
+ make_for_clang
+ make_for_clang_analyzer
+
+ if [ check_mingw -eq 0 ]; then
+ make_for_mingw
+ fi
+
+ make_distcheck
+ make_install_system
+}
+
+function make_for_continuus_integration ()
+{
+ # Setup the environment if we are local
+ check_for_jenkins
+
+ # No matter then evironment, we should not have a Makefile at this point
+ assert_no_file 'Makefile'
+
+ # Platforms which require bootstrap should have some setup done before we hit this stage.
+ # If we are building locally, skip this step, unless we are just testing locally.
+ if $BOOTSTRAP_SNAPSHOT; then
+ snapshot_check
+ else
+ # If we didn't require a snapshot, then we should not have a configure
+ assert_no_file 'configure'
+
+ run_autoreconf
+ fi
+
+ assert_no_file 'Makefile' 'Programmer error, Makefile existed where build state should have been clean'
+
+ case $HOST_OS in
+ *-fedora-*)
+ run_configure
+
+ assert_exec_file 'configure'
+ assert_file 'Makefile'
+
+ make_target 'all'
+
+ # make rpm includes "make distcheck"
+ if [[ -f rpm.am ]]; then
+ make_rpm
+ elif [[ -d rpm ]]; then
+ make_rpm
+ else
+ make_distcheck
+ fi
+
+ assert_exec_file 'configure'
+ assert_file 'Makefile'
+
+ make_install_system
+ ;;
+ *-precise-*)
+ run_configure
+
+ assert_exec_file 'configure'
+ assert_file 'Makefile'
+
+ make_target 'all'
+
+ make_distcheck
+
+ assert_exec_file 'configure'
+ assert_file 'Makefile'
+
+ make_valgrind
+
+ assert_exec_file 'configure'
+ assert_file 'Makefile'
+
+ make_install_system
+ ;;
+ *)
+ make_jenkins_default
+ ;;
+ esac
+
+ make_maintainer_clean
+
+ safe_popd
+}
+
+# The point to this test is to test bootstrap.sh itself
+function self_test ()
+{
+ # We start off with a clean env
+ make_maintainer_clean
+
+ eval "./bootstrap.sh jenkins" || die "failed 'jenkins'"
+ eval "./bootstrap.sh all" || die "failed 'all'"
+ eval "./bootstrap.sh gdb" || die "failed 'gdb'"
+ eval "./bootstrap.sh maintainer-clean" || die "failed 'maintainer-clean'"
+}
+
+function make_install_html ()
+{
+ run_configure_if_required
+ assert_file 'configure'
+
+ make_target 'install-html'
+}
+
+function make_gdb ()
+{
+ save_BUILD
+
+ if command_exists 'gdb'; then
+ run_configure_if_required
+
+ # Set ENV GDB_COMMAND
+ if [[ -z "$GDB_COMMAND" ]]; then
+ setup_gdb_command
+ fi
+
+ # If we don't have a configure, then most likely we will be missing libtool
+ assert_file 'configure'
+ if [[ -f 'libtool' ]]; then
+ TESTS_ENVIRONMENT="./libtool --mode=execute $GDB_COMMAND"
+ else
+ TESTS_ENVIRONMENT="$GDB_COMMAND"
+ fi
+
+ make_target 'check'
+
+ if [ -f 'gdb.txt' ]; then
+ rm 'gdb.txt'
+ fi
+
+ if [ -f '.gdb_history' ]; then
+ rm '.gdb_history'
+ fi
+
+ if $jenkins_build_environment; then
+ make_target 'clean'
+ fi
+ else
+ echo 'gdb was not present'
+ return 1
+ fi
+
+ restore_BUILD
+}
+
+# $1 target to compile
+# $2 to die, or not to die, based on contents
+function make_target ()
+{
+ if [ -z "$1" ]; then
+ die "Programmer error, no target provided for make"
+ fi
+
+ if [ ! -f 'Makefile' ]; then
+ die "Programmer error, make was called before configure"
+ run_configure
+ fi
+
+ if [ -n "$TESTS_ENVIRONMENT" ]; then
+ if $VERBOSE; then
+ echo "TESTS_ENVIRONMENT=$TESTS_ENVIRONMENT"
+ fi