Re: Speed up progname, progpath setting

2008-04-11 Thread Peter O'Gorman
Ralf Wildenhues wrote:
> * Bob Friesenhahn wrote on Fri, Apr 11, 2008 at 12:12:45AM CEST:
>> On Thu, 10 Apr 2008, Ralf Wildenhues wrote:
>>> On systems where $PWD happens to not work, we shouldn't care about
>>> performance, they are so rare.
>> We should define what it means for PWD to work.
> 
> My intention was to use it only in places where it doesn't matter
> whether logical or physical paths are used.  For example progpath,
> where all that's needed is that we can grep/sed the libtool script.

Yes, thus avoiding the possible forks for cd and pwd. I think using $PWD
for this is fine.

Peter
-- 
Peter O'Gorman
http://pogma.com




Re: Speed up progname, progpath setting

2008-04-10 Thread Ralf Wildenhues
* Bob Friesenhahn wrote on Fri, Apr 11, 2008 at 12:12:45AM CEST:
> On Thu, 10 Apr 2008, Ralf Wildenhues wrote:
>>
>> On systems where $PWD happens to not work, we shouldn't care about
>> performance, they are so rare.
>
> We should define what it means for PWD to work.

My intention was to use it only in places where it doesn't matter
whether logical or physical paths are used.  For example progpath,
where all that's needed is that we can grep/sed the libtool script.

Cheers,
Ralf




Re: Speed up progname, progpath setting

2008-04-10 Thread Bob Friesenhahn

On Thu, 10 Apr 2008, Ralf Wildenhues wrote:


On systems where $PWD happens to not work, we shouldn't care about
performance, they are so rare.


We should define what it means for PWD to work.  Using the ZSH shell:

% echo `/bin/pwd`
/scratch/bfriesen/build/GraphicsMagick-1.1-16-static

% echo `pwd`
/home/bfriesen/build/GraphicsMagick-1.1-16-static

% echo $PWD
/home/bfriesen/build/GraphicsMagick-1.1-16-static

Note that only /bin/pwd revealed the true path, but the shell's notion 
of the path is more pleasing to me since it is reporting how I got to 
the working directory and nicely hides that there was a symbolic link 
involved.


Bob
==
Bob Friesenhahn
[EMAIL PROTECTED], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/





Re: Speed up progname, progpath setting

2008-04-10 Thread Ralf Wildenhues
* Peter O'Gorman wrote on Thu, Apr 10, 2008 at 11:21:01PM CEST:
> Peter O'Gorman wrote:
> > Ralf Wildenhues wrote:
> >>   curwd=`cd . && pwd`
> >>
> >> Do we know when (with which shells) this can be replaced by $PWD
> >> portably?
> > 
> > The ones that are not buggy and comply with the standards? :) (I don't
> > know, maybe all of them).
> 
> Maybe, instead of using $PWD, when the package is not libtool itself, we
> can substitute abs_top_builddir into the libtool script and use that for
> when progdir=.?

We can also just test for working $PWD in configure, and if it works,
then
  curwd=$PWD
  cd "..."
  progdir=$PWD
  cd "curwd"

On systems where $PWD happens to not work, we shouldn't care about
performance, they are so rare.

Given that we more and more rely on the shell we test in configure is
the same as the one executing libtool, I am tending more and more to
putting Bruno's patch in.

Cheers,
Ralf




Re: Speed up progname, progpath setting

2008-04-10 Thread Peter O'Gorman
Peter O'Gorman wrote:
> Ralf Wildenhues wrote:
>> OK to apply?
> 
> Yes, thanks.
> 
>> What about eliminating (when progdir='.')
>>   curwd=`cd . && pwd`
>>
>> Do we know when (with which shells) this can be replaced by $PWD
>> portably?
> 
> The ones that are not buggy and comply with the standards? :) (I don't
> know, maybe all of them).

Maybe, instead of using $PWD, when the package is not libtool itself, we
can substitute abs_top_builddir into the libtool script and use that for
when progdir=.?

Peter
-- 
Peter O'Gorman
http://pogma.com




Re: Speed up progname, progpath setting

2008-04-09 Thread Eric Blake

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Peter O'Gorman on 4/9/2008 10:19 PM:
|> What about eliminating (when progdir='.')
|>   curwd=`cd . && pwd`
|>
|> Do we know when (with which shells) this can be replaced by $PWD
|> portably?
|
| The ones that are not buggy and comply with the standards? :) (I don't
| know, maybe all of them).

To some degree, it depends on whether you are okay with $PWD being logical
on platforms where pwd behaves like the posix 'pwd -P'; however, since
autoconf documents that you can't reliably expect either 'pwd -L' or 'pwd
- -P', you have to deal with both anyway.  But I personally don't know how
likely you are to hit a shell that forgets to assign PWD.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkf9l6QACgkQ84KuGfSFAYB1cQCfbSg9VOLCutPYN3N64PrYgSWg
fF8AnRbBdPGsdSZrCA9xhro679+xuVku
=Ahjz
-END PGP SIGNATURE-




Re: Speed up progname, progpath setting

2008-04-09 Thread Peter O'Gorman
Ralf Wildenhues wrote:
> OK to apply?

Yes, thanks.

> 
> What about eliminating (when progdir='.')
>   curwd=`cd . && pwd`
> 
> Do we know when (with which shells) this can be replaced by $PWD
> portably?

