[cygwin, libtool] use shell function to emit wrapper scripts and wrapper.exe source [Was: Re: .exe magic]

2007-04-18 Thread Charles Wilson

[Added libtool-patches to CC list. Discussion of this patch
should probably drop libtool and cygwin]

Ralf Wildenhues wrote:

* Charles Wilson wrote on Wed, Apr 18, 2007 at 08:49:31PM CEST:
Caveat: over a year after the message referenced above, but libtool2.0 
is STILL in code-slush, so the desired fixes will have to wait until 
after 2.0


... I'd prefer to see such a patch before deciding when it's good to put
it in.


Okay, here's the first bit. It's pretty simple. Testing is in progress 
(and in conjuction with the new argz fix I just posted to 
libtool-patches), but looks good so far: the new wrapper scripts are 
identical to old ones generated without this patch.


--
Chuck

ChangeLog

2007-04-18  Charles Wilson  [EMAIL PROTECTED]

* libltdl/config/ltmain.m4sh [func_mode_link]: move wrapper
script writing from here...
[func_emit_libtool_wrapper_script]: to this new function, and
write to stdout
[func_mode_link]: move cwrapper source code writing from here...
[func_emit_libtool_cwrapperexe_source]: to this new function,
and write to stdout
[func_mode_link]: call the two new functions and redirect to
appropriate file.

Index: libltdl/config/ltmain.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.72
diff -u -r1.72 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  10 Apr 2007 19:09:26 -  1.72
+++ libltdl/config/ltmain.m4sh  19 Apr 2007 01:05:30 -
@@ -1202,6 +1202,555 @@
 }
 }
 
