$NetBSD: patch-configure,v 1.4 2018/11/28 01:31:45 sevan Exp $

builtin krb5-config in platforms such as solaris do not support
the gssapi option, and need an explicit -lgss

On Darwin, do not append custom CFLAGS.

Do not strip debug flags.

Support Minix.

--- configure.orig	Wed Nov 28 00:16:07 2018
+++ configure
@@ -3744,6 +3744,7 @@ $as_echo "$as_me: $xc_bad_var_msg libraries. Use LIBS 
         ;;
     esac
   done
+  xc_bad_var_cflags=no
   if test $xc_bad_var_cflags = yes; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: using CFLAGS: $CFLAGS" >&5
 $as_echo "$as_me: using CFLAGS: $CFLAGS" >&6;}
@@ -8089,7 +8090,7 @@ else
     lt_cv_sys_max_cmd_len=8192;
     ;;
 
-  bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
+  bitrig* | darwin* | dragonfly* | freebsd* | minix* | netbsd* | openbsd*)
     # This has been around since 386BSD, at least.  Likely further.
     if test -x /sbin/sysctl; then
       lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -8555,12 +8556,8 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
   lt_cv_deplibs_check_method=pass_all
   ;;
 
-netbsd* | netbsdelf*-gnu)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
-  fi
+netbsd* | netbsdelf*-gnu | minix*)
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
   ;;
 
 newos6*)
@@ -12761,14 +12758,13 @@ _LT_EOF
       fi
       ;;
 
-    netbsd* | netbsdelf*-gnu)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
+    netbsd* | netbsdelf*-gnu | minix*)
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      output_verbose_link_cmd=func_echo_all
       ;;
 
     solaris*)
@@ -13451,15 +13447,13 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
       esac
       ;;
 
-    netbsd* | netbsdelf*-gnu)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec='-R$libdir'
+    netbsd* | netbsdelf*-gnu | minix*)
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
       hardcode_direct=yes
       hardcode_shlibpath_var=no
+      output_verbose_link_cmd=func_echo_all
       ;;
 
     newsos6)
@@ -14565,6 +14559,18 @@ fi
   dynamic_linker='GNU/Linux ld.so'
   ;;
 
+minix*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Minix ld.elf_so'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
 netbsdelf*-gnu)
   version_type=linux
   need_lib_prefix=no
@@ -17079,7 +17085,7 @@ squeeze() {
 
 
       #
-  if test "$compiler_id" != "unknown"; then
+  if false; then
     #
     if test "$compiler_id" = "GNU_C" ||
       test "$compiler_id" = "CLANG"; then
@@ -17407,13 +17413,6 @@ $as_echo_n "checking if compiler accepts debug disabli
       tmp_options="$flags_dbg_off"
     fi
     #
-    if test "$flags_prefer_cppflags" = "yes"; then
-      CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
-      CFLAGS="$tmp_CFLAGS"
-    else
-      CPPFLAGS="$tmp_CPPFLAGS"
-      CFLAGS="$tmp_CFLAGS $tmp_options"
-    fi
     squeeze CPPFLAGS
     squeeze CFLAGS
 
@@ -19081,7 +19080,7 @@ $as_echo "no" >&6; }
   tst_cflags="no"
   case $host_os in
     darwin*)
-      tst_cflags="yes"
+      tst_cflags="no"
       ;;
   esac
 
@@ -22013,7 +22012,11 @@ $as_echo "yes" >&6; }
      if test -n "$host_alias" -a -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then
         GSSAPI_INCS=`$GSSAPI_ROOT/bin/$host_alias-krb5-config --cflags gssapi`
      elif test -f "$KRB5CONFIG"; then
-        GSSAPI_INCS=`$KRB5CONFIG --cflags gssapi`
+        if `$KRB5CONFIG --cflags gssapi` 2>&1 | grep "Unknown option" >/dev/null; then
+           GSSAPI_INCS=`$KRB5CONFIG --cflags`
+        else
+           GSSAPI_INCS=`$KRB5CONFIG --cflags gssapi`
+        fi
      elif test "$GSSAPI_ROOT" != "yes"; then
         GSSAPI_INCS="-I$GSSAPI_ROOT/include"
      fi
@@ -22186,7 +22189,7 @@ $as_echo "#define HAVE_GSSAPI 1" >>confdefs.h
         LIBS="-lgss $LIBS"
         ;;
      *)
-        LIBS="-lgssapi $LIBS"
+        LIBS="-lgssapi -lkrb5 $LIBS"
         ;;
      esac
   fi
