Re: [cygwin] cwrapper emits wrapper script

2007-06-06 Thread Charles Wilson

Peter O'Gorman wrote:
Could you please resend the patch itself, I am having issues with 
stripping the html markup from these links. (well, I can strip the html, 
but the resulting patch is not applying.)


Attached.

--
Chuck

2007-04-27  Charles Wilson  [EMAIL PROTECTED]

* ltmain.m4sh (func_emit_libtool_wrapper_script): add
code block to handle cases when wrapper script is in $objdir.
(func_emit_libtool_cwrapperexe_source): replace DEBUG() macro
with namespace-safe LTWRAPPER_DEBUGPRINTF(). Call
func_emit_libtool_wrapper_script() with appropriate filters to
embed script text in C char* static variable.
(f_e_l_c_s: main): add new option --lt-dump-script, parse argv[]
for it, and take appropriate action.  Call chase_symlinks()
on argv[0], in case this.exe was launched via one.  Use chased
value to determine full absolute pathname of wrapper script, in
$objdir. Unconditionally write script out to this pathname and
set permission bits.  Remove extraneous ';' from debugging loop.
(f_e_l_c_s: main) [mingw]: DOS-ize $SHELL before populating
newargv[0]; if $TARGETSHELL environment variable is set, use
it instead of $SHELL and do not DOS-ize.  Ensure newargv[1]
(wrapper script absolute path) uses only '/', not '\'.  Make
sure to call execv() with DOS-ized $SHELL (or un-DOS-ized
$TARGETSHELL, if set)
(f_e_l_c_s: make_executable): new function
(f_e_l_c_s: chase_symlinks): new function (no-op if !S_ISLNK)

2007-04-27  Charles Wilson  [EMAIL PROTECTED]

* ltmain.m4sh (func_emit_libtool_cwrapperexe_source):
ensure that generated source follows GCS as nearly as
possible.

