diff --git a/ChangeLog b/ChangeLog index ae7afba9..37911f27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,25 @@ Fri Sep 5 13:11:38 1997 Gordon Matzigkeit + * demo/Makefile.am (hell_debug_LDFLAGS): Change hell.static to + hell.debug in order to reflect the new static linking semantics. + + * ltmain.sh.in (link): Add new `-all-static' flag to prevent all + dynamic linking. The old `-static' flag just prevents dynamic + linking against libtool libraries. Suggested by Bengt + Martensson. + * ltconfig.in (with_gnu_ld): Add a test to make sure that we are actually using GNU ld. This fixes an inconsistency when running ltconfig without using libtool.m4. Reported by Ulrich Drepper. + (global_symbol_pipe): Delete symbols that are not valid C + identifiers. Reported by Johan Danielsson and Bengt Martensson. Thu Sep 4 21:53:08 1997 Gordon Matzigkeit * ltmain.sh.in (echo): Quote all the uses of `echo' in all eval - statements. + statements. Reported by Bengt Martensson and Alexandre Oliva. + (echo): Need to surround test args with double quotes, or the echo + test fails on Digital Unix 4.0. From Todd Kover. Thu Aug 28 20:58:56 1997 Gordon Matzigkeit diff --git a/NEWS b/NEWS index fc094fde..c72611a5 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,9 @@ NEWS - list of user-visible changes between releases of GNU libtool. -New in 1.0b: +New in 1.0c: * Bug fixes. +* New `-all-static' flag to prevent any dynamic linking. The regular + `-static' flag just prevents dynamic linking of libtool libraries. * Suppress duplicate compiler output during `compile' mode. * New `execute' mode to support debugging uninstalled libtool libraries and executables. diff --git a/README-alpha b/README-alpha index fb1a5788..0644d4dc 100644 --- a/README-alpha +++ b/README-alpha @@ -11,7 +11,7 @@ that don't have shared libraries, I am collecting `NM' and If ltconfig on your system says that it found the command to parse NM output, then you don't need to look any further: -checking command to parse NM output... yes +checking command to parse /usr/bin/nm output... yes Otherwise, I would very much appreciate hearing about the combination of `NM' and `global_symbol_pipe' that ltconfig needs to use in order @@ -40,7 +40,8 @@ program. So, on most OSes, this will be a command like: $ nm assert-perr.o | \ - sed -e '/^.* [BCDEGRSTU] /!d' -e 's/^.* [BCDEGRSTU] \(.*\)$/\1 \1/' + sed -e '/^.* [BCDEGRSTU] \([_A-Za-z][_A-Za-z0-9]*\)$/!d' + -e 's/^.* [BCDEGRSTU] \([_A-Za-z][_A-Za-z0-9]*\)$/\1 \1/' _IO_stderr_ _IO_stderr_ __assert_perror_fail __assert_perror_fail __assert_program_name __assert_program_name @@ -51,6 +52,9 @@ strerror strerror On some OSes, the C symbols will need to strip a leading underscore: +$ nm assert-perr.o | \ + sed -e '/^.* [BCDEGRSTU] _\([_A-Za-z][_A-Za-z0-9]*\)$/!d' + -e 's/^.* [BCDEGRSTU] _\([_A-Za-z][_A-Za-z0-9]*\)$/_\1 \1/' __IO_stderr_ _IO_stderr_ ___assert_perror_fail __assert_perror_fail ___assert_program_name __assert_program_name diff --git a/TODO b/TODO index d5b08349..277d254f 100644 --- a/TODO +++ b/TODO @@ -1,14 +1,6 @@ For next public release: ************************ -* #@%$ing SUN makes their Solaris /usr/bin/echo always interpret -backslashes, so: - var='\n' - newvar=`echo "$var"` - test "$var" = "$newvar" -returns false. We need to detect this, and use the other -echo (/usr/ucb/echo). - * Document `execute' mode, and the experimental nature of -dlopen and -dlpreopen. diff --git a/configure.in b/configure.in index e7f61a9e..283489da 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to create configure. AC_INIT(ltmain.sh.in) -AM_INIT_AUTOMAKE(libtool,1.0b) +AM_INIT_AUTOMAKE(libtool,1.0c) pkgdatadir='${datadir}/libtool' AC_SUBST(pkgdatadir) diff --git a/demo/Makefile.am b/demo/Makefile.am index 578735ab..34585481 100644 --- a/demo/Makefile.am +++ b/demo/Makefile.am @@ -17,16 +17,16 @@ libhello_la_LDFLAGS = -version-info 3:12:1 include_HEADERS = foo.h -bin_PROGRAMS = hell hell.static helldl +bin_PROGRAMS = hell hell.debug helldl # Build hell from main.c and libhello.la hell_SOURCES = main.c hell_LDADD = libhello.la -# Create a statically-linked version of hell. -hell_static_SOURCES = main.c -hell_static_LDADD = libhello.la -hell_static_LDFLAGS = -static +# Create an easier-to-debug version of hell. +hell_debug_SOURCES = main.c +hell_debug_LDADD = libhello.la +hell_debug_LDFLAGS = -static # Create a version of hell that does a preloaded dlopen. helldl_SOURCES = dlmain.c diff --git a/doc/libtool.texi b/doc/libtool.texi index d9b8ce65..a375bd6a 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -866,7 +866,7 @@ as well as automatically running the correct @code{ranlib} command. @cindex Standalone binaries Another common situation where static linking is desirable is in creating a standalone binary. Use libtool to do the linking and add the -@samp{-static} flag. +@samp{-all-static} flag. @node Invoking libtool @chapter Invoking @code{libtool} @@ -974,6 +974,11 @@ The following components of @var{mode-args} are treated specially: @table @samp @cindex Undefined symbols, allowing @cindex Unresolved symbols, allowing +@item -all-static +If @var{output-file} is a program, then do not link it against any +shared libraries at all. If @var{output-file} is a library, then only +create a static library. + @item -allow-undefined If @var{output-file} is a libtool library, allow it to contain references to symbols that aren't defined in that library or its @@ -1001,8 +1006,8 @@ If @var{output-file} is a library, it will eventually be installed in @item -static If @var{output-file} is a program, then do not link it against any -shared libraries. If @var{output-file} is a library, then only create a -static library. +uninstalled shared libtool libraries. If @var{output-file} is a +library, then only create a static library. @item -version-info @var{current}[:@var{revision}[:@var{age}]] If @var{output-file} is a libtool library, use library version @@ -1123,21 +1128,21 @@ First, to link a program against a libtool library, just use the @samp{program_LDADD} variable: @example -bin_PROGRAMS = hell hell.static +bin_PROGRAMS = hell hell.debug # Build hell from main.c and libhello.la hell_SOURCES = main.c hell_LDADD = libhello.la -# Create a statically-linked version of hell. -hell_static_SOURCES = main.c -hell_static_LDADD = libhello.la -hell_static_LDFLAGS = -static +# Create an easier-to-debug version of hell. +hell_debug_SOURCES = main.c +hell_debug_LDADD = libhello.la +hell_debug_LDFLAGS = -static @end example You may use the @samp{program_LDFLAGS} variable to stuff in any flags you want to pass to libtool while linking @samp{program} (such as -@samp{-static} to create a statically-linked executable). +@samp{-static} to avoid linking uninstalled shared libtool libraries). Building a libtool library is almost as trivial@dots{} note the use of @samp{libhello_la_LDFLAGS} to pass the @samp{-version-info} diff --git a/ltconfig.in b/ltconfig.in index 49286576..b6b6fab2 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -802,27 +802,39 @@ fi # Check for command to grab the raw symbol name followed by C symbol from nm. echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 -# This is a sane default that works on at least a few old systems. -# [It comes from Ultrix. What could be older than Ultrix?!! ;)] -global_symbol_pipe="sed -e '/^.* [BCDEGRSTU] /!d' -e 's/^.* [BCDEGRSTU] \(.*\)$/\1 \1/'" +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] -# Take a first stab at what the pipe should be. +# Character class describing NM global symbol codes. +symcode='[BCDEGRSTU]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \1' + +# Define system-specific variables. +case "$host_os" in +aix*) + symcode='[BCDTU]' + ;; +solaris2*) + symcode='[BDTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then - # We're using GNU nm. - global_symbol_pipe="sed -e '/^.* [ABCDGISTU] /!d' -e 's/^.* [ABCDGISTU] \(.*\)$/\1 \1/'" -else - # It's the system nm. - case "$host_os" in - aix*) - # Delete symbols that begin with a dot. - global_symbol_pipe="sed -e '/^.* [BCDTU] [^.]/!d' -e 's/^.* [BCDTU] \(.*\)$/\1 \1/'" - ;; - solaris2*) - global_symbol_pipe="sed -e '/^.* [BDTU] /!d' -e 's/^.* [BDTU] \(.*\)$/\1 \1/'" - ;; - esac + symcode='[ABCDGISTU]' fi +# Delete symbols that are not valid C identifiers. +global_symbol_pipe="sed -e '/^.* $symcode $sympat$/!d'" + +# Write the raw and C identifiers. +global_symbol_pipe="$global_symbol_pipe -e 's/^.* $symcode $sympat$/$symxfrm/'" + # Check to see that the pipe works correctly. pipe_works=no $rm conftest* diff --git a/ltmain.sh.in b/ltmain.sh.in index 3b5290e2..217e36eb 100644 --- a/ltmain.sh.in +++ b/ltmain.sh.in @@ -23,7 +23,7 @@ # the same distribution terms that you use for the rest of that program. echo=echo -if test X`$echo '\t'` = 'X\t'; then : +if test "X`$echo '\t'`" = 'X\t'; then : else # The Solaris and AIX default echo program unquotes backslashes. # This makes it impossible to quote backslashes using @@ -392,7 +392,6 @@ if test -z "$show_help"; then install_libdir= libobjs= link_against_libtool_libs= - link_static= ltlibs= objs= prev= @@ -405,14 +404,11 @@ if test -z "$show_help"; then for arg do case "$arg" in - -static) - if test "$build_libtool_libs" = yes; then - if test "$hardcode_direct" = unsupported && test -z "$link_static_flag"; then - $echo "$progname: warning: static linking is impossible in this configuration" 1>&2 - else - build_libtool_libs=no - fi + -all-static | -static) + if test "X$arg" = "X-all-static" && test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + $echo "$progname: warning: complete static linking is impossible in this configuration" 1>&2 fi + build_libtool_libs=no build_old_libs=yes break ;; @@ -453,6 +449,14 @@ if test -z "$show_help"; then prevarg="$arg" case "$arg" in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + -allow-undefined) allow_undefined=yes continue @@ -471,7 +475,7 @@ if test -z "$show_help"; then -export-dynamic) if test "$export_dynamic" != yes; then export_dynamic=yes - arg=`eval \$echo "$export_dynamic_flag_spec"` + arg=`eval \\$echo "$export_dynamic_flag_spec"` # Add the symbol object into the linking commands. compile_command="$compile_command @SYMFILE@" @@ -502,11 +506,9 @@ if test -z "$show_help"; then ;; -static) - link_static="$link_static_flag" - compile_command="$compile_command $link_static" - finalize_command="$finalize_command $link_static" + # We already handled this flag above. continue - ;; + ;; -version-info) prev=vinfo @@ -647,7 +649,7 @@ if test -z "$show_help"; then fi if test -n "$libdir"; then - flag=`eval \$echo \"$hardcode_libdir_flag_spec\"` + flag=`eval \\$echo \"$hardcode_libdir_flag_spec\"` compile_command="$compile_command $flag" finalize_command="$finalize_command $flag" @@ -922,13 +924,13 @@ if test -z "$show_help"; then if test "$build_libtool_libs" = yes; then # Get the real and link names of the library. - library_names=`eval \$echo \"$library_names_spec\"` + library_names=`eval \\$echo \"$library_names_spec\"` set dummy $library_names realname="$2" shift; shift if test -n "$soname_spec"; then - soname=`eval \$echo \"$soname_spec\"` + soname=`eval \\$echo \"$soname_spec\"` else soname="$realname" fi @@ -944,7 +946,7 @@ if test -z "$show_help"; then test -z "$pic_flag" && libobjs=`$echo "$libobjs " | sed -e 's/\.lo /.o /g' -e 's/ $//g'` # Do each of the archive commands. - cmds=`eval \$echo \"$archive_cmds\"` + cmds=`eval \\$echo \"$archive_cmds\"` IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1014,7 +1016,7 @@ if test -z "$show_help"; then reload_objs="$objs"`$echo "$libobjs " | sed -e 's/[^ ]*\.a //g' -e 's/\.lo /.o /g' -e 's/ $//g'` output="$obj" - cmds=`eval \$echo \"$reload_cmds\"` + cmds=`eval \\$echo \"$reload_cmds\"` IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1038,7 +1040,7 @@ if test -z "$show_help"; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs" output="$libobj" - cmds=`eval \$echo \"$reload_cmds\"` + cmds=`eval \\$echo \"$reload_cmds\"` IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1176,17 +1178,7 @@ EOF # We have no uninstalled library dependencies, so finalize right now. $show "$compile_command" $run eval "$compile_command" - status=$? - - # If we failed to link statically, then try again. - if test $status -ne 0 && test -n "$link_static"; then - $echo "$progname: cannot link \`$output' statically; retrying semi-dynamically" 1>&2 - compile_command=`$echo "$compile_command " | sed -e "s% $link_static % %" -e 's/ $//'` - $show "$compile_command" - $run eval "$compile_command" - status=$? - fi - exit $status + exit $? fi # Replace the output file specification. @@ -1371,7 +1363,7 @@ EOF fi # Do each command in the archive commands. - cmds=`eval \$echo \"$old_archive_cmds\"` + cmds=`eval \\$echo \"$old_archive_cmds\"` IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1645,7 +1637,7 @@ EOF # Do each command in the postinstall commands. lib="$destdir/$realname" - cmds=`eval \$echo \"$postinstall_cmds\"` + cmds=`eval \\$echo \"$postinstall_cmds\"` IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1792,7 +1784,7 @@ EOF fi # Do each command in the postinstall commands. - cmds=`eval \$echo \"$old_postinstall_cmds\"` + cmds=`eval \\$echo \"$old_postinstall_cmds\"` IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -1829,7 +1821,7 @@ EOF for libdir in $libdirs; do # Do each command in the postinstall commands. - cmds=`eval \$echo \"$finish_cmds\"` + cmds=`eval \\$echo \"$finish_cmds\"` IFS="${IFS= }"; save_ifs="$IFS"; IFS=';' for cmd in $cmds; do IFS="$save_ifs" @@ -2154,6 +2146,7 @@ a program from several object files. The following components of LINK-COMMAND are treated specially: + -all-static do not do any dynamic linking at all -allow-undefined allow a libtool library to reference undefined symbols -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to dld_preloaded_symbols @@ -2162,7 +2155,7 @@ The following components of LINK-COMMAND are treated specially: -lNAME OUTPUT-FILE requires the installed library libNAME -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -rpath LIBDIR the created library will eventually be installed in LIBDIR - -static do not do any dynamic linking or shared library creation + -static do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] diff --git a/tests/ChangeLog b/tests/ChangeLog index db57c6ef..2e9ea612 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,16 @@ +Fri Sep 5 13:36:24 1997 Gordon Matzigkeit + + * demo-exec.test, demo-inst.test: Change references from + hell.static to hell.debug. + + * quote.test (echo): Add the same Digital Unix echo test fixes as + the ones to ltmain.sh.in from Todd Kover. + + * if.test, test-e.test (scripts): Add ../lineno to the scripts we + check. + * if.test: Check for accidental use of test X$something rather + than test "X$something". + Thu Aug 28 20:58:30 1997 Gordon Matzigkeit * quote.test (echo): Change test to version that uses printf. diff --git a/tests/demo-exec.test b/tests/demo-exec.test index 247a12d0..afe5912a 100755 --- a/tests/demo-exec.test +++ b/tests/demo-exec.test @@ -20,9 +20,9 @@ fi echo "Executing uninstalled programs in ../demo" status=0 -if ../demo/hell.static | grep 'Welcome to GNU Hell'; then : +if ../demo/hell.debug| grep 'Welcome to GNU Hell'; then : else - echo "$0: cannot execute ../demo/hell.static" 1>&2 + echo "$0: cannot execute ../demo/hell.debug" 1>&2 status=1 fi diff --git a/tests/demo-inst.test b/tests/demo-inst.test index 419cafdf..3e99e5e7 100755 --- a/tests/demo-inst.test +++ b/tests/demo-inst.test @@ -25,9 +25,9 @@ $make install || exit 1 echo "= Executing installed programs" status=0 -if $prefix/bin/hell.static | grep 'Welcome to GNU Hell'; then : +if $prefix/bin/hell.debug | grep 'Welcome to GNU Hell'; then : else - echo "$0: cannot execute $prefix/bin/hell.static" 1>&2 + echo "$0: cannot execute $prefix/bin/hell.debug" 1>&2 status=1 fi diff --git a/tests/if.test b/tests/if.test index a4710669..c1e0e999 100644 --- a/tests/if.test +++ b/tests/if.test @@ -10,23 +10,32 @@ if test -z "$srcdir"; then fi . $srcdir/defs || exit 1 -# Check for bad binary operators. +# Check all the "portable" shell scripts. status=0 -if egrep -n -e "if[ ]+[\"']?\\$.*(=|-[lg][te]|-eq|-ne)" $srcdir/../ltconfig $srcdir/../ltmain.sh; then +scripts="$srcdir/../ltconfig $srcdir/../ltmain.sh $srcdir/../lineno" + +# Check for bad binary operators. +if egrep -n -e "if[ ]+[\"']?\\$.*(=|-[lg][te]|-eq|-ne)" $scripts; then echo "use \`if test \$something =' instead of \`if \$something ='" status=1 fi # Check for bad unary operators. -if egrep -n -e 'if[ ]+-' $srcdir/../ltconfig $srcdir/../ltmain.sh; then +if egrep -n -e 'if[ ]+-' $scripts; then echo "use \`if test -X' instead of \`if -X'" status=1 fi # Check for using `[' instead of `test'. -if egrep -n -e 'if[ ]+\[' $srcdir/../ltconfig $srcdir/../ltmain.sh; then +if egrep -n -e 'if[ ]+\[' $scripts; then echo "use \`if test' instead of \`if ['" status=1 fi +# Check for using test X... instead of test "X... +if egrep -n -e 'test[ ]+X' $scripts; then + echo "use \`test "X..."' instead of \`test X'" + status=1 +fi + exit $status diff --git a/tests/quote.test b/tests/quote.test index d35b909e..3bf5d88c 100755 --- a/tests/quote.test +++ b/tests/quote.test @@ -14,14 +14,14 @@ fi status=0 echo=echo -if test X`$echo '\t'` = 'X\t'; then : +if test "X`$echo '\t'`" = 'X\t'; then : else # The Solaris and AIX default echo program unquotes backslashes. # This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # So, we emulate echo with printf '%s\n' echo='printf %s\n' - if test X`$echo '\t'` = 'X\t'; then : + if test "X`$echo '\t'`" = 'X\t'; then : else # Oops. We have no working printf. Try to find a not-so-buggy echo. echo=echo diff --git a/tests/test-e.test b/tests/test-e.test index 2e148120..071d3c05 100644 --- a/tests/test-e.test +++ b/tests/test-e.test @@ -11,7 +11,8 @@ fi . $srcdir/defs || exit 1 # Check that test -e isn't used in our portable shell scripts. -if egrep -n -e 'test[ ]+-e' $srcdir/../ltconfig $srcdir/../ltmain.sh; then +scripts="$srcdir/../ltconfig $srcdir/../ltmain.sh $srcdir/../lineno" +if egrep -n -e 'test[ ]+-e' $scripts; then echo "use test -f, not test -e to check for file existence" exit 1 fi