[PATCH] Add --lt-* options to shell wrapper

2009-07-12 Thread Charles Wilson
* libltdl/config/ltmain.m4sh (func_emit_wrapper)
[func_parse_lt_options]: New function.
[func_opts_contain_lt]: New function.
[func_lt_dump_args]: New function.
[func_exec_program_core]: New function, refactored from [main].
[func_exec_program]: New function.
[main]: Call func_parse_lt_options early. Use func_exec_program.
(func_emit_cwrapperexe_src) [main]: Reword error message to
align with (upcoming) documentation.
---
For symmetry, support --lt-debug and --lt-dump-script in the shell
wrapper, as well as in the cwrapper.

In this patch series, I've kept the --lt-dump-script option
for now, and even added support for that option to the wrapper
script.  I think the option is useful, and I agree that symmetry
between w-script and w-exe is important. However, Ralf said:
 I'd consider documenting --lt-dump-script the cementation of 
 a bad API. 
So, as a compromise we could could modify this documentation patch
to just not /document/ that option, while retaining all the other
documentation/discussion of the w-exe and the --lt-debug option.

There are four patches in this series:

1. Remove unneeded functions and options from cwrapper
committed: 75765d58c38c55ef069ef100732c1e978f4151a6

2. [PATCH] Enable runtime cwrapper debugging; add tests
http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00039.html
pending...

3. [PATCH] Add --lt-* options to shell wrapper
(this post. obviously no URL yet, and obviously pending...)

4. [PATCH] Document wrapper changes
(next post. also no URL yet, and also obviously pending...)

Together, these four obsolete and (I hope) address all of the comments
for
[PATCH] Document and test LT_DEBUGWRAPPER cwrapper macro
http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00031.html
as well as addressing the comments recieved so far in review of #2.

I'm posting #3 and #4 on the off chance that, for whatever reasons,
approval for #2 has been held up waiting for these two promised patches.
I'm really hoping to get my pending patch set reviewed and merged in the
near future, as the current cygwin patch queue is a bit ridiculous at 72kB...
  8 files changed, 1271 insertions(+), 242 deletions(-)


 libltdl/config/ltmain.m4sh |  150 ++--
 1 files changed, 130 insertions(+), 20 deletions(-)

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index d8c5749..881aef5 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -2401,7 +2401,134 @@ func_fallback_echo ()
 _LTECHO_EOF'
 }
 ECHO=\$qECHO\
