$NetBSD: patch-ac,v 1.15 2004/12/21 13:50:25 grant Exp $ --- ltmain.sh.orig 2004-09-19 22:34:44.000000000 +1000 +++ ltmain.sh @@ -184,6 +184,31 @@ func_win32_libid () { # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { + # Set the commonly-used compilers for some tags. + tag_compilers_CC="*cc *xlc" + tag_compilers_CXX="*++ *CC" + tag_compilers_F77="*77 *fort" + base_compiler=`set -- "$@"; $echo $1` + # If $tagname still isn't set, then try to infer if the default + # "CC" tag applies by matching up the base compile command to some + # compilers commonly used for the "CC" tag. + if test -z "$tagname"; then + z=CC + eval "tag_compilers=\$tag_compilers_${z}" + if test -n "$tag_compilers"; then + for zp in $tag_compilers; do + case $base_compiler in + $zp) + # The compiler in the base compile command matches + # one of the common compilers for the current tag. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + done + fi + fi if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do @@ -224,6 +249,27 @@ func_infer_tag () { break ;; esac + # If $tagname still isn't set, then try to infer it by + # matching up the base compile command to some compilers + # commonly used for certain tags. + base_compiler=`set -- "$@"; $echo $1` + eval "tag_compilers=\$tag_compilers_${z}" + if test -n "$tag_compilers"; then + for zp in $tag_compilers; do + case $base_compiler in + $zp) + # The compiler in the base compile command matches + # one of the common compilers for the current tag. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + done + if test -n "$tagname"; then + break + fi + fi fi done # If $tagname still isn't set, then no tagged configuration @@ -522,7 +568,7 @@ if test -z "$show_help"; then $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2 case $nonopt in - *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) + *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc* | *CC) mode=link for arg do @@ -1306,6 +1352,13 @@ EOF exit $EXIT_FAILURE ;; esac + # Canonicalise the pathname + tmp="" + while test "$arg" != "$tmp" + do + tmp=$arg + arg=`$echo "X$arg" | $Xsed -e 's%[^/.][^/.]*/\.\.%%g' -e 's%/\./%/%g' -e 's%//*%/%g' -e 's%/$%%g'` + done if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; @@ -1466,7 +1519,7 @@ EOF # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; @@ -1477,7 +1530,7 @@ EOF esac elif test "X$arg" = "X-lc_r"; then case $host in - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; @@ -3063,7 +3116,7 @@ EOF age="$number_minor" revision="$number_revision" ;; - freebsd-aout|freebsd-elf|sunos) + freebsd-aout|freebsd-elf|dragonfly|sunos) current="$number_major" revision="$number_minor" age="0" @@ -3143,6 +3196,11 @@ EOF versuffix=".$current"; ;; + dragonfly) + major=".$current" + versuffix=".$current" + ;; + irix | nonstopux) major=`expr $current - $age + 1` @@ -3168,6 +3226,7 @@ EOF linux) major=.`expr $current - $age` versuffix="$major.$age.$revision" + versuffix2="$major.$age" ;; osf) @@ -3336,7 +3395,7 @@ EOF *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; @@ -5364,8 +5423,16 @@ relink_command=\"$relink_command\"" exit $EXIT_FAILURE fi - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + # Canonicalise the pathname: + # - remove foo/../ + # - replace // + # - remove /./ + # - strip any trailing / + tmp="" + while test "$dest" != "$tmp"; do + tmp=$dest + dest=`$echo "X$dest" | $Xsed -e 's%[^/.][^/.]*/\.\.%%g' -e 's%/\./%/%g' -e 's%//*%/%g' -e 's%/$%%g'` + done # Check to see that the destination is a directory. test -d "$dest" && isdir=yes