#!/bin/sh error() { echo "Configure failed due to the errors above!" exit 1 } # Check for --no-updates in any position updates="yes" requested_help="no" for var in "$@"; do case "$var" in --no-updates) echo "Skipping check for Amber updates"; updates="no";; -h|-H|--h|--he|--hel|--help|-help) updates="no"; requested_help="yes";; --full|--full-h|--full-he|--full-hel|--full-help) updates="no"; requested_help="yes";; esac done # No arguments means we ask for help if [ $# -eq 0 ]; then requested_help="yes" updates="no" fi if [ "$updates" = "yes" ]; then # Tell people we're checking for updates, since this could take a # couple seconds, especially if ambermd.org is down echo "Checking for updates..." # Check to see if there are any updates available. This will print a message # giving how many patches are available for Amber and AmberTools ./update_amber --check-updates # The return code of the above command tells us what happened. Return 1 for # an error, and return 2 if there are patches available ret_code=$? if [ $ret_code -eq 2 ]; then printf "There are patches available. Do you want to apply them now? [y/N]" echo " (Recommended Y) " read answer ans=`echo $answer | awk '{print substr($1,1,1)}'` if [ "$ans" = "y" -o "$ans" = "Y" ]; then # Since patch_amber may patch itself and quit before applying all patches, # continue to check for updates and update the tree until they have all # been applied. while [ $ret_code -eq 2 ] do ./update_amber --update if [ $? -ne 0 ]; then echo "Automatic patching failed! Check the errors before re-configuring" exit 1 fi ./update_amber --check-updates 2>&1 > /dev/null ret_code=$? done else echo "NOT updating your tree and continuing anyway." fi elif [ $ret_code -eq 1 ]; then echo "Check for updates failed." fi fi # Simple redirection to carry out the configure script inside AmberTools/src (cd AmberTools/src && ./configure2 $@) || error # Bail out if we just got the usage statement if [ "$requested_help" = "yes" ]; then exit 0 fi ln -sf AmberTools/src/config.h . # Make clean here echo "Cleaning the src directories. This may take a few moments." make clean > /dev/null 2>&1 echo "Configure complete."