Index: libltdl/config/ltmain.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.74
diff -u -r1.74 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  2007-04-24 23:04:28.546875000 -0400
+++ libltdl/config/ltmain.m4sh  2007-04-27 03:52:20.109375000 -0400
@@ -2301,6 +2301,20 @@
 file=\`ls -ld \\$thisdir/\$file\ | ${SED} -n 's/.*- //p'\`
   done
 
+  # cygwin/mingw cwrapper will rewrite this line:
+  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
+  if test \\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\ = \yes\; then
+# special case for '.'
+if test \\$thisdir\ = \.\; then
+  thisdir=\`pwd\`
+fi
+# remove .libs from thisdir
+case \\$thisdir\ in
+*[/]$objdir ) thisdir=\`\$ECHO \X\$thisdir\ | \$Xsed -e 
's%[/][^/]*$%%'\` ;;
+$objdir )   thisdir=. ;;
+esac
+  fi
+
   # Try to get the absolute directory name.
   absdir=\`cd \\$thisdir\  pwd\`
   test -n \\$absdir\  thisdir=\\$absdir\
@@ -2424,7 +2438,7 @@
This wrapper executable should never be moved out of the build directory.
If it is, it will not operate correctly.
 
-   Currently, it simply execs the wrapper *script* /bin/sh $output,
+   Currently, it simply execs the wrapper *script* $SHELL $output,
but could eventually absorb all of the scripts functionality and
exec $objdir/$outputname directly.
 */
@@ -2438,6 +2452,7 @@
 #include assert.h
 #include string.h
 #include ctype.h
+#include errno.h
 #include sys/stat.h
 
 #if defined(PATH_MAX)
@@ -2482,12 +2497,11 @@
   if (stale) { free ((void *) stale); stale = 0; } \
 } while (0)
 
-/* -DDEBUG is fairly common in CFLAGS.  */
-#undef DEBUG
+#undef LTWRAPPER_DEBUGPRINTF
 #if defined DEBUGWRAPPER
-# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
+# define LTWRAPPER_DEBUGPRINTF(format, ...) fprintf(stderr, format, 
__VA_ARGS__)
 #else
-# define DEBUG(format, ...)
+# define LTWRAPPER_DEBUGPRINTF(format, ...)
 #endif
 
 const char *program_name = NULL;
@@ -2496,42 +2510,145 @@
 char * xstrdup (const char *string);
 const char * base_name (const char *name);
 char * find_executable(const char *wrapper);
+char * chase_symlinks(const char *pathspec);
+intmake_executable(const char *path);
 intcheck_executable(const char *path);
 char * strendzap(char *str, const char *pat);
 void lt_fatal (const char *message, ...);
 
+static const char* script_text = 
+EOF
+
+   func_emit_libtool_wrapper_script |
+   $SED -e 's/\([\\]\)/\\\1/g' \
+-e 's/\(WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\)=.*/\1=yes/' \
+-e 's/^//' -e 's/$/\\n/' 
+   echo ;
+
+   cat EOF
 int
 main (int argc, char *argv[])
 {
   char **newargz;
+  char *tmp_pathspec;
+  char *actual_cwrapper_path;
+  char *shwrapper_name;
+  FILE *shwrapper;
+
+  const char* dumpscript_opt = --lt-dump-script;
   int i;
 
   program_name = (char *) xstrdup (base_name (argv[0]));
-  DEBUG((main) argv[0]  : %s\n,argv[0]);
-  DEBUG((main) program_name : %s\n,program_name);
+  LTWRAPPER_DEBUGPRINTF((main) argv[0]  : %s\n,argv[0]);
+  LTWRAPPER_DEBUGPRINTF((main) program_name : %s\n,program_name);
+
+ 

Re: [cygwin] cwrapper emits wrapper script

2007-06-06 Thread Peter O'Gorman
On Wed, 2007-06-06 at 10:25 -0400, Charles Wilson wrote:
 Peter O'Gorman wrote:
  Could you please resend the patch itself, I am having issues with 
  stripping the html markup from these links. (well, I can strip the html, 
  but the resulting patch is not applying.)
 
 Attached.

Thanks, I'll look again tonight (I hope).

I'm lazy and would like to avoid work as much as possible, Gary has
already asked if you'd like a commit bit, I'm hoping you'll agree, then
all we'll need to do is say ok and you can commit your changes
yourself.

So, you have an account on savannah? (chawil?)

Peter




Re: [cygwin] cwrapper emits wrapper script

2007-06-06 Thread libtool
On Wed, 06 Jun 2007 09:43:50 -0500, Peter O'Gorman said:
 I'm lazy and would like to avoid work as much as possible, Gary has
 already asked if you'd like a commit bit, I'm hoping you'll agree, then
 all we'll need to do is say ok and you can commit your changes
 yourself.

As long as somebody other than me inspects/approves (...or rejects) my
patches, I'm happy to turn the crank to check them in myself.

--
Chuck




Re: [cygwin] cwrapper emits wrapper script

2007-06-06 Thread Peter O'Gorman
On Wed, 2007-06-06 at 10:25 -0400, Charles Wilson wrote:
 Peter O'Gorman wrote:
  Could you please resend the patch itself, I am having issues with 
  stripping the html markup from these links. (well, I can strip the html, 
  but the resulting patch is not applying.)
 
 Attached.
 
 --
 Chuck
 
 2007-04-27  Charles Wilson  [EMAIL PROTECTED]
 
   * ltmain.m4sh (func_emit_libtool_wrapper_script): add
   code block to handle cases when wrapper script is in $objdir.
   (func_emit_libtool_cwrapperexe_source): replace DEBUG() macro
   with namespace-safe LTWRAPPER_DEBUGPRINTF(). Call
   func_emit_libtool_wrapper_script() with appropriate filters to
   embed script text in C char* static variable.
   (f_e_l_c_s: main): add new option --lt-dump-script, parse argv[]
   for it, and take appropriate action.  Call chase_symlinks()
   on argv[0], in case this.exe was launched via one.  Use chased
   value to determine full absolute pathname of wrapper script, in
   $objdir. Unconditionally write script out to this pathname and
   set permission bits.  Remove extraneous ';' from debugging loop.
   (f_e_l_c_s: main) [mingw]: DOS-ize $SHELL before populating
   newargv[0]; if $TARGETSHELL environment variable is set, use
   it instead of $SHELL and do not DOS-ize.  Ensure newargv[1]
   (wrapper script absolute path) uses only '/', not '\'.  Make
   sure to call execv() with DOS-ized $SHELL (or un-DOS-ized
   $TARGETSHELL, if set)
   (f_e_l_c_s: make_executable): new function
   (f_e_l_c_s: chase_symlinks): new function (no-op if !S_ISLNK)
 
 2007-04-27  Charles Wilson  [EMAIL PROTECTED]
 
   * ltmain.m4sh (func_emit_libtool_cwrapperexe_source):
   ensure that generated source follows GCS as nearly as
   possible.
 

Ok. Causes no regressions for me on linux or darwin, and nothing jumps
out at me, please feel free to exercise your commit bit on these :-)
I am not, unfortunately, able to test on windows.

Noah gave a good suggestion about passing
WRAPPER_SCRIPT_BELONGS_IN_OBJDIR as an argument, but, I agree, it can be
left to a later patch.

At some point it would be nice to emit
func_emit_libtool_cwrapperexe_source from config.status, saving 550
lines of code from libtool on non-windows platforms. But I'm just
dreaming, you can ignore that :)

Thank you!

Peter