$NetBSD: patch-ac,v 1.23 2008/04/26 02:39:27 markd Exp $

--- configure.orig	2008-04-15 14:06:13.000000000 +1200
+++ configure
@@ -2712,7 +2712,7 @@ fi
 
 
 if test "${want_R_shlib}" = yes; then
-  LIBR="-L\$(R_HOME)/lib\$(R_ARCH) -lR"
+  LIBR="-Wl,-R${prefix}/lib/R/lib\$(R_ARCH) -L\$(R_HOME)/lib\$(R_ARCH) -lR"
 else
   LIBR=
 fi
@@ -28129,6 +28129,7 @@ cat > conftest.c <<EOF
 #else
 # define F77_SYMBOL(x)   x
 #endif
+int MAIN__ () { return 0; }
 int main () {
   exit(0);
 }
@@ -28206,6 +28207,9 @@ cat > conftest.c <<EOF
 
 extern void F77_SYMBOL(cftest)(int *a, int *b, double *x, double *y);
 
+int MAIN_ () { return 0; }
+int MAIN__ () { return 0; }
+
 int main () {
   int a[3] = {17, 237, 2000000000}, b[2], res = 0;
   double x[3] = {3.14159265, 123.456789, 2.3e34}, z[3];
@@ -28303,6 +28307,9 @@ typedef struct {
 
 extern void F77_SYMBOL(cftest)(Rcomplex *x);
 
+int MAIN_ () { return 0; }
+int MAIN__ () { return 0; }
+
 int main () {
     Rcomplex z[3];
 
@@ -29385,151 +29392,6 @@ echo "${ECHO_T}no" >&6; }
 fi
 
     fi
-    if test "${G77}" = yes; then
-      ac_safe=_mieee
-{ echo "$as_me:$LINENO: checking whether ${F77} accepts -mieee" >&5
-echo $ECHO_N "checking whether ${F77} accepts -mieee... $ECHO_C" >&6; }
-if { as_var=r_cv_prog_f77_flag_${ac_safe}; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-r_save_FFLAGS="${FFLAGS}"
-FFLAGS="${FFLAGS} -mieee"
-cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_f77_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  eval "r_cv_prog_f77_flag_${ac_safe}=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	eval "r_cv_prog_f77_flag_${ac_safe}=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-FFLAGS="${r_save_FFLAGS}"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-fi
-
-if eval "test \"`echo '$r_cv_prog_f77_flag_'$ac_safe`\" = yes"; then
-  { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-  separator=""
-test -z "${separator}" && separator=" "
-if test -z "${R_XTRA_FFLAGS}"; then
-  R_XTRA_FFLAGS="-mieee"
-else
-  R_XTRA_FFLAGS="${R_XTRA_FFLAGS}${separator}-mieee"
-fi
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-    else
-      ac_safe=_fpe3
-{ echo "$as_me:$LINENO: checking whether ${F77} accepts -fpe3" >&5
-echo $ECHO_N "checking whether ${F77} accepts -fpe3... $ECHO_C" >&6; }
-if { as_var=r_cv_prog_f77_flag_${ac_safe}; eval "test \"\${$as_var+set}\" = set"; }; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-r_save_FFLAGS="${FFLAGS}"
-FFLAGS="${FFLAGS} -fpe3"
-cat >conftest.$ac_ext <<_ACEOF
-      program main
-
-      end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_f77_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  eval "r_cv_prog_f77_flag_${ac_safe}=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	eval "r_cv_prog_f77_flag_${ac_safe}=no"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-FFLAGS="${r_save_FFLAGS}"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-fi
-
-if eval "test \"`echo '$r_cv_prog_f77_flag_'$ac_safe`\" = yes"; then
-  { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-  separator=""
-test -z "${separator}" && separator=" "
-if test -z "${R_XTRA_FFLAGS}"; then
-  R_XTRA_FFLAGS="-fpe3"
-else
-  R_XTRA_FFLAGS="${R_XTRA_FFLAGS}${separator}-fpe3"
-fi
-else
-  { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
-fi
-
-    fi
     if test "${GXX}" = yes; then
       ac_safe=_mieee
 { echo "$as_me:$LINENO: checking whether ${CXX-c++} accepts -mieee" >&5
@@ -31027,7 +30889,7 @@ echo "$as_me: WARNING: Use of flat names
       SHLIB_LIBADD="-lcc_dynamic"
     fi
     ;;
-  freebsd*)
+  freebsd* | dragonfly*)
     ## Only sure for FreeBSD 3 and above.
     main_ldflags="-export-dynamic"
     shlib_ldflags="-shared"
@@ -31116,6 +30978,12 @@ echo "$as_me: WARNING: Use of flat names
     fcpicflags=
     ;;
   netbsd*)
+    fpicflags="-fPIC"
+    case "${host_cpu}" in
+      powerpc*)
+	cpicflags="-fPIC"
+	;;
+    esac
     if ${CPP} - -dM < /dev/null | grep __ELF__ >/dev/null ; then
       main_ldflags="-export-dynamic"
       shlib_ldflags="-shared"
@@ -31215,7 +31083,7 @@ fi
 : ${FPICFLAGS="${fpicflags}"}
 if test -z "${FPICFLAGS}"; then
   case "${host_os}" in
-    aix*|cygwin*|irix*|mingw*|osf*)
+    aix*|cygwin*|irix*|mingw*|osf*|darwin*)
       ;;
     *)
       { echo "$as_me:$LINENO: WARNING: I could not determine FPICFLAGS." >&5
@@ -37567,6 +37435,15 @@ cat > conftest.c <<EOF
 #endif
 extern void F77_SYMBOL(test1)(int *iflag);
 
+#ifdef F77_DUMMY_MAIN
+
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+
+#endif
+
 int main () {
   int iflag;
   F77_SYMBOL(test1)(&iflag);
@@ -37631,6 +37508,14 @@ else
 #else
 # define F77_SYMBOL(x)   x
 #endif
+#ifdef F77_DUMMY_MAIN
+
+#  ifdef __cplusplus
+     extern "C"
+#  endif
+   int F77_DUMMY_MAIN() { return 1; }
+
+#endif
 void F77_SYMBOL(xerbla)(char *srname, int *info)
 {}
 void blas_set () {
