Re: automake/535: Extract correct man section from files in MAN_MANS

2009-03-07 Thread Peter Breitenlohner

On Sat, 7 Mar 2009, Ralf Wildenhues wrote:


Attached is a small patch (current git) correcting this problem.



@@ -39,8 +39,8 @@ if %?NOTRANS_MANS%
 ## Extract all items from notrans_man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
 ?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; for i in $$l2; do \
-## Accept files like `foo.1c'.
-?HAVE_NOTRANS?   case $$i in *.%SECTION%*) echo $$i;; esac; \
+## Accept for `man1' files like `foo.1c' but not `sub.1/foo.2' or `foo-2.1.4'.
+?HAVE_NOTRANS?   case `echo $$i | sed -e 's,.*\.,,'` in %SECTION%*) echo 
$$i;; esac; \
 ?HAVE_NOTRANS? done; \
 ## Extract basename of manpage, change the extension if needed.
} | while read p; do \


This has the disadvantage that we're now again forking at least twice
per installed file.  The point of the install rule changes in master
was to make them faster!  :-)

I don't know a good way to fix this without adding any forks at all, but
the patch below fixes the issue for master with adding two forks per set
of man pages installed.  It uses the same regex for matching the section
as is used in automake.in.


Hallo Ralf,

actually, I never thought about that aspect.

I think there is a way to reduce the number of forks, replacing the two
loops by one such that one could extract ext rather early and reuse it later
on.  However, this would be major surgery and require extensive testing.

The idea is roughly this, e.g., for the install-man1 target:

dot_seen=no
for i in $(man1_MANS) . $(man_MANS); do
  if test x$i = x.; then
dot_seen=yes
continue
  fi
  ext=`echo $i | sed -e 's/^.*\\.//'`
  case $ext in
1*) ;;
*) if test $dot_seen = yes; then
 continue
   else
 ext=1
   fi ;;
  esac
  [proceed as now, reusing the ext extracted above]
done

Could also be 'dot_seen=false', 'dot_seen=:', and 'if $dot_seen; then'.

This is for branch-1-10. Perhaps something analogous can be done for the new
scheme in git master (just updated my local copy, still have to study it).

Comments?


+# Let's play with $DESTDIR too, it shouldn't hurt.
+./configure --prefix='' --mandir=/man


Let's just omit --prefix here, rather than passing an empty one.
Also, let's add a 'make uninstall' as well as the notrans man pages,
so all changed code paths are exercised; and rename a bit, so we can
better test that no wrong directories are created.


Shall I try to do that, or will you (knowing better exactly what you have in
mind)?

Regards,
Peter Breitenlohner p...@mppmu.mpg.de




Re: automake/535: Extract correct man section from files in MAN_MANS

2009-03-07 Thread Ralf Wildenhues
Hello Peter,

* Peter Breitenlohner wrote on Sat, Mar 07, 2009 at 04:56:10PM CET:
 On Sat, 7 Mar 2009, Ralf Wildenhues wrote:

 I don't know a good way to fix this without adding any forks at all, but
 the patch below fixes the issue for master with adding two forks per set
 of man pages installed.  It uses the same regex for matching the section
 as is used in automake.in.

 I think there is a way to reduce the number of forks, replacing the two
 loops by one such that one could extract ext rather early and reuse it later
 on.  However, this would be major surgery and require extensive testing.

Let's not go this way.  The current git master version works well in
this regard, with less than a dozen forks per 40 manpages that go in
the same directory, of those typically only one or two `install'
commands (which are by far the most expensive of them).

 This is for branch-1-10. Perhaps something analogous can be done for the new
 scheme in git master (just updated my local copy, still have to study it).

 Comments?

Well, your scheme still forks once per file, when computing $ext.
Don't worry about it, I'm not interested in making branch-1-10 faster,
all that work has gone into git master already and will be in 1.11.

 +# Let's play with $DESTDIR too, it shouldn't hurt.
 +./configure --prefix='' --mandir=/man

 Let's just omit --prefix here, rather than passing an empty one.
 Also, let's add a 'make uninstall' as well as the notrans man pages,
 so all changed code paths are exercised; and rename a bit, so we can
 better test that no wrong directories are created.

 Shall I try to do that, or will you (knowing better exactly what you have in
 mind)?

Erm, I've already done all that in the patch that I posted; and I have
applied to master.  So there is nothing left to do on this topic, except
to argue (if you want) that this should be fixed in branch-1-10.  :-)

Cheers,
Ralf




Improve `make -n dist' and `make -n distcheck' for GNU make.

