From: Charles Wilson Date: Tue, 19 Jun 2007 05:43:16 +0000 (+0000) Subject: * libltdl/config/ltmain.m4sh: Add new magic variable X-Git-Tag: release-2-1b~113 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9137c1440fc7fbd448069793e002628118fd01d;p=thirdparty%2Flibtool.git * libltdl/config/ltmain.m4sh: Add new magic variable for use with cwrapper. (func_ltwrapper_script_p): New function. (func_ltwrapper_executable_p): New function. (func_ltwrapper_scriptname): New function. (func_ltwrapper_p): Accomodate both wrapper scripts and wrapper executables. (func_mode_execute): Handle $file that is a wrapper script and $file that is a wrapper executable differently. (func_mode_install) [cygwin|mingw]: If $file is a wrapper executable, use func_ltwrapper_scriptname to determine wrapper script name. Afterwards, always use func_ltwrapper_script_p instead of func_ltwrapper_p. (func_emit_libtool_wrapper_script): Rename to... (func_emit_wrapper): ...this. All callers changed. (func_emit_libtool_cwrapperexe_source): Rename to... (func_emit_cwrapperexe_src): ...this. All callers changed. Embed new magic_exe variable into source. Private transient wrapper script now called foo_ltshwrapperTMP, not foo_ltshwrapper. (func_emit_cwrapperexe_src) [main, mingw]: Use _spawnv and return child's exit code manually rather than rely on broken execv. (func_mode_link) [cygwin|mingw]: Don't call dirname and basename directly; use func_dirname and func_basename when computing cwrapper names. Use cwrapper to generate wrapper script, and use pathname returned by func_ltwrapper_scriptname instead of $output. (func_mode_link) [NOT cygwin|mingw]: move wrapper script generation for non-win32 inside case statement, as default case. (func_mode_uninstall) [$name's extension != .lo|.la]: 'clean' mode must handle $file differently if it is a libtool wrapper script, or if it is a libtool wrapper executable. * tests/destdir.at [Simple DESTDIR install]: $EXEEXT fixups. * tests/destdir.at [DESTDIR with in-package deplibs]: Ditto. --- diff --git a/ChangeLog b/ChangeLog index d28c96cc3..67ba91148 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +2007-06-18 Charles Wilson + + * libltdl/config/ltmain.m4sh: Add new magic variable + for use with cwrapper. + (func_ltwrapper_script_p): New function. + (func_ltwrapper_executable_p): New function. + (func_ltwrapper_scriptname): New function. + (func_ltwrapper_p): Accomodate both wrapper scripts and + wrapper executables. + (func_mode_execute): Handle $file that is a wrapper + script and $file that is a wrapper executable differently. + (func_mode_install) [cygwin|mingw]: If $file is a wrapper + executable, use func_ltwrapper_scriptname to determine + wrapper script name. Afterwards, always use + func_ltwrapper_script_p instead of func_ltwrapper_p. + (func_emit_libtool_wrapper_script): Rename to... + (func_emit_wrapper): ...this. All callers changed. + (func_emit_libtool_cwrapperexe_source): Rename to... + (func_emit_cwrapperexe_src): ...this. All callers changed. + Embed new magic_exe variable into source. Private transient + wrapper script now called foo_ltshwrapperTMP, not + foo_ltshwrapper. + (func_emit_cwrapperexe_src) [main, mingw]: Use _spawnv + and return child's exit code manually rather than rely on + broken execv. + (func_mode_link) [cygwin|mingw]: Don't call dirname and + basename directly; use func_dirname and func_basename + when computing cwrapper names. Use cwrapper to generate + wrapper script, and use pathname returned by + func_ltwrapper_scriptname instead of $output. + (func_mode_link) [NOT cygwin|mingw]: move wrapper script + generation for non-win32 inside case statement, as default + case. + (func_mode_uninstall) [$name's extension != .lo|.la]: + 'clean' mode must handle $file differently if it is a libtool + wrapper script, or if it is a libtool wrapper executable. + * tests/destdir.at [Simple DESTDIR install]: $EXEEXT fixups. + * tests/destdir.at [DESTDIR with in-package deplibs]: Ditto. + + 2007-06-17 Noah Misch * AUTHORS: Add myself. diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 6b25dbb25..54781274b 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -135,7 +135,7 @@ EOF fi magic="%%%MAGIC variable%%%" - +magic_exe="%%%MAGIC EXE variable%%%" # Global variables. # $mode is unset @@ -661,13 +661,55 @@ func_lalib_unsafe_p () test "$lalib_p" = yes } +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + func_lalib_p "$1" +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_ltwrapper_scriptname_result="" + if func_ltwrapper_executable_p "$1"; then + func_dirname "$1" + func_basename "$1" + func_stripname '' '.exe' "$func_basename_result" + if test -z "$func_dirname_result"; then + func_ltwrapper_scriptname_result="./$objdir/${func_stripname_result}_ltshwrapper" + else + func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" + fi + fi +} + # func_ltwrapper_p file -# True iff FILE is a libtool wrapper script. +# True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { - func_lalib_p "$1" + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } @@ -1649,12 +1691,14 @@ func_mode_execute () -*) ;; *) # Do a test to see if this is really a libtool program. - if func_ltwrapper_p "$file"; then + if func_ltwrapper_script_p "$file"; then func_source "$file" - - # Transform arg to wrapped name. - file="$progdir/$program" + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" fi + # Transform arg to wrapped name. + file="$progdir/$program" ;; esac # Quote arguments (to preserve shell metacharacters). @@ -2085,14 +2129,19 @@ func_mode_install () # Do a test to see if this is really a libtool program. case $host in *cygwin*|*mingw*) - func_stripname '' '.exe' "$file" - wrapper=$func_stripname_result + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi ;; *) wrapper=$file ;; esac - if func_ltwrapper_p "$wrapper"; then + if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= @@ -2209,7 +2258,7 @@ func_mode_install () test "$mode" = install && func_mode_install ${1+"$@"} -# func_emit_libtool_wrapper_script arg +# func_emit_wrapper arg # # emit a libtool wrapper script on stdout # don't directly open a file because we may want to @@ -2223,11 +2272,11 @@ test "$mode" = install && func_mode_install ${1+"$@"} # will assume that the directory in which it is stored is # the '.lib' directory. This is a cygwin/mingw-specific # behavior. -func_emit_libtool_wrapper_script () +func_emit_wrapper () { - func_emit_libtool_wrapper_script_arg1=no + func_emit_wrapper_arg1=no if test -n "$1" ; then - func_emit_libtool_wrapper_script_arg1=$1 + func_emit_wrapper_arg1=$1 fi $ECHO "\ @@ -2315,7 +2364,7 @@ else # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. - WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_libtool_wrapper_script_arg1 + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then @@ -2432,13 +2481,13 @@ else fi\ " } -# end: func_emit_libtool_wrapper_script +# end: func_emit_wrapper -# func_emit_libtool_cwrapperexe_source +# func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. -func_emit_libtool_cwrapperexe_source () +func_emit_cwrapperexe_src () { cat < $cwrappersource + func_emit_cwrapperexe_src > $cwrappersource + + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $opt_dry_run || $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource - # we should really use a build-platform specific compiler - # here, but OTOH, the wrappers (shell script and this C one) - # are only useful if you want to execute the "real" binary. - # Since the "real" binary is built for $host, then this - # wrapper might as well be built for $host, too. - $opt_dry_run || $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + } ;; - esac - $RM $output - trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 - func_emit_libtool_wrapper_script no > $output - chmod +x $output + func_emit_wrapper no > $output + chmod +x $output + ;; + esac } exit $EXIT_SUCCESS ;; @@ -7179,8 +7254,15 @@ func_mode_uninstall () esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then - relink_command= - func_source $dir/$noexename + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + rmfiles="$rmfiles $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles diff --git a/tests/destdir.at b/tests/destdir.at index 3789b44b9..8ce8df35c 100644 --- a/tests/destdir.at +++ b/tests/destdir.at @@ -60,7 +60,7 @@ $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o m m.$OBJEXT liba.la mkdir $DESTDIR$libdir $DESTDIR$bindir AT_CHECK([$LIBTOOL --mode=install cp liba.la $DESTDIR$libdir/liba.la], [], [ignore], [ignore]) -AT_CHECK([$LIBTOOL --mode=install cp m $DESTDIR$bindir/m], +AT_CHECK([$LIBTOOL --mode=install cp m$EXEEXT $DESTDIR$bindir/m$EXEEXT], [], [ignore], [ignore]) $LIBTOOL --mode=clean rm -f liba.la m LT_AT_MVDIR(["$DESTDIR$libdir"], ["$libdir"]) @@ -99,7 +99,7 @@ AT_CHECK([$LIBTOOL --mode=install cp liba2dep.la $DESTDIR${libdir}2/liba2dep.la] [], [ignore], [ignore]) AT_CHECK([$LIBTOOL --mode=install cp liba.la $DESTDIR$libdir/liba.la], [], [ignore], [ignore]) -AT_CHECK([$LIBTOOL --mode=install cp m $DESTDIR$bindir/m], +AT_CHECK([$LIBTOOL --mode=install cp m$EXEEXT $DESTDIR$bindir/m$EXEEXT], [], [ignore], [ignore]) $LIBTOOL --mode=clean rm -f liba1dep.la liba2dep.la liba.la m LT_AT_MVDIR(["$DESTDIR$libdir"], ["$libdir"]) @@ -127,8 +127,8 @@ done LT_AT_EXEC_CHECK([$bindir/m]) # TODO: make this more portable: -if test "$OBJDUMP" != false && ($OBJDUMP -p $bindir/m) >/dev/null 2>&1; then - AT_CHECK([$OBJDUMP -p $bindir/m | $EGREP -i "R(UN)?PATH.*$DESTDIR"], [1]) +if test "$OBJDUMP" != false && ($OBJDUMP -p $bindir/m$EXEEXT) >/dev/null 2>&1; then + AT_CHECK([$OBJDUMP -p $bindir/m$EXEEXT | $EGREP -i "R(UN)?PATH.*$DESTDIR"], [1]) . $libdir/liba.la set x $library_names lname=$2