$NetBSD: patch-ca,v 1.7 2009/12/14 06:36:57 seb Exp $

--- Configure.orig	2009-12-06 17:23:10.000000000 +0000
+++ Configure	2009-12-06 17:51:02.000000000 +0000
@@ -3233,13 +3233,14 @@
 			osvers="$3"
 			;;
 		dragonfly) osname=dragonfly
-			osvers="$3"
+			osvers=`$uname -r | UU/tr '[A-Z]' '[a-z]'`
 			;;
 		dynixptx*) osname=dynixptx
 			osvers=`echo "$4"|sed 's/^v//'`
 			;;
 		freebsd) osname=freebsd
-			osvers="$3" ;;
+			osvers=`$uname -r | UU/tr '[A-Z]' '[a-z]'`
+			;;
 		genix)	osname=genix ;;
 		gnu)	osname=gnu
 			osvers="$3" ;;
@@ -3261,7 +3262,7 @@
 		MiNT)	osname=mint
 			;;
 		netbsd*) osname=netbsd
-			osvers="$3"
+			osvers=`$uname -r | UU/tr '[A-Z]' '[a-z]'`
 			;;
 		news-os) osvers="$3"
 			case "$3" in
@@ -3272,7 +3273,7 @@
 		next*) osname=next ;;
 		nonstop-ux) osname=nonstopux ;;
 		openbsd) osname=openbsd
-                	osvers="$3"
+                	osvers=`$uname -r | UU/tr '[A-Z]' '[a-z]'`
                 	;;
 		os2)	osname=os2
 			osvers="$4"
@@ -4772,7 +4773,7 @@
 esac
 case "$libpth" in
 ' ') dlist='';;
-'') dlist="$loclibpth $plibpth $glibpth";;
+'') dlist="$plibpth $glibpth $loclibpth";;
 *) dlist="$libpth";;
 esac
 
@@ -6503,7 +6504,9 @@
 . ./getfile
 prefixvar=sitelib
 . ./setprefixvar
-sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
+if $test -z "$sitelib_stem"; then
+	sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
+fi
 
 : Determine list of previous versions to include in @INC
 $cat > getverlist <<EOPL
@@ -7015,7 +7018,9 @@
 	vendorlibexp="$ansexp"
 	;;
 esac
-vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
+if $test -z "$vendorlib_stem"; then
+	vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
+fi
 prefixvar=vendorlib
 . ./installprefix
 
@@ -9381,6 +9386,13 @@
 	;;
 esac
 
+: Look for a hint-file generated 'call-back-unit'.  We need
+: to set some defaults for building perl in pkgsrc.
+if $test -f pkgsrc.cbu; then
+	echo "Setting pkgsrc-specific hints regarding compiler/linker flags..."
+	. ./pkgsrc.cbu
+fi
+
 : Set the vendorbin variables
 case "$vendorprefix" in
 '')	d_vendorbin="$undef"
@@ -18816,7 +18828,15 @@
 ACAT(Cir,cus)
 EOCP
 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
-if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
+# yuck, what a hack.
+# MIPSPro compiler/preprocessor behaves differently if invoked on
+# stdin vs file.  Here we test for stdin, but lateron we use files.
+# So force it to work the way we know it does:
+if [ x"${OPSYS}" = x"IRIX" ]; then
+	echo "Hacking MIPSPro on file vs. stdin..." >&4
+	echo "We know we can catify or stringify, separately or together!"
+	cpp_stuff=42
+elif $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
 	echo "Oh!  Smells like ANSI's been here." >&4
 	echo "We can catify or stringify, separately or together!"
 	cpp_stuff=42