2009-03-07 Thread Ralf Wildenhues
I noticed that `make -n dist' touches the build tree, in that it creates
directories $(distdir) and below.  Also, `make -n distcheck' bails out
with some error due to missing directories.  (BTW, I'm unsure whether
this has been reported before; if yes, speak up and I'll thank ya!)

This happens because, even in the presence of `-n', GNU (and Solaris)
make executes rule commands that contain the string `$(MAKE)'.  This is
all Good[tm] in general, but it means that we should separate commands
that change files from those that only recurse, and where not possible
(distcheck), ensure to bail out early and cleanly.

This patch fixes these issues.  The second test is mostly identical to
the first one, except that it ensures that GNU make produces sufficient
output.

One more patch to improve things for some BSD make versions coming up.
I'm not sure whether rule commands prefixed by `+' are portable enough
or desirable in Automake-provided rules; they have never been used so
far.  So I might want to avoid using it for now.

Pushed to master; I thought about branch-1-10, too, as the patch does
not seem all that intrusive, but master has seen other necessary fixes,
most notably 4a6593e3b (Fix the distdir target to cope with spaces in
absolute file names).

Cheers,
Ralf

Improve `make -n dist' and `make -n distcheck' for GNU make.

Ensure that `make -n dist' and `make -n distcheck' do not change
files, due to GNU make executing rules containing `$(MAKE)'.

* lib/am/distdir.am (distdir): Separate the creation of
`$(distdir)/$$subdir' for `$(DIST_SUBDIRS)' and the recursion
into the `$(DIST_SUBDIRS)' in two separate rule commands.
(distcheck): Exit recursive rule early when run with `make -n',
as detected by a witness file.
* tests/maken.test, tests/maken2.test: New tests.
* tests/Makefile.am: Update.
* NEWS: Update.

diff --git a/NEWS b/NEWS
index 6fcc1a5..d4b59e9 100644
--- a/NEWS
+++ b/NEWS
@@ -170,6 +170,9 @@ Bugs fixed in 1.10a:
 containing the error message, but exit successfully.  However, `make dist'
 will ensure that no such bogus man pages are packaged into a tarball.
 
+  - Targets provided by automake behave better with `make -n', in that they
+take care not to create files.
+
 * Bugs introduced by 1.10:
 
   - Fix output of dummy dependency files in presence of post-processed
diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index 5acfa49..ad5e771 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -220,12 +220,18 @@ endif %?TOPDIR_P%
 ## directory, then we use `distdir' instead of `top_distdir'; this lets
 ## us work correctly with an enclosing package.
 ##
+## Split the loop for the directory creation and the one for recursion,
+## so that with GNU make -n, only the latter is executed.
 if %?SUBDIRS%
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
  if test $$subdir = .; then :; else \
test -d $(distdir)/$$subdir \
|| $(MKDIR_P) $(distdir)/$$subdir \
|| exit 1; \
+ fi; \
+   done
+   @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test $$subdir = .; then :; else \
dir1=$$subdir; dir2=$(distdir)/$$subdir; \
$(am__relativize); \
new_distdir=$$reldir; \
@@ -418,6 +424,12 @@ distcheck: dist
mkdir $(distdir)/_inst
 ## Undo the write access.
chmod a-w $(distdir)
+## With GNU make, the following command will be executed even with `make -n',
+## due to the presence of `$(MAKE)'.  That is normally all well (and `$(MAKE)'
+## is necessary for things like parallel distcheck), but here we don't want
+## execution.  To avoid MAKEFLAGS parsing hassles, use a witness file that a
+## non-`-n' run would have just created.
+   test -d $(distdir)/_build || exit 0; \
 ## Compute the absolute path of `_inst'.  Strip any leading DOS drive
 ## to allow DESTDIR installations.  Otherwise $(DESTDIR)$(prefix) would
 ## expand to c:/temp/am-dc-5668/c:/src/package/package-1.0/_inst.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d4687f4..15e8e61 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -393,6 +393,8 @@ lzma.test \
 maintclean.test \
 make.test \
 makej.test \
+maken.test \
+maken2.test \
 makevars.test \
 man.test \
 man2.test \
diff --git a/tests/maken.test b/tests/maken.test
new file mode 100755
index 000..8219ec6
--- /dev/null
+++ b/tests/maken.test
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2009  Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public 

substitute datadir in python script

2009-03-07 Thread Bastien Dalla Piazza
Hi all,

I'm developing an application with mixed C++ and python.

I wonder how to do the following:

let's assume alib.la is a python extention library installed in
$(pyexecdir) which depends on the prefix given by the user.

Up to now, I was substituting the absolute directories path at install
time using sed on my scripts source files, so adding to Makefile.am:

ascript.py: ascript_src.py
sed -e
s#sys.append('pyexecdir')#sys.append('$(pyexecdir)')#g;s#datadir#
$(datadir)/@PACKAGE@/#g ascript_src.py  ascript.py

substituting pyexecdir in order to allow import alib in the
installed scripts and datadir to allow access to the installed data
files (like images).

This solution feels a bit clumsy because I need the file names
ascript_src.py and ascript.py to deferenciate the original and the
substituted files.
I think I need an equivalent in python of the config.h header file,
but where to install it? Or is there a standard way to achieve the
substitutions?

Thanks!


automake less verbose branch

2009-03-07 Thread Ralf Wildenhues
Hello Jan, all,

I've worked a bit on the less verbose automake stuff, and put the result
up as a branch in the git repository:
  git clone git://git.savannah.gnu.org/automake.git
  git branch je-silent origin/je-silent-am

It would be *great* if you (or whoever wants to) could test it, play
around with it, use it on various packages, and ideally also on
different systems and make implementations if possible.  Every bit
helps.

I won't promise that this branch will never be rewound, but I sure
hope to be able to soon finish the other open topics, and then merge
them for an 1.11 alpha.

Detailed patch descriptions will follow on automake-patches, not sure if
today, though.  Please discuss/send patches on the -patches list.

Thanks,
Ralf




Re: automake less verbose branch

2009-03-07 Thread Jan Engelhardt

On Saturday 2009-03-07 16:16, Ralf Wildenhues wrote:

Hello Jan, all,

I've worked a bit on the less verbose automake stuff, and put the result
up as a branch in the git repository:
  git clone git://git.savannah.gnu.org/automake.git
  git branch je-silent origin/je-silent-am
origin/je-silent

It would be *great* if you (or whoever wants to) could test it, play
around with it, use it on various packages, and ideally also on
different systems and make implementations if possible.  Every bit
helps.

I am missing the definition of am__v_GEN in the generated Makefile
that is designed for use with manual rules. Like,

# -*- Makefile -*-

man8_MANS = foo.8

foo.8: foo.8.in
${am__v_GEN}man -l foo.8.in $@