diff options
author | Charles Wilson <libtool@cwilson.fastmail.fm> | 2007-06-19 05:43:16 +0000 |
---|---|---|
committer | Charles Wilson <libtool@cwilson.fastmail.fm> | 2007-06-19 05:43:16 +0000 |
commit | f9137c1440fc7fbd448069793e002628118fd01d (patch) | |
tree | 5ae3beb0ecedf334a458ec4ac83542d9348b6b6a | |
parent | 691ddc8da27361ea2d1a9b189c306244e582d283 (diff) | |
download | libtool-f9137c1440fc7fbd448069793e002628118fd01d.tar.gz |
* 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.
-rw-r--r-- | ChangeLog | 40 | ||||
-rw-r--r-- | libltdl/config/ltmain.m4sh | 166 | ||||
-rw-r--r-- | tests/destdir.at | 8 |
3 files changed, 168 insertions, 46 deletions
@@ -1,3 +1,43 @@ +2007-06-18 Charles Wilson <libtool@cwilson.fastmail.fm> + + * 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 <noah@cs.caltech.edu> * AUTHORS: Add myself. diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 6b25dbb2..54781274 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 <<EOF @@ -2547,12 +2596,13 @@ void lt_fatal (const char *message, ...); static const char *script_text = EOF - func_emit_libtool_wrapper_script yes | + func_emit_wrapper yes | $SED -e 's/\([\\"]\)/\\\1/g' \ -e 's/^/ "/' -e 's/$/\\n"/' echo ";" cat <<EOF +const char * MAGIC_EXE = "$magic_exe"; int main (int argc, char *argv[]) @@ -2561,11 +2611,12 @@ main (int argc, char *argv[]) char *tmp_pathspec; char *actual_cwrapper_path; char *shwrapper_name; + intptr_t rval = 127; FILE *shwrapper; const char *dumpscript_opt = "--lt-dump-script"; int i; - + program_name = (char *) xstrdup (base_name (argv[0])); LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0])); LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name)); @@ -2623,9 +2674,9 @@ EOF /* shwrapper_name transforms */ strendzap (shwrapper_name, ".exe"); tmp_pathspec = XMALLOC (char, (strlen (shwrapper_name) + - strlen ("_ltshwrapper") + 1)); + strlen ("_ltshwrapperTMP") + 1)); strcpy (tmp_pathspec, shwrapper_name); - strcat (tmp_pathspec, "_ltshwrapper"); + strcat (tmp_pathspec, "_ltshwrapperTMP"); XFREE (shwrapper_name); shwrapper_name = tmp_pathspec; tmp_pathspec = 0; @@ -2688,19 +2739,28 @@ EOF case $host_os in mingw*) cat <<EOF - execv ("$lt_newargv0", (const char * const *) newargz); + /* execv doesn't actually work on mingw as expected on unix */ + rval = _spawnv (_P_WAIT, "$lt_newargv0", (const char * const *) newargz); + if (rval == -1) + { + /* failed to start process */ + LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"$lt_newargv0\": errno = %d\n", errno)); + return 127; + } + return rval; +} EOF ;; *) cat <<EOF execv ("$lt_newargv0", newargz); + return rval; /* =127, but avoids unused variable warning */ +} EOF ;; esac cat <<"EOF" - return 127; -} void * xmalloc (size_t num) @@ -2977,7 +3037,7 @@ lt_fatal (const char *message, ...) } EOF } -# end: func_emit_libtool_cwrapperexe_source +# end: func_emit_cwrapperexe_src # func_mode_link arg... func_mode_link () @@ -6708,28 +6768,43 @@ EOF esac case $host in *cygwin* | *mingw* ) - output_name=`basename $output` - output_path=`dirname $output` + func_basename "$output" + output_name=$func_basename_result + func_dirname "$output" + output_path=$func_dirname_result + if test -z "$output_path"; then + output_path=. + fi 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 - func_emit_libtool_cwrapperexe_source > $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 3789b44b..8ce8df35 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 |