+# func_emit_libtool_wrapper_script
+# emit a libtool wrapper script on stdout
+# don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw 
+# wrapper executable.  Must ONLY be called from within
+# func_mode_link because it depends on a number of variable
+# set therein.
+func_emit_libtool_wrapper_script ()
+{
+   $ECHO \
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \\${ZSH_VERSION+set}\  (emulate sh) /dev/null 21; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\[EMAIL PROTECTED]}, 
which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\[EMAIL PROTECTED]}'='\[EMAIL PROTECTED]'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) /dev/null 21  unset CDPATH
+
+relink_command=\$relink_command\
+
+# This environment variable determines our operation mode.
+if test \\$libtool_install_magic\ = \$magic\; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='$macro_version'
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$ECHO are already set.
+  if test \\$libtool_execute_magic\ != \$magic\; then
+ECHO=\$qecho\
+file=\\$0\
+# Make sure echo works.
+if test \X\$1\ = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test \X\`{ \$ECHO '\t'; } 2/dev/null\`\ = 'X\t'; then
+  # Yippee, \$ECHO works!
+  :
+else
+  # Restart under the correct shell, and then maybe \$ECHO will work.
+  exec $SHELL \\$0\ --no-reexec \${1+\[EMAIL PROTECTED]}
+fi
+  fi\
+
+   $ECHO \
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$ECHO \X\$file\ | \$Xsed -e 's%/[^/]*$%%'\`
+  test \x\$thisdir\ = \x\$file\  thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \\$file\ | ${SED} -n 's/.*- //p'\`
+  while test -n \\$file\; do
+destdir=\`\$ECHO \X\$file\ | \$Xsed -e 's%/[^/]*\$%%'\`
+
+# If there was a directory component, then change thisdir.
+if test \x\$destdir\ != \x\$file\; then
+  case \\$destdir\ in
+  [/]* | [A-Za-z]:[/]*) thisdir=\\$destdir\ ;;
+  *) thisdir=\\$thisdir/\$destdir\ ;;
+  esac
+fi
+
+file=\`\$ECHO \X\$file\ | \$Xsed -e 's%^.*/%%'\`
+file=\`ls -ld \\$thisdir/\$file\ | ${SED} -n 's/.*- //p'\`
+  done
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \\$thisdir\  pwd\`
+  test -n \\$absdir\  thisdir=\\$absdir\
+
+
+   if test $fast_install = yes; then
+ 

Re: [cygwin, libtool] use shell function to emit wrapper scripts and wrapper.exe source [Was: Re: .exe magic]

2007-04-18 Thread Charles Wilson

Charles Wilson wrote:

Okay, here's the first bit. It's pretty simple. Testing is in progress 
(and in conjuction with the new argz fix I just posted to 
libtool-patches), but looks good so far: the new wrapper scripts are 
identical to old ones generated without this patch.


Test results -- old tests:
==
All 115 tests passed
(9 tests were not run) --- gcc-3.4.5 doesn't supply gfortran, only g77.
==

Test results -- new tests. Unexpected failures:
 14: Java convenience archives   FAILED (convenience.at:273)
 16: Link order of deplibs.  FAILED (link-order2.at:129)
 49: Run tests with low max_cmd_len  FAILED (cmdline_wrap.at:42)
are actually not unexpected on cygwin.  And certainly have nothing to do 
with this patch.


Actually, I think this is may be the best test conformance I've ever 
seen on cygwin...


--
Chuck




[cygwin, libtool] use shell function to emit wrapper scripts and wrapper.exe source [Was: Re: .exe magic]

2007-04-18 Thread Charles Wilson

[Added libtool-patches to CC list. Discussion of this patch
should probably drop libtool and cygwin]

Ralf Wildenhues wrote:

* Charles Wilson wrote on Wed, Apr 18, 2007 at 08:49:31PM CEST:
Caveat: over a year after the message referenced above, but libtool2.0 
is STILL in code-slush, so the desired fixes will have to wait until 
after 2.0


... I'd prefer to see such a patch before deciding when it's good to put
it in.


Okay, here's the first bit. It's pretty simple. Testing is in progress 
(and in conjuction with the new argz fix I just posted to 
libtool-patches), but looks good so far: the new wrapper scripts are 
identical to old ones generated without this patch.


--
Chuck

ChangeLog

2007-04-18  Charles Wilson  [EMAIL PROTECTED]

* libltdl/config/ltmain.m4sh [func_mode_link]: move wrapper
script writing from here...
[func_emit_libtool_wrapper_script]: to this new function, and
write to stdout
[func_mode_link]: move cwrapper source code writing from here...
[func_emit_libtool_cwrapperexe_source]: to this new function,
and write to stdout
[func_mode_link]: call the two new functions and redirect to
appropriate file.

Index: libltdl/config/ltmain.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.72
diff -u -r1.72 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  10 Apr 2007 19:09:26 -  1.72
+++ libltdl/config/ltmain.m4sh  19 Apr 2007 01:05:30 -
@@ -1202,6 +1202,555 @@
 }
 }
 
+# func_emit_libtool_wrapper_script
+# emit a libtool wrapper script on stdout
+# don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw 
+# wrapper executable.  Must ONLY be called from within
+# func_mode_link because it depends on a number of variable
+# set therein.
+func_emit_libtool_wrapper_script ()
+{
+   $ECHO \
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \\${ZSH_VERSION+set}\  (emulate sh) /dev/null 21; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\[EMAIL PROTECTED]}, 
which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\[EMAIL PROTECTED]}'='\[EMAIL PROTECTED]'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) /dev/null 21  unset CDPATH
+
+relink_command=\$relink_command\
+
+# This environment variable determines our operation mode.
+if test \\$libtool_install_magic\ = \$magic\; then
+  # install mode needs the following variables:
+  generated_by_libtool_version='$macro_version'
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$ECHO are already set.
+  if test \\$libtool_execute_magic\ != \$magic\; then
+ECHO=\$qecho\
+file=\\$0\
+# Make sure echo works.
+if test \X\$1\ = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test \X\`{ \$ECHO '\t'; } 2/dev/null\`\ = 'X\t'; then
+  # Yippee, \$ECHO works!
+  :
+else
+  # Restart under the correct shell, and then maybe \$ECHO will work.
+  exec $SHELL \\$0\ --no-reexec \${1+\[EMAIL PROTECTED]}
+fi
+  fi\
+
+   $ECHO \
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$ECHO \X\$file\ | \$Xsed -e 's%/[^/]*$%%'\`
+  test \x\$thisdir\ = \x\$file\  thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \\$file\ | ${SED} -n 's/.*- //p'\`
+  while test -n \\$file\; do
+destdir=\`\$ECHO \X\$file\ | \$Xsed -e 's%/[^/]*\$%%'\`
+
+# If there was a directory component, then change thisdir.
+if test \x\$destdir\ != \x\$file\; then
+  case \\$destdir\ in
+  [/]* | [A-Za-z]:[/]*) thisdir=\\$destdir\ ;;
+  *) thisdir=\\$thisdir/\$destdir\ ;;
+  esac
+fi
+
+file=\`\$ECHO \X\$file\ | \$Xsed -e 's%^.*/%%'\`
+file=\`ls -ld \\$thisdir/\$file\ | ${SED} -n 's/.*- //p'\`
+  done
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \\$thisdir\  pwd\`
+  test -n \\$absdir\  thisdir=\\$absdir\
+
+
+   if test $fast_install = yes; then
+