$NetBSD: patch-ac,v 1.15 2005/12/01 23:11:26 joerg Exp $

--- configure.orig	2005-06-20 09:02:39.000000000 +0000
+++ configure
@@ -2173,7 +2173,7 @@ else
 fi
 
 if test "${want_R_shlib}" = yes; then
-  LIBR="-L\$(R_HOME)/lib -lR"
+  LIBR="-Wl,-R${prefix}/lib/R/lib -L\$(R_HOME)/lib -lR"
 else
   LIBR=
 fi
@@ -6413,7 +6413,7 @@ darwin* | rhapsody*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-freebsd* | kfreebsd*-gnu)
+freebsd* | kfreebsd*-gnu | dragonfly*)
   if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
     case $host_cpu in
     i*86 )
@@ -8934,7 +8934,7 @@ if test -z "$aix_libpath"; then aix_libp
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu)
+    freebsd* | kfreebsd*-gnu | dragonfly*)
       archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec='-R$libdir'
       hardcode_direct=yes
@@ -9512,7 +9512,7 @@ kfreebsd*-gnu)
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd*)
+freebsd* | dragonfly*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -11892,7 +11892,7 @@ if test -z "$aix_libpath"; then aix_libp
   freebsd-elf*)
     archive_cmds_need_lc_CXX=no
     ;;
-  freebsd* | kfreebsd*-gnu)
+  freebsd* | kfreebsd*-gnu | dragonfly*)
     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
     # conventions
     ld_shlibs_CXX=yes
@@ -12599,7 +12599,7 @@ echo $ECHO_N "checking for $compiler opt
 	    ;;
 	esac
 	;;
-      freebsd* | kfreebsd*-gnu)
+      freebsd* | kfreebsd*-gnu | dragonfly*)
 	# FreeBSD uses GNU C++
 	;;
       hpux9* | hpux10* | hpux11*)
@@ -13210,7 +13210,7 @@ kfreebsd*-gnu)
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd*)
+freebsd* | dragonfly*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -15781,7 +15781,7 @@ if test -z "$aix_libpath"; then aix_libp
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu)
+    freebsd* | kfreebsd*-gnu | dragonfly*)
       archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec_F77='-R$libdir'
       hardcode_direct_F77=yes
@@ -16359,7 +16359,7 @@ kfreebsd*-gnu)
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd*)
+freebsd* | dragonfly*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -18128,7 +18128,7 @@ if test -z "$aix_libpath"; then aix_libp
       ;;
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | kfreebsd*-gnu)
+    freebsd* | kfreebsd*-gnu | dragonfly*)
       archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
       hardcode_libdir_flag_spec_GCJ='-R$libdir'
       hardcode_direct_GCJ=yes
@@ -18706,7 +18706,7 @@ kfreebsd*-gnu)
   dynamic_linker='GNU ld.so'
   ;;
 
-freebsd*)
+freebsd* | dragonfly*)
   objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
   version_type=freebsd-$objformat
   case $version_type in
@@ -21697,13 +21697,13 @@ fi
     ## only need ncurses if libreadline is not statically linked against it
     unset ac_cv_lib_readline_rl_callback_read_char
 
-echo "$as_me:$LINENO: checking for main in -lncurses" >&5
-echo $ECHO_N "checking for main in -lncurses... $ECHO_C" >&6
-if test "${ac_cv_lib_ncurses_main+set}" = set; then
+echo "$as_me:$LINENO: checking for main in -ltermcap" >&5
+echo $ECHO_N "checking for main in -ltermcap... $ECHO_C" >&6
+if test "${ac_cv_lib_termcap_main+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-lncurses  $LIBS"
+LIBS="-ltermcap  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -21742,35 +21742,35 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_ncurses_main=yes
+  ac_cv_lib_termcap_main=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_ncurses_main=no
+ac_cv_lib_termcap_main=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_main" >&5
-echo "${ECHO_T}$ac_cv_lib_ncurses_main" >&6
-if test $ac_cv_lib_ncurses_main = yes; then
+echo "$as_me:$LINENO: result: $ac_cv_lib_termcap_main" >&5
+echo "${ECHO_T}$ac_cv_lib_termcap_main" >&6
+if test $ac_cv_lib_termcap_main = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBNCURSES 1
+#define HAVE_LIBTERMCAP 1
 _ACEOF
 
