diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 4b20087ff71fc6480ecd60f4788d5364233f8de1..eab2079b699fb51b7d1e27e4bc5963c045600e44 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2010-01-26  Paolo Bonzini  <bonzini@gnu.org>
+
+	* configure.ac: Test for executability of _the first word_ of GFORTRAN.
+	* configure: Regenerate.
+
 2010-01-26  Jakub Jelinek  <jakub@redhat.com>
 
 	PR fortran/42866
diff --git a/libgomp/configure b/libgomp/configure
index 23625003a2333b8b8a0b53b0200e8d6a8abea636..d2018b8c1948f827bb3c1f4864d002e753f1bbed 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -11459,7 +11459,8 @@ case `echo $GFORTRAN` in
   -* | no* )
     FC=no ;;
   *)
-    if test -x "$GFORTRAN"; then
+    set dummy $GFORTRAN; ac_word=$2
+    if test -x "$ac_word"; then
       FC="$GFORTRAN"
     else
       FC=no
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index 96c958af6e75ee44bc19994bb7319e21d974f1d0..fefffe9652eaa9290ad37c87a99b706fd0d97f2c 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -146,7 +146,8 @@ case `echo $GFORTRAN` in
   -* | no* )
     FC=no ;;
   *)
-    if test -x "$GFORTRAN"; then
+    set dummy $GFORTRAN; ac_word=$2
+    if test -x "$ac_word"; then
       FC="$GFORTRAN"
     else
       FC=no