+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 make_skeleton_mingw ()
+{
+ 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
+ elif command_exists 'wineconsole'; then
+ TESTS_ENVIRONMENT='wineconsole --backend=curses'
+ 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 ()
+{
+ check_mingw
+ if ! check_mingw; then
+ die 'mingw64 tools were not found'
+ 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'
+
+ make_skeleton_mingw
+ ret=$?
+
+ 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
+
+ if [ check_mingw -eq 0 ]; then
+ make_for_mingw
+ fi
+
+ make_distcheck
+ make_install_system