-  fi\
+  fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all exist in the --lt- namespace
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's $0 value, followed by $@.
+lt_option_debug=
+func_parse_lt_options ()
+{
+  lt_script_arg0=\$0
+  shift
+  for lt_opt
+  do
+case \\$lt_opt\ in
+--lt-debug) lt_option_debug=1 ;;
+--lt-dump-script)
+lt_dump_D=\`\$ECHO \X\$lt_script_arg0\ | $SED -e 's/^X//' -e 
's%/[^/]*$%%'\`
+test \X\$lt_dump_D\ = \X\$lt_script_arg0\  lt_dump_D=.
+lt_dump_F=\`\$ECHO \X\$lt_script_arg0\ | $SED -e 's/^X//' -e 
's%^.*/%%'\`
+cat \\$lt_dump_D/\$lt_dump_F\
+exit 0
+  ;;
+--lt-*)
+\$ECHO \Unrecognized --lt- option: '\$lt_opt'\ 12
+exit 1
+  ;;
+esac
+  done
+}
+
+# Sets opts_contain_lt_result to \yes\ if the
+# supplied arguments contain any elements in the
+# --lt-* namespace. Empty otherwise.
+opts_contain_lt_result=
+func_opts_contain_lt ()
+{
+  opts_contain_lt_result=
+  for lt_option
+  do
+case \\$lt_option\ in
+--lt-*) opts_contain_lt_result=yes
+break ;;
+*) ;;
+esac
+  done
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+  lt_dump_args_N=1;
+  for lt_arg
+  do
+\$ECHO \(main) newargz[\$lt_dump_args_N]   : \$lt_arg\
+lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
+  done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+
+  case $host in
+  # Backslashes separate directories on plain windows
+  *-*-mingw | *-*-os2* | *-cegcc*)
+$ECHO \
+  if test -n \\$lt_option_debug\; then
+\$ECHO \(main) lt_argv_zero : \$progdir\$program\ 12
+func_lt_dump_args \${1+\\...@\} 12
+  fi
+  exec \\$progdir\$program\ \${1+\\...@\}
+
+;;
+
+  *)
+$ECHO \
+  if test -n \\$lt_option_debug\; then
+\$ECHO \(main) lt_argv_zero : \$progdir/\$program\ 12
+func_lt_dump_args \${1+\\...@\} 12
+  

[PATCH] Document wrapper changes.

2009-07-12 Thread Charles Wilson
* NEWS: Indicate new feature and incompatibility.
* doc/libtool.texi [Linking executables]: Mention wrapper
executables, in addition to wrapper scripts. Add menu referencing
subsection 'Wrapper executables for programs'.
[Wrapper executables for programs]: New subsection. Documents
cwrapper rationale and command line options.
---
This patch adds documentation for the new wrapper command line
options (which apply to both the wrapper /script/ and to the
wrapper /executable/).  However, because the options are of
primary interest with respect to the wrapper exes, I've kept
the documentation in the page specific for those, with a note
that the script also supports the options.

In this patch series, I've kept the --lt-dump-script option
for now, and even added support for that option to the wrapper
script.  I think the option is useful, and I agree that symmetry
between w-script and w-exe is important. However, Ralf said:
 I'd consider documenting --lt-dump-script the cementation of
 a bad API.
So, as a compromise we could could modify this documentation patch
to just not /document/ that option, while retaining all the other
documentation/discussion of the w-exe and the --lt-debug option.

There are four patches in this series:

1. Remove unneeded functions and options from cwrapper
committed: 75765d58c38c55ef069ef100732c1e978f4151a6

2. [PATCH] Enable runtime cwrapper debugging; add tests
http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00039.html
pending...

3. [PATCH] Add --lt-* options to shell wrapper
(just posted. Hasn't propagated to the archive yet, so no URL.
Obviously, still pending...)

4. [PATCH] Document wrapper changes
(this post. Obviously no URL yet, and also obviously pending...)

Together, these four obsolete and (I hope) address all of the comments
for
[PATCH] Document and test LT_DEBUGWRAPPER cwrapper macro
http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00031.html
as well as addressing the comments recieved so far in review of #2.

I'm posting #3 and #4 on the off chance that, for whatever reasons,
approval for #2 has been held up waiting for these two promised patches.



 NEWS |   11 
 doc/libtool.texi |   69 -
 2 files changed, 78 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 5a57891..64f27b6 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,17 @@ New in 2.2.8 2009-??-??: git version 2.2.7a, Libtool team:
   - New libtool command line flag --no-verbose, which disables only
 the extra verbose output messages and has no effect on the
 default informational messages.
+  - Wrapper scripts and wrapper executables for programs linked against
+uninstalled shared libraries now support command-line options --lt-debug
+and --lt-dump-script.
+
+* Important incompatible changes:
+
+  - The wrapper command line option support described above introduces the
+following incompatibility: the wrapper will remove any command line
+options that begin with '--lt-*' from the argument list before launching
+(uninstalled) programs. Any '--lt-*' option on the command line not
+recognized by the wrapper will result in an error.
 
 * Changes in supported systems or compilers:
 
diff --git a/doc/libtool.texi b/doc/libtool.texi
index a7872c6..8fa6f59 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -790,8 +790,9 @@ Note that libtool added the necessary run-time path flag, 
as well as
 @cindex wrapper scripts for programs
 @cindex program wrapper scripts
 Notice that the executable, @code{hell}, was actually created in the
-...@file{@value{objdir}} subdirectory.  Then, a wrapper script was created
-in the current directory.
+...@file{@value{objdir}} subdirectory.  Then, a wrapper script (or, on
+certain platforms, a wrapper executable @pxref{Wrapper executables}) was
+created in the current directory.
 
 Since libtool created a wrapper script, you should use libtool to
 install it and debug it too.  However, since the program does not depend
@@ -845,6 +846,70 @@ price of being dynamic is eight kilobytes, and the payoff 
is about four
 kilobytes.  So, having a shared @file{libhello} won't be an advantage
 until we link it against at least a few more programs.
 
+...@menu
+* Wrapper executables:: Wrapper executables for some platforms.
+...@end menu
+
+...@node Wrapper executables
+...@subsection Wrapper executables for programs
+...@cindex wrapper executables for programs
+...@cindex program wrapper executables
+
+Some platforms, notably those hosted on Windows such as Cygwin
+and MinGW, use a wrapper executable rather than a wrapper script
+to ensure proper operation of programs linked by libtool against
+uninstalled shared libraries. The wrapper executable thus performs
+the same function as the wrapper script used on other platforms, but
+allows to satisfy the @command{make} rules for the program, whose
+name ends in @code{$(EXEEXT)}. The actual program executable 

Re: [PATCH] Enable runtime cwrapper debugging; add tests

2009-07-12 Thread Charles Wilson
Charles Wilson wrote:
 I'll follow up this patch with another to add support for
   --lt-debug
   --lt-dump-script
 to the shell wrapper.  --lt-debug will do very little other than $ECHO
 the full path to the program executable and its arguments.
 --lt-dump-script will simply { cat $0  exit 0 }

See just-posted [PATCH] Add --lt-* options to shell wrapper

 Then I'll revise and retitle the remainder of
 [PATCH] Document and test LT_DEBUGWRAPPER cwrapper macro
 http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00031.html
 as appropriate.

See just-posted [PATCH] Document wrapper changes.

 Ping x2 ?

--
Chuck




Re: [PATCH] Document and test LT_DEBUGWRAPPER cwrapper macro

2009-07-12 Thread Charles Wilson
End thread. This patch has been obsoleted by:

1. Remove unneeded functions and options from cwrapper
committed: 75765d58c38c55ef069ef100732c1e978f4151a6

2. [PATCH] Enable runtime cwrapper debugging; add tests
http://lists.gnu.org/archive/html/libtool-patches/2009-06/msg00039.html
pending...

3. [PATCH] Add --lt-* options to shell wrapper
just posted. pending...

4. [PATCH] Document wrapper changes
just posted. pending...

--
Chuck




Re: [PATCH] [cygwin|mingw] fix dlpreopen with --disable-static take 6

2009-07-12 Thread Charles Wilson
Charles Wilson wrote:
 * libltdl/config/general.m4sh: Update copyright year.
 (func_tr_sh): New function.
 * libltdl/config/ltmain.m4sh (func_generate_dlsyms) [cygwin|mingw]:
 Obtain DLL name corresponding to import library by using value
 stored in unique variable libfile_$(transliterated implib name).
 If that fails, use $sharedlib_from_linklib_cmd to extract DLL
 name from import library directly. Also, properly extract dlsyms
 from the import library.
 (func_mode_link) [cygwin|mingw]: Prefer to dlpreopen DLLs
 over static libs when both are available.  When dlpreopening
 DLLs, use linklib (that is, import lib) as dlpreopen file,
 rather than DLL. Store name of associated la file in
 unique variable libfile_$(transliterated implib name)
 for later use.
 (func_win32_libid): Accomodate pei-i386 import libs
 as well as pe-i386.
 (func_cygming_dll_for_implib): New function.
 (func_cygming_dll_for_implib_fallback): New function.
 (func_cygming_dll_for_implib_fallback_core): New function.
 (func_cygming_gnu_implib_p): New function.
 (func_cygming_ms_implib_p): New function.
 * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Adjust sed
 expressions for lt_cv_sys_global_symbol_to_c_name_address and
 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
 as trailing space after module name is optional.
 (_LT_LINKER_SHLIBS) [cygwin|mingw][C++]:
 Set exclude_expsyms correctly for $host. Simplify regular
 expression in export_symbols_cmds.
 (_LT_LINKER_SHLIBS) [cygwin|mingw|pw32][C]: Set exclude_expsyms
 correctly for $host. Enable export_symbols_cmds to identify
 DATA exports by _nm_ prefix.
 (_LT_CHECK_SHAREDLIB_FROM_LINKLIB): New macro sets
 sharedlib_from_linklib_cmd variable.
 (_LT_DECL_DLLTOOL): New macro ensures DLLTOOL is always set.
 ---
 Reposted without change from -take5, here:
 http://lists.gnu.org/archive/html/libtool-patches/2009-01/msg00232.html
 
 This patch has been in use in the cygwin distribution since 2009-02-20.

Ping?

FYI, the cygwin distribution recently (Jul 4) released an updated
binutils package (2.19.51) for cygwin-1.7.  This version supports the
  --identify
and
  --identify-strict
options -- so, at least on cygwin-1.7 we won't be using the
func_cygming_dll_for_implib_fallback function.

Now, with the redesign proposed by Ralf back in January and implemented
(take 3? take 4? I forget), we ordinarily use NEITHER
  func_cygming_dll_for_implib_fallback
nor
  dlltool --identify-strict
because, in the ordinary case, we have a libtool .la file and use it to
track implib-dll.  NOW, the only time either of these two methods is
used, is when someone specifies explicitly an implib or DLL on the link
command passed to libtool:

  libtool mode=link  /my/path/foo.dll.a -lbar-3.dll

BUT...it's still nice that the (faster, less kludgy) dlltool method can
now be used on cygwin-1.7. (No, the standard toolchain from the
mingw.org guys doesn't yet support --identify-strict, so it still uses
the fallback).

--
Chuck