diff --git a/configure b/configure
index 3bd87c41121d15d40f77bde6babc01c1d1ca9ce0..4be3baec9e429496951316f61cc4ff0dc2664424 100755
--- a/configure
+++ b/configure
@@ -659,6 +659,7 @@ PYTHON
 ENABLE_RUBY
 ENABLE_RUBY_FALSE
 ENABLE_RUBY_TRUE
+RUBY
 ENABLE_SWIG_FALSE
 ENABLE_SWIG_TRUE
 SWIG
@@ -671,7 +672,6 @@ FC_MOD_FLAG
 ENABLE_F2003_ISOC
 CREATE_ISOC_FALSE
 CREATE_ISOC_TRUE
-RUBY
 LIBRT
 ENABLE_MPI
 USE_MPI
@@ -30035,45 +30035,6 @@ fi
 #  ----------------------------------------------------------------------
 #  Create the Fortran Interface via iso_c_binding module (Fortran 2003 Standard)
 #
-# the test for ruby itself is unconditional because ruby is also used in
-# the Fortran 2003 ISO C generator
-# Extract the first word of "ruby", so it can be a program name with args.
-set dummy ruby; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RUBY+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$RUBY"; then
-  ac_cv_prog_RUBY="$RUBY" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_RUBY="ruby"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-RUBY=$ac_cv_prog_RUBY
-if test -n "$RUBY"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY" >&5
-$as_echo "$RUBY" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
 # Check whether --enable-iso-c-interface was given.
 if test "${enable_iso_c_interface+set}" = set; then :
   enableval=$enable_iso_c_interface; enable_isoc=${enableval}
@@ -30396,7 +30357,44 @@ fi
 #
 # Check whether --enable-ruby was given.
 if test "${enable_ruby+set}" = set; then :
-  enableval=$enable_ruby; RUBY_INCLUDES="$($RUBY $srcdir/config/interface.rb)"
+  enableval=$enable_ruby; # Extract the first word of "ruby", so it can be a program name with args.
+set dummy ruby; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RUBY+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RUBY"; then
+  ac_cv_prog_RUBY="$RUBY" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_RUBY="ruby"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RUBY=$ac_cv_prog_RUBY
+if test -n "$RUBY"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY" >&5
+$as_echo "$RUBY" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+   RUBY_INCLUDES="$($RUBY $srcdir/config/interface.rb)"
    save_CPPFLAGS=$CPPFLAGS
    CPPFLAGS="$CPPFLAGS $RUBY_INCLUDES"
    ac_fn_c_check_header_compile "$LINENO" "ruby.h" "ac_cv_header_ruby_h" "$ac_includes_default
@@ -30405,8 +30403,6 @@ if test "x$ac_cv_header_ruby_h" = xyes; then :
 
 else
   enable_ruby=no
-                              RUBY=
-
 fi
 
 
@@ -30443,6 +30439,14 @@ else
   ENABLE_RUBY=false
 
 fi
+# Ruby is also used for the Fortran 2003 ISO C generator in maintainer mode.
+# Report properly if it's missing:
+if ${RUBY:+false} :; then :
+  { RUBY=; unset RUBY;}
+fi
+
+RUBY=${RUBY-"${am_missing_run}ruby"}
+
 #  ----------------------------------------------------------------------
 #  Create the Python Interface via swig
 # Check whether --enable-python was given.
diff --git a/src/Makefile.in b/src/Makefile.in
index c9bc1ae8dde7c9f81873b3c07e03a7081ed84ca3..7d17d054228841afc996d224504fa6657c05e76f 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1364,8 +1364,8 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \
 
 
 #
-mo_cdi.f90: $(top_srcdir)/src/cdi.h $(top_srcdir)/interfaces/f2003/bindGen.rb
-	$(RUBY) $(top_srcdir)/interfaces/f2003/bindGen.rb $(top_srcdir)/src/cdi.h $@
+mo_cdi.f90: @MAINTAINER_MODE_TRUE@ $(top_srcdir)/src/cdi.h $(top_srcdir)/interfaces/f2003/bindGen.rb
+	$(AM_V_GEN)$(RUBY) $(top_srcdir)/interfaces/f2003/bindGen.rb $(top_srcdir)/src/cdi.h $@
 
 @FORTRAN_MOD_UC_TRUE@MO_CDI.$(FCMODEXT): mo_cdi.lo
 @FORTRAN_MOD_UC_FALSE@mo_cdi.$(FCMODEXT): mo_cdi.lo