The ones that are not buggy and comply with the standards? :) (I don't
know, maybe all of them).


> 2008-04-10  Ralf Wildenhues  <[EMAIL PROTECTED]>
> 
>   * libltdl/m4/libtool.m4 (_LT_PROG_XSI_SHELLFNS): Move non-XSI
>   definition of func_dirname_and_basename ...
>   * libltdl/config/general.m4sh (func_dirname_and_basename):
>   ...  here, to use it for the other scripts that use general.m4sh
>   (and as portable fallback for libtool).  Add marker for early
>   insertion of generated shell functions (into libtool, not the
>   other scripts) here.
>   Use func_dirname_and_basename to compute progname, progpath.
>   * libltdl/config/ltmain.m4sh (func_mode_help): Remove marker
>   for insertion of generated shell functions.
>   * tests/sh.test: Adjust function definition test to not match
>   function call.

Thank you again,
Peter
-- 
Peter O'Gorman
http://pogma.com




Speed up progname, progpath setting

2008-04-09 Thread Ralf Wildenhues
OK to apply?

What about eliminating (when progdir='.')
  curwd=`cd . && pwd`

Do we know when (with which shells) this can be replaced by $PWD
portably?

Thanks,
Ralf

2008-04-10  Ralf Wildenhues  <[EMAIL PROTECTED]>

* libltdl/m4/libtool.m4 (_LT_PROG_XSI_SHELLFNS): Move non-XSI
definition of func_dirname_and_basename ...
* libltdl/config/general.m4sh (func_dirname_and_basename):
...  here, to use it for the other scripts that use general.m4sh
(and as portable fallback for libtool).  Add marker for early
insertion of generated shell functions (into libtool, not the
other scripts) here.
Use func_dirname_and_basename to compute progname, progpath.
* libltdl/config/ltmain.m4sh (func_mode_help): Remove marker
for insertion of generated shell functions.
* tests/sh.test: Adjust function definition test to not match
function call.

Index: libltdl/config/general.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/general.m4sh,v
retrieving revision 1.10
diff -u -r1.10 general.m4sh
--- libltdl/config/general.m4sh 9 Mar 2008 14:12:10 -   1.10
+++ libltdl/config/general.m4sh 9 Apr 2008 23:24:13 -
@@ -61,6 +61,32 @@
 dirname="s,/[^/]*$,,"
 basename="s,^.*/,,"
 
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+#   dirname:  Compute the dirname of FILE.  If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+#   basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+  # Extract subdirectory from the argument.
+  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+  if test "X$func_dirname_result" = "X${1}"; then
+func_dirname_result="${3}"
+  else
+func_dirname_result="$func_dirname_result${2}"
+  fi
+  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+# Generated shell functions inserted here.
+
 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
 # is ksh but when the shell is invoked as "sh" and the current value of
 # the _XPG environment variable is not equal to 1 (one), the special
@@ -71,13 +97,17 @@
 # The name of this program:
 # In the unlikely event $progname began with a '-', it would play havoc with
 # func_echo (imagine progname=-n), so we prepend ./ in that case:
-progname=`$ECHO "X$progpath" | $Xsed -e "$basename" -e 's,^-,./-,'`
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+case $progname in
+  -*) progname=./$progname ;;
+esac
 
 # Make sure we have an absolute path for reexecution:
 case $progpath in
   [\\/]*|[A-Za-z]:\\*) ;;
   *[\\/]*)
- progdir=`$ECHO "X$progpath" | $Xsed -e "$dirname"`
+ progdir=$func_dirname_result
  progdir=`cd "$progdir" && pwd`
  progpath="$progdir/$progname"
  ;;
Index: libltdl/config/ltmain.m4sh
===
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.102
diff -u -r1.102 ltmain.m4sh
--- libltdl/config/ltmain.m4sh  16 Mar 2008 08:34:25 -  1.102
+++ libltdl/config/ltmain.m4sh  9 Apr 2008 23:24:15 -
@@ -432,9 +432,6 @@
 exit $?
 }
 
-# Generated shell functions inserted here.
-
-
 # Parse options once, thoroughly.  This comes as soon as possible in
 # the script to make things like `libtool --version' happen quickly.
 {
Index: libltdl/m4/libtool.m4
===
RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v
retrieving revision 1.146
diff -u -r1.146 libtool.m4
--- libltdl/m4/libtool.m4   1 Apr 2008 18:23:19 -   1.146
+++ libltdl/m4/libtool.m4   9 Apr 2008 23:24:17 -
@@ -7189,29 +7189,9 @@
   func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
 }
 
-# func_dirname_and_basename file append nondir_replacement
-# perform func_basename and func_dirname in a single function
-# call:
-#   dirname:  Compute the dirname of FILE.  If nonempty,
-# add APPEND to the result, otherwise set result
-# to NONDIR_REPLACEMENT.
-# value returned in "$func_dirname_result"
-#   basename: Compute filename of FILE.
-# value retuned in "$func_basename_result"
-# Implementation must be kept synchronized with func_dirname
-# and func_basename. For efficiency, we do not delegate to
-# those functions but instead duplicate the functionality here.
-func_dirname_and_basename ()
-{
-  # Extract subdirectory from the argument.
-  func_dir