--- origsrc/perl-5.22.1/Configure.orig
+++ src/perl-5.22.1/Configure
@@ -4967,18 +4967,21 @@
 case "$ccname" in
     gcc)
 	$echo 'extern int foo;' > try.c
-	set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'`
+	set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include$'`
 	shift
 	if $test $# -gt 0; then
 	    incpth="$incpth $*"
 	    incpth="`$echo $incpth|$sed 's/^ //'`"
-	    for i in $*; do
-		j="`$echo $i|$sed 's,/include$,/lib,'`"
-		if $test -d $j; then
-		    libpth="$libpth $j"
-		fi
-	    done
-	    libpth="`$echo $libpth|$sed 's/^ //'`"
+	   for i in $*; do
+	       j="`$echo $i|$sed 's,/include$,/lib,'`"
+	       if $test -d $j; then
+		   case " $libpth " in
+		   *" $j "*) ;;
+		   *) libpth="$libpth $j";;
+		   esac
+	       fi
+	   done
+	   libpth="`$echo $libpth|$sed 's/^ //'`"
 	    for xxx in $libpth $loclibpth $plibpth $glibpth; do
 		if $test -d $xxx; then
 		    case " $libpth " in
