diff --git a/src/configure b/src/configure index 44dc1e3bc20..e8d81571422 100755 --- a/src/configure +++ b/src/configure @@ -680,26 +680,44 @@ else fi - echo $ac_n "checking setting template to""... $ac_c" 1>&6 -echo "configure:686: checking setting template to" >&5 +echo "configure:685: checking setting template to" >&5 # Check whether --with-template or --without-template was given. if test "${with_template+set}" = set; then withval="$with_template" TEMPLATE=$withval else - - GUESS=`grep "^$host=" template/.similar | sed 's/.*=//' | tail -1` - if test "$GUESS" - then TEMPLATE="$GUESS" - else - host_no_ver=`echo "$host" | sed 's/[0-9.]*$//'` - GUESS=`grep "^$host_no_ver" template/.similar | sed 's/.*=//' | tail -1` - if test "$GUESS" - then TEMPLATE="$GUESS" - else TEMPLATE=`uname -s | tr A-Z a-z` - fi - fi + +# First, try for a template exactly matching $host +if test -f "template/$host" +then TEMPLATE="$host" +else + # Next try for an exact match to a .similar entry. + # There shouldn't be multiple matches, but take the last if there are. + GUESS=`grep "^$host=" template/.similar | sed 's/^.*=//' | tail -1` + if test "$GUESS" + then TEMPLATE="$GUESS" + else + # Next look for a .similar entry that is a prefix of $host. + # If there are multiple matches, take the last one. + exec 4