-  LIBS="-lncurses $LIBS"
+  LIBS="-ltermcap $LIBS"
 
 else
 
-echo "$as_me:$LINENO: checking for main in -ltermcap" >&5
-echo $ECHO_N "checking for main in -ltermcap... $ECHO_C" >&6
-if test "${ac_cv_lib_termcap_main+set}" = set; then
+echo "$as_me:$LINENO: checking for main in -ltermlib" >&5
+echo $ECHO_N "checking for main in -ltermlib... $ECHO_C" >&6
+if test "${ac_cv_lib_termlib_main+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltermcap  $LIBS"
+LIBS="-ltermlib  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -21809,35 +21809,35 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_termcap_main=yes
+  ac_cv_lib_termlib_main=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_termcap_main=no
+ac_cv_lib_termlib_main=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_termcap_main" >&5
-echo "${ECHO_T}$ac_cv_lib_termcap_main" >&6
-if test $ac_cv_lib_termcap_main = yes; then
+echo "$as_me:$LINENO: result: $ac_cv_lib_termlib_main" >&5
+echo "${ECHO_T}$ac_cv_lib_termlib_main" >&6
+if test $ac_cv_lib_termlib_main = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBTERMCAP 1
+#define HAVE_LIBTERMLIB 1
 _ACEOF
 
-  LIBS="-ltermcap $LIBS"
+  LIBS="-ltermlib $LIBS"
 
 else
 
-echo "$as_me:$LINENO: checking for main in -ltermlib" >&5
-echo $ECHO_N "checking for main in -ltermlib... $ECHO_C" >&6
-if test "${ac_cv_lib_termlib_main+set}" = set; then
+echo "$as_me:$LINENO: checking for main in -lncurses" >&5
+echo $ECHO_N "checking for main in -lncurses... $ECHO_C" >&6
+if test "${ac_cv_lib_ncurses_main+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltermlib  $LIBS"
+LIBS="-lncurses  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -21876,25 +21876,25 @@ if { (eval echo "$as_me:$LINENO: \"$ac_l
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_termlib_main=yes
+  ac_cv_lib_ncurses_main=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_termlib_main=no
+ac_cv_lib_ncurses_main=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_termlib_main" >&5
-echo "${ECHO_T}$ac_cv_lib_termlib_main" >&6
-if test $ac_cv_lib_termlib_main = yes; then
+echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_main" >&5
+echo "${ECHO_T}$ac_cv_lib_ncurses_main" >&6
+if test $ac_cv_lib_ncurses_main = yes; then
   cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBTERMLIB 1
+#define HAVE_LIBNCURSES 1
 _ACEOF
 
-  LIBS="-ltermlib $LIBS"
+  LIBS="-lncurses $LIBS"
 
 fi
 
@@ -27065,6 +27065,7 @@ cat > conftest.c <<EOF
 #else
 # define F77_SYMBOL(x)   x
 #endif
+int MAIN__ () { return 0; }
 int main () {
   exit(0);
 }
@@ -27133,6 +27134,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];
@@ -27221,6 +27225,9 @@ typedef struct {
 
 extern void F77_SYMBOL(cftest)(Rcomplex *x);
 
+int MAIN_ () { return 0; }
+int MAIN__ () { return 0; }
+
 int main () {
     Rcomplex z[3];
 
@@ -28047,157 +28054,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 eval "test \"\${r_cv_prog_f77_flag_${ac_safe}+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 { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&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); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; 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 conftest.err conftest.$ac_objext \
-      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 eval "test \"\${r_cv_prog_f77_flag_${ac_safe}+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 { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&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); } &&
-	 { ac_try='test -z "$ac_f77_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; 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 conftest.err conftest.$ac_objext \
-      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
@@ -29093,7 +28949,7 @@ fi ;;
       SHLIB_LIBADD="-lcc_dynamic"
     fi
     ;;
-  freebsd*)
+  freebsd* | dragonfly*)
     ## Only sure for FreeBSD 3 and above.
     main_ldflags="-export-dynamic"
     shlib_ldflags="-shared"
@@ -29151,6 +29007,7 @@ fi ;;
     fpicflags=
     ;;
   netbsd*)
+    fpicflags="-fPIC"
     if ${CPP} - -dM < /dev/null | grep __ELF__ >/dev/null ; then
       main_ldflags="-export-dynamic"
       shlib_ldflags="-shared"
