@@ -800,6 +800,7 @@ if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
800800 ldflags_save=$LDFLAGS
801801 CFLAGS="$CFLAGS $perlcppflags"
802802 LIBS="$LIBS $perllibs"
803+ perlldflags=`echo "$perlldflags" | sed -e 's/^ *//g'`
803804 LDFLAGS="$perlldflags $LDFLAGS"
804805 AC_TRY_LINK(,[ ],
805806 AC_MSG_RESULT(yes); perl_ok=yes,
@@ -813,7 +814,9 @@ if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then
813814 PERL_CFLAGS=`echo "$perlcppflags" | sed -e 's/-pipe //' -e 's/-W[[^ ]]*//'`
814815 fi
815816 if test "X$perlldflags" != "X"; then
816- LDFLAGS="$perlldflags $LDFLAGS"
817+ if test "X`echo \"$LDFLAGS\" | grep -F -e \"$perlldflags\"`" = "X"; then
818+ LDFLAGS="$perlldflags $LDFLAGS"
819+ fi
817820 fi
818821 PERL_LIBS=$perllibs
819822 PERL_SRC="auto/if_perl.c if_perlsfio.c"
@@ -1582,7 +1585,9 @@ if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then
15821585 dnl configure, so strip these flags first (if present)
15831586 rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'`
15841587 if test "X$rubyldflags" != "X"; then
1585- LDFLAGS="$rubyldflags $LDFLAGS"
1588+ if test "X`echo \"$LDFLAGS\" | grep -F -e \"$rubyldflags\"`" = "X"; then
1589+ LDFLAGS="$rubyldflags $LDFLAGS"
1590+ fi
15861591 fi
15871592 fi
15881593 if test "X$rubyldflags" != "X"; then
@@ -2338,8 +2343,10 @@ if test -z "$SKIP_MOTIF"; then
23382343 dnl Remove "-L" from before $GUI_LIB_LOC if it's there
23392344 GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
23402345
2346+ dnl Ubuntu has libXm.so in /usr/lib/i386-linux-gnu and elsewhere. The
2347+ dnl linker will figure out which one to use, we only check if one exists.
23412348 AC_MSG_CHECKING(for location of Motif GUI libs)
2342- gui_libs="`echo $x_libraries|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC"
2349+ gui_libs="`echo $x_libraries|sed 's%/[^/][^/]*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC"
23432350 GUI_LIB_LOC=
23442351 for try in $gui_libs; do
23452352 for libtry in "$try"/libXm.a "$try"/libXm.so* "$try"/libXm.sl "$try"/libXm.dylib; do
@@ -2350,7 +2357,9 @@ if test -z "$SKIP_MOTIF"; then
23502357 done
23512358 if test -n "$GUI_LIB_LOC"; then
23522359 dnl Remove /usr/lib, it causes trouble on some systems
2353- if test "$GUI_LIB_LOC" = /usr/lib; then
2360+ if test "$GUI_LIB_LOC" = /usr/lib \
2361+ -o "$GUI_LIB_LOC" = /usr/lib/i386-linux-gnu \
2362+ -o "$GUI_LIB_LOC" = /usr/lib/x86_64-linux-gnu; then
23542363 GUI_LIB_LOC=
23552364 AC_MSG_RESULT(in default path)
23562365 else
@@ -3784,7 +3793,7 @@ if test "$GCC" = yes; then
37843793 dnl And undefine it first to avoid a warning.
37853794 AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
37863795 if test "$gccmajor" -gt "3"; then
3787- CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
3796+ CFLAGS=`echo "$CFLAGS" | sed -e 's/ * -Wp,-D_FORTIFY_SOURCE=.//g' -e 's/ * -D_FORTIFY_SOURCE=.//g' -e 's/ *-U_FORTIFY_SOURCE //g' -e 's/$/ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1/'`
37883797 AC_MSG_RESULT(yes)
37893798 else
37903799 AC_MSG_RESULT(no)
@@ -3799,7 +3808,7 @@ AC_MSG_CHECKING(linker --as-needed support)
37993808LINK_AS_NEEDED=
38003809# Check if linker supports --as-needed and --no-as-needed options
38013810if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
3802- LDFLAGS="$LDFLAGS - Wl,--as-needed"
3811+ LDFLAGS=`echo "$LDFLAGS" | sed -e 's/ *- Wl,--as-needed//g' | sed -e 's/$/ -Wl,--as-needed/'`
38033812 LINK_AS_NEEDED=yes
38043813fi
38053814if test "$LINK_AS_NEEDED" = yes; then
0 commit comments