From: Gary V. Vaughan Date: Thu, 31 Aug 2000 17:23:44 +0000 (+0000) Subject: Move the echo detection code to a macro in libtool.m4. The code X-Git-Tag: release-1-3d~137 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0e072fa33ed51157c6c33462f25200e447994fad;p=thirdparty%2Flibtool.git Move the echo detection code to a macro in libtool.m4. The code at the top ofltconfig.in is ugly, but will go away when the rest of ltconfig is migrated. * Makefile.am (libtool): Pass the value of $ECHO to ltconfig as an environment variable. * libtool.m4 (_LT_AC_PROG_ECHO_BACKSLASH): Quote the ECHO value correctly so that it inserts the correct code into configure.in suitably quoted for M4 expansion. This code needs to be near the top of configure.in as it calls itself recursively, so I am using AC_DIVERSION_NOTICE (or simply NOTICE on CVS Autoconf). The value of ECHO is also substitued into the Makefile to be used when Make calls ltconfig to generate libtool, so another layer of quotation is required for the Makefile. (AC_LIBTOOL_SETUP): Use it. * ltconfig.in: Accept a value for ECHO from the environment, and carefully substitue for $0 if it is present in the ECHO value. Because ECHO was quoted for Make, when ltconfig is called by configure, it is overquoted, and one layer of quotes must be stripped. --- diff --git a/ChangeLog b/ChangeLog index 942126c1d..7c8ccdbbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2000-08-31 Gary V. Vaughan + + Move the echo detection code to a macro in libtool.m4. The code + at the top ofltconfig.in is ugly, but will go away when the rest + of ltconfig is migrated. + + * Makefile.am (libtool): Pass the value of $ECHO to ltconfig as + an environment variable. + * libtool.m4 (_LT_AC_PROG_ECHO_BACKSLASH): Quote the ECHO value + correctly so that it inserts the correct code into configure.in + suitably quoted for M4 expansion. This code needs to be near + the top of configure.in as it calls itself recursively, so I + am using AC_DIVERSION_NOTICE (or simply NOTICE on CVS + Autoconf). The value of ECHO is also substitued into the + Makefile to be used when Make calls ltconfig to generate + libtool, so another layer of quotation is required for the + Makefile. + (AC_LIBTOOL_SETUP): Use it. + * ltconfig.in: Accept a value for ECHO from the environment, and + carefully substitue for $0 if it is present in the ECHO value. + Because ECHO was quoted for Make, when ltconfig is called by + configure, it is overquoted, and one layer of quotes must be + stripped. + 2000-08-27 Gary V. Vaughan * ltconfig.in (with_gcc): Make the value of this option diff --git a/Makefile.am b/Makefile.am index 7b5dc8aba..5bd773dd4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,7 +32,7 @@ libtool: $(srcdir)/ltmain.sh $(srcdir)/ltconfig AR="$(AR)" CC="$(CC)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \ MAGIC="$(MAGIC)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" \ LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" STRIP="$(STRIP)" \ - AS="$(AS)" DLLTOOL="$(DLLTOOL)" OBJDUMP="$(OBJDUMP)" \ + AS="$(AS)" DLLTOOL="$(DLLTOOL)" OBJDUMP="$(OBJDUMP)" ECHO="$(ECHO)" \ objext="$(OBJEXT)" exeext="$(EXEEXT)" reload_flag="$(reload_flag)" \ deplibs_check_method="$(deplibs_check_method)" file_magic_cmd="$(file_magic_cmd)" \ $(SHELL) $(srcdir)/ltconfig $(LIBTOOL_FLAGS) --srcdir=$(srcdir) \ @@ -43,7 +43,7 @@ clibtool: $(srcdir)/ltmain.c $(srcdir)/ltconfig AR="$(AR)" CC="$(CC)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \ MAGIC="$(MAGIC)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" \ LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" STRIP="$(STRIP)" \ - AS="$(AS)" DLLTOOL="$(DLLTOOL)" OBJDUMP="$(OBJDUMP)" \ + AS="$(AS)" DLLTOOL="$(DLLTOOL)" OBJDUMP="$(OBJDUMP)" ECHO="$(ECHO)" \ objext="$(objext)" exeext="$(exeext)" reload_flag="$(reload_flag)" \ deplibs_check_method="$(deplibs_check_method)" file_magic_cmd="$(file_magic_cmd)" \ $(SHELL) $(srcdir)/ltconfig $(LIBTOOL_FLAGS) --srcdir=$(srcdir) \ diff --git a/libtool.m4 b/libtool.m4 index 4ca45fc26..86184866b 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -33,7 +33,7 @@ AC_CACHE_SAVE AR="$AR" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ MAGIC="$MAGIC" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \ -AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \ +AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" ECHO="$ECHO" \ objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \ deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ @@ -72,6 +72,8 @@ AC_REQUIRE([AC_OBJEXT])dnl AC_REQUIRE([AC_EXEEXT])dnl dnl +_LT_AC_PROG_ECHO_BACKSLASH + # Only perform the check for file, if the check method requires it case "$deplibs_check_method" in file_magic*) @@ -176,6 +178,179 @@ ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], esac ]) +# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR +# --------------------------------- +AC_DEFUN([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR], +[# Find the correct PATH separator. Usually this is `:', but +# DJGPP uses `;' like DOS. +if test "X${PATH_SEPARATOR+set}" != Xset; then + UNAME=${UNAME-`uname 2>/dev/null`} + case X$UNAME in + *-DOS) lt_cv_sys_path_separator=';' ;; + *) lt_cv_sys_path_separator=':' ;; + esac +fi +])# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn;t interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case "X$ECHO" in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +lt_echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($lt_echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $lt_echo works! + : +else + # Restart under the correct shell. + exec "$SHELL" "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null && + lt_echo_test_string="`eval $cmd`" && + (test "X$lt_echo_test_string" = "X$lt_echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($lt_echo '\t') 2>/dev/null`" = 'X\t' && + lt_echo_testing_string=`($lt_echo "$lt_echo_test_string") 2>/dev/null` && + test "X$lt_echo_testing_string" = "X$lt_echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH /usr/ucb; do + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + lt_echo_testing_string=`($dir/echo "$lt_echo_test_string") 2>/dev/null` && + test "X$lt_echo_testing_string" = "X$lt_echo_test_string"; then + lt_echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$lt_echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + lt_echo_testing_string=`(print -r "$lt_echo_test_string") 2>/dev/null` && + test "X$lt_echo_testing_string" = "X$lt_echo_test_string"; then + # This shell has a builtin print -r that does the trick. + lt_echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running ltconfig again with it. + ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}" + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec "$CONFIG_SHELL" "[$]0" --no-reexec ${1+"$@"} + else + # Try using printf. + lt_echo='printf %s\n' + if test "X`($lt_echo '\t') 2>/dev/null`" = 'X\t' && + lt_echo_testing_string=`($lt_echo "$lt_echo_test_string") 2>/dev/null` && + test "X$lt_echo_testing_string" = "X$lt_echo_test_string"; then + # Cool, printf works + : + elif lt_echo_testing_string=`("$ORIGINAL_CONFIG_SHELL" "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$lt_echo_testing_string" = 'X\t' && + lt_echo_testing_string=`("$ORIGINAL_CONFIG_SHELL" "[$]0" --fallback-echo "$lt_echo_test_string") 2>/dev/null` && + test "X$lt_echo_testing_string" = "X$lt_echo_test_string"; then + CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL" + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + lt_echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif lt_echo_testing_string=`("$CONFIG_SHELL" "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$lt_echo_testing_string" = 'X\t' && + lt_echo_testing_string=`("$CONFIG_SHELL" "[$]0" --fallback-echo "$lt_echo_test_string") 2>/dev/null` && + test "X$lt_echo_testing_string" = "X$lt_echo_test_string"; then + lt_echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$lt_echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + lt_echo_test_string=`eval $prev` + export lt_echo_test_string + exec "${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}}" "[$]0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + lt_echo=echo + fi + fi + fi + fi +fi +fi + +# Copy lt_echo and quote the copy suitably for passing to ltconfig from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$lt_echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +AC_DIVERT_POP +])# _LT_AC_PROG_ECHO_BACKSLASH + + # AC_LIBTOOL_DLOPEN - enable checks for dlopen support AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) diff --git a/ltconfig.in b/ltconfig.in index 76e6558aa..ba1bac024 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -27,7 +27,15 @@ # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} -echo=echo + +case "X$ECHO" in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0',;s,\\$0,'$0','` + ;; +esac + +echo=${ECHO-echo} if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift @@ -65,6 +73,7 @@ fi # if CDPATH is set. if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi +if test -z "$ECHO"; then if test "X${echo_test_string+set}" != Xset; then # find a string as large as possible, as long as the shell can cope with it for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do @@ -160,6 +169,7 @@ else fi fi fi +fi # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. @@ -233,6 +243,7 @@ old_DLLTOOL="$DLLTOOL" old_OBJDUMP="$OBJDUMP" old_OBJEXT="$OBJEXT" old_EXEEXT="$EXEEXT" +old_echo="$echo" old_reload_flag="$reload_flag" old_deplibs_check_method="$deplibs_check_method" old_file_magic_cmd="$file_magic_cmd" @@ -1897,7 +1908,6 @@ EOF # Now try to grab the symbols. nlist=conftest.nm if { echo "$progname:@LINENO@: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then - # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -2547,7 +2557,7 @@ case "$ltmain" in old_MAGIC old_LD old_LDFLAGS old_LIBS \ old_LN_S old_NM old_RANLIB old_STRIP \ old_AS old_DLLTOOL old_OBJDUMP \ - old_OBJEXT old_EXEEXT old_reload_flag \ + old_OBJEXT old_EXEEXT old_echo old_reload_flag \ old_deplibs_check_method old_file_magic_cmd \ AR AR_FLAGS CC LD LN_S NM LTSHELL LTCONFIG_VERSION \ reload_flag reload_cmds wl \ @@ -2636,7 +2646,7 @@ EOF old_MAGIC old_LD old_LDFLAGS old_LIBS \ old_LN_S old_NM old_RANLIB old_STRIP \ old_AS old_DLLTOOL old_OBJDUMP \ - old_OBJEXT old_EXEEXT old_reload_flag \ + old_OBJEXT old_EXEEXT old_echo old_reload_flag \ old_deplibs_check_method old_file_magic_cmd; do eval "$var=\\\"\$var\\\"" done @@ -2660,8 +2670,8 @@ cat <> "$cfgfile" # CPPFLAGS=$old_CPPFLAGS MAGIC=$old_MAGIC LD=$old_LD LDFLAGS=$old_LDFLAGS \\ # LIBS=$old_LIBS LN_S=$old_LN_S NM=$old_NM RANLIB=$old_RANLIB \\ # STRIP=$old_STRIP AS=$old_AS DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP \\ -# objext=$old_OBJEXT exeext=$old_EXEEXT reload_flag=$old_reload_flag \\ -# deplibs_check_method=$old_deplibs_check_method file_magic_cmd=$old_file_magic_cmd \\ +# objext=$old_OBJEXT exeext=$old_EXEEXT echo=$old_echo \\ +# reload_flag=$old_reload_flag deplibs_check_method=$old_deplibs_check_method \# file_magic_cmd=$old_file_magic_cmd \\ # $0$ltconfig_args # # Compiler and other test output produced by $progname, useful for