* config/general.m4sh (Xsed): Set a default when not used from

ltmain.in.
(ECHO): Audit for (and correct!) uses of $ECHO with more than one
argument, which breaks when ECHO='printf %sn', and with possible
`-' as first character of the argument, which breaks `print -r'
and some implementations of `echo'.
* config/ltmain.in, tests/defs.in, libtoolize.in (ECHO): Ditto.
Reported by Albert Chin-A-Young <china@thewrittenword.com>
This commit is contained in:
Gary V. Vaughan 2004-09-24 16:08:33 +00:00
parent ea60dcd3ad
commit fc4e513ee0
5 changed files with 67 additions and 50 deletions

View File

@ -1,3 +1,14 @@
2004-09-24 Gary V. Vaughan <gary@gnu.org>
* config/general.m4sh (Xsed): Set a default when not used from
ltmain.in.
(ECHO): Audit for (and correct!) uses of $ECHO with more than one
argument, which breaks when ECHO='printf %s\n', and with possible
`-' as first character of the argument, which breaks `print -r'
and some implementations of `echo'.
* config/ltmain.in, tests/defs.in, libtoolize.in (ECHO): Ditto.
Reported by Albert Chin-A-Young <china@thewrittenword.com>
2004-09-24 Peter O'Gorman <peter@pogma.com>
* m4/libtool.m4 (_LT_CMD_STRIPLIB) [darwin]: strip archives too.

View File

@ -36,6 +36,7 @@ m4_if([# general.m4sh -- general shell script boiler plate -*- Autoconf -*-
: ${MV="mv -f"}
: ${RM="rm -f"}
: ${SED="@SED@"}
: ${Xsed="$SED -e s/^X//"}
# Global variables:
EXIT_SUCCESS=0
@ -60,12 +61,14 @@ basename="s,^.*/,,g"
progpath="$0"
# The name of this program:
progname=`$ECHO "$progpath" | $SED "$basename"`
# In the unlikely event $progname began with a '-', it would play havoc with
# func_echo (imagine progname=-n), so we substitute for _ in that case.
progname=`$ECHO "X$progpath" | $Xsed -e "$basename" -e 's,^-,_,'`
# Make sure we have an absolute path for reexecution:
case $progpath in
[[\\/]]*|[[A-Za-z]]:\\*) ;;
*) progdir=`$ECHO "$progpath" | $SED "$dirname"`
*) progdir=`$ECHO "X$progpath" | $Xsed -e "$dirname"`
progdir=`cd "$progdir" && pwd`
progpath="$progdir/$progname"
;;
@ -98,7 +101,7 @@ opt_verbose=false
# name if it has been set yet.
func_echo ()
{
$ECHO $progname${mode+: }$mode: ${1+"$@"}
$ECHO "$progname${mode+: }$mode: "${1+"$@"}
}
# func_verbose arg...
@ -112,14 +115,14 @@ func_verbose ()
# Echo program name prefixed message to standard error.
func_error ()
{
$ECHO $progname${mode+: }$mode: ${1+"$@"} 1>&2
$ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
}
# func_warning arg...
# Echo program name prefixed warning message to standard error.
func_warning ()
{
$ECHO $progname${mode+: }$mode: warning: ${1+"$@"} 1>&2
$ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
}
# func_fatal_error arg...
@ -173,9 +176,9 @@ func_mkdir_p ()
case $my_directory_path in */*) ;; *) break ;; esac
# ...otherwise throw away the child directory and loop
my_directory_path=`$ECHO "$my_directory_path" | $SED "$dirname"`
my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
done
my_dir_list=`$ECHO $my_dir_list | $SED 's,:*$,,'`
my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
save_mkdir_p_IFS="$IFS"; IFS=':'
for my_dir in $my_dir_list; do
@ -224,7 +227,7 @@ func_mktempdir ()
func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
fi
$ECHO "$my_tmpdir"
$ECHO "X$my_tmpdir" | $Xsed
}

View File

@ -491,22 +491,22 @@ Otherwise, only FILE itself is deleted using RM."
# Separate optargs to long options:
-dlopen=*|--mode=*|--tag=*)
arg=`$ECHO "$opt" | $SED "$my_sed_long_arg"`
opt=`$ECHO "$opt" | $SED "$my_sed_long_opt"`
arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`
opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`
set -- "$opt" "$arg" ${1+"$@"}
;;
# Separate optargs to short options:
# -x*|-y*)
# arg=`$ECHO "$opt" |$SED "$my_sed_single_rest"`
# opt=`$ECHO "$opt" |$SED "$my_sed_single_opt"`
# arg=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_rest"`
# opt=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_opt"`
# set -- "$opt" "$arg" ${1+"$@"}
# ;;
# Separate non-argument short options:
# -z*|-z*|-y*)
# rest=`$ECHO "$opt" |$SED "$my_sed_single_rest"`
# opt=`$ECHO "$opt" |$SED "$my_sed_single_opt"`
# rest=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_rest"`
# opt=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_opt"`
# set -- "$opt" "-$rest" ${1+"$@"}
# ;;
@ -762,7 +762,7 @@ extern \"C\" {
for dlprefile in $dlprefiles; do
func_echo "extracting global C symbols from \`$dlprefile'"
name=`$ECHO "$dlprefile" | ${SED} -e 's%^.*/%%'`
name=`$ECHO "X$dlprefile" | $Xsed -e 's%^.*/%%'`
$run eval '$ECHO ": $name " >> "$nlist"'
$run eval "$NM $dlprefile | $global_symbol_pipe >> '$nlist'"
done
@ -1579,7 +1579,7 @@ func_mode_finish ()
# Exit here if they wanted silent mode.
test "$show" = : && exit $EXIT_SUCCESS
$ECHO "----------------------------------------------------------------------"
$ECHO "X----------------------------------------------------------------------" | $Xsed
$ECHO "Libraries have been installed in:"
for libdir in $libdirs; do
$ECHO " $libdir"
@ -1612,7 +1612,7 @@ func_mode_finish ()
$ECHO
$ECHO "See any operating system documentation about shared libraries for"
$ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
$ECHO "----------------------------------------------------------------------"
$ECHO "X----------------------------------------------------------------------" | $Xsed
exit $EXIT_SUCCESS
}
@ -1783,7 +1783,7 @@ func_mode_install ()
if test -n "$relink_command"; then
# Determine the prefix the user has applied to our future dir.
inst_prefix_dir=`$ECHO "$destdir" | $SED "s%$libdir\$%%"`
inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
# Don't allow the user to place us outside of our expected
# location b/c this prevents finding dependent libraries that
@ -1917,7 +1917,7 @@ func_mode_install ()
case $file in
*.exe)
if test ! -f "$file"; then
file=`$ECHO $file|${SED} 's,.exe$,,'`
file=`$ECHO "X$file"| $Xsed -e 's,.exe$,,'`
stripped_ext=".exe"
fi
;;
@ -1926,7 +1926,7 @@ func_mode_install ()
# Do a test to see if this is really a libtool program.
case $host in
*cygwin*|*mingw*)
wrapper=`$ECHO $file | ${SED} -e 's,.exe$,,'`
wrapper=`$ECHO "X$file" | $XSED -e 's,.exe$,,'`
;;
*)
wrapper=$file
@ -2023,7 +2023,7 @@ func_mode_install ()
destfile=$destfile.exe
;;
*:*.exe)
destfile=`$ECHO $destfile | ${SED} -e 's,.exe$,,'`
destfile=`$ECHO "X$destfile" | $Xsed -e 's,.exe$,,'`
;;
esac
;;
@ -3050,7 +3050,7 @@ func_mode_link ()
# Collect preopened libtool deplibs, except any this library
# has declared as weak libs
for deplib in $dependency_libs; do
deplib_base=`$ECHO "$deplib" |$SED "$basename"`
deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
case " $weak_libs " in
*" $deplib_base "*) ;;
*) deplibs="$deplibs $deplib" ;;
@ -3222,8 +3222,7 @@ func_mode_link ()
match_pattern*)
set dummy $deplibs_check_method
match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
if eval $ECHO \"$deplib\" 2>/dev/null \
| $SED 10q \
if eval $ECHO \"X$deplib\" 2>/dev/null | $Xsed -e 10q \
| $EGREP "$match_pattern_regex" > /dev/null; then
valid_a_lib=yes
fi
@ -3616,8 +3615,8 @@ func_mode_link ()
# Make a new name for the extract_expsyms_cmds to use
soroot="$soname"
soname=`$ECHO $soroot | ${SED} -e 's/^.*\///'`
newlib="libimp-`$ECHO $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
soname=`$ECHO "X$soroot" | $Xsed -e 's/^.*\///'`
newlib=libimp-`$ECHO "X$soname" | $Xsed -e 's/^lib//;s/\.dll$//'`.a
# If the library has no export list, then create one now
if test -f "$output_objdir/$soname-def"; then :
@ -4386,9 +4385,9 @@ func_mode_link ()
# Eliminate all temporary directories.
for path in $notinst_path; do
lib_search_path=`$ECHO "$lib_search_path " | ${SED} -e 's% $path % %g'`
lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e 's% $path % %g'`
deplibs=`$ECHO "$deplibs " | ${SED} -e 's% -L$path % %g'`
dependency_libs=`$ECHO "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e 's% -L$path % %g'`
done
if test -n "$xrpath"; then
@ -4613,7 +4612,7 @@ EOF
esac
done
if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
${SED} 10q |
$SED -e 10q |
$EGREP "$file_magic_regex" > /dev/null; then
newdeplibs="$newdeplibs $a_deplib"
a_deplib=""
@ -4664,8 +4663,7 @@ EOF
potential_libs=`ls $i/$libname[[.-]]* 2>/dev/null`
for potent_lib in $potential_libs; do
potlib="$potent_lib" # see symlink-check above in file_magic test
if eval $ECHO \"$potent_lib\" 2>/dev/null |
${SED} 10q |
if eval $ECHO \"X$potent_lib\" 2>/dev/null | $Xsed -e 10q | \
$EGREP "$match_pattern_regex" > /dev/null; then
newdeplibs="$newdeplibs $a_deplib"
a_deplib=""
@ -4702,7 +4700,7 @@ EOF
if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
for i in $predeps $postdeps ; do
# can't use Xsed below, because $i might contain '/'
tmp_deplibs=`$ECHO "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
done
fi
if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[[ ]]//g' |
@ -4986,7 +4984,7 @@ EOF
save_libobjs=$libobjs
fi
save_output=$output
output_la=`$ECHO "$output" | $SED $basename`
output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
# Clear the reloadable object creation command queue and
# initialize k to one.
@ -5288,7 +5286,7 @@ EOF
prog)
case $host in
*cygwin*) output=`$ECHO $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
*cygwin*) output=`$ECHO "X$output" | $Xsed -e 's,.exe$,,;s,$,.exe,'` ;;
esac
test -n "$vinfo" && \
func_warning "\`-version-info' is ignored for programs"
@ -5576,21 +5574,21 @@ EOF
# win32 will think the script is a binary if it has
# a .exe suffix, so we strip it off here.
case $output in
*.exe) output=`$ECHO $output|${SED} 's,.exe$,,'` ;;
*.exe) output=`$ECHO "X$output" | $Xsed -e 's,.exe$,,'` ;;
esac
# test for cygwin because mv fails w/o .exe extensions
case $host in
*cygwin*)
exeext=.exe
outputname=`$ECHO $outputname|${SED} 's,.exe$,,'` ;;
outputname=`$ECHO "X$outputname" | $Xsed -e 's,.exe$,,'` ;;
*) exeext= ;;
esac
case $host in
*cygwin* | *mingw* )
output_name=`basename $output`
output_path=`dirname $output`
cwrappersource=`$ECHO "$output_path/$objdir/lt-$output_name.c"`
cwrapper=`$ECHO "$output_path/$output_name.exe"`
cwrappersource="$output_path/$objdir/lt-$output_name.c"
cwrapper="$output_path/$output_name.exe"
$RM $cwrappersource $cwrapper
trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
@ -6529,8 +6527,8 @@ func_mode_uninstall ()
noexename=$name
case $file in
*.exe)
file=`$ECHO $file|${SED} 's,.exe$,,'`
noexename=`$ECHO $name|${SED} 's,.exe$,,'`
file=`$ECHO "X$file" | $Xsed -e 's,.exe$,,'`
noexename=`$ECHO "X$name" | $Xsed -e 's,.exe$,,'`
# $file with .exe has already been added to rmfiles,
# add $file without .exe
rmfiles="$rmfiles $file"

View File

@ -146,15 +146,15 @@ configure_ac=configure.in
# Separate optargs to long options:
--ltdl=*)
arg=`$ECHO "$opt" | $SED "$my_sed_long_arg"`
opt=`$ECHO "$opt" | $SED "$my_sed_long_opt"`
arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`
opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`
set -- "$opt" "$arg" ${1+"$@"}
;;
# Separate non-argument short options:
-c*|-i*|-f*|-n*|-q*|-v*)
rest=`$ECHO "$opt" |$SED "$my_sed_single_rest"`
opt=`$ECHO "$opt" |$SED "$my_sed_single_opt"`
rest=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_rest"`
opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_opt"`
set -- "$opt" "-$rest" ${1+"$@"}
;;
@ -178,7 +178,7 @@ func_copy ()
my_destfile="$2"
my_return_status=1
func_mkdir_p `$ECHO "$my_destfile" | $SED "$dirname"`
func_mkdir_p `$ECHO "X$my_destfile" | $Xsed -e "$dirname"`
$RM "$my_destfile"
if $opt_link && $LN_S "$my_srcfile" "$my_destfile"; then
@ -224,8 +224,8 @@ func_copy_all_files ()
while test -n "$my_srcdirs"; do
IFS="$my_save_IFS"
my_srcdir=`$ECHO "$my_srcdirs" | sed 's,:.*,,g'`
my_srcdirs=`$ECHO "$my_srcdirs" | sed 's,:*[[^:]][[^:]]*:*,,'`
my_srcdir=`$ECHO "X$my_srcdirs" | $Xsed -e 's,:.*,,g'`
my_srcdirs=`$ECHO "X$my_srcdirs" | $Xsed -e 's,:*[[^:]][[^:]]*:*,,'`
for my_filename in `cd "$my_srcdir" && ls`; do
@ -236,7 +236,8 @@ func_copy_all_files ()
# Add to the appropriate list
if test -f "$my_srcdir/$my_filename"; then
my_srcfile=`$ECHO "$my_srcdir/$my_filename" |sed "s,^$my_basedir/*,,"`
my_srcfile=`$ECHO "X$my_srcdir/$my_filename" | $Xsed \
-e "s,^$my_basedir/*,,"`
my_srcfiles="$my_srcfiles${my_srcfiles:+:}$my_srcfile"
elif $my_opt_recurse && test -d "$my_srcdir/$my_filename"; then
my_srcdirs="$my_srcdirs${my_srcdirs:+:}$my_srcdir/$my_filename"
@ -403,7 +404,9 @@ func_included_files ()
/^[m4]_include(\[[.*\]])$/ { s,^[m4]_include(\[[\(.*\)\]])$,\1,; p; };
d'
test -f "$my_searchfile" && $ECHO "$my_searchfile"
if test -f "$my_searchfile"; then
$ECHO "X$my_searchfile" | $Xsed
fi
# Only recurse when we don't care if all the variables we use get
# trashed, since they are in global scope.

View File

@ -34,6 +34,8 @@ m4_include([general.m4sh])
: ${LIBTOOL="../libtool"}
: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
# Sed that helps us avoid accidentally triggering echo(1) options like -n.
Xsed="$SED -e s/^X//"
# Disable usage of config.site for autoconf, unless DJGPP is present.
# The DJGPP port of autoconf requires config.site, to work correctly.
@ -50,7 +52,7 @@ NO | no | 0 | "")
esac
if test -z "$srcdir"; then
srcdir=`$ECHO "$0" | $SED "$dirname"`
srcdir=`$ECHO "X$0" | $Xsed -e "$dirname"`
test "$srcdir" = "$0" && srcdir=.
fi