Subject: bug#9289: Feature request: Better 'nobase_' support for nonrecursive build system.

From: Krzesimir Nowak <[email-masked]>
Date: Fri, 12 Aug 2011 09:51:27 +0200

Package: automake
Version: 1.11.1

'nobase_' is quite a useful prefix when we want to distribute exact
directory structure like it is in our code repository. But its
usefullness is quite dimnished in case of nonrecursive build system
generated by automake. Lets have a look at the example below:

Our directory structure is as follows:
/
+-foo
  +-bar
  | +-baz
  | | +-1.x
  | | `-2.x
  | `-3.x
  `-4.x

I'd like to put every file under `foo' directory without the `foo'
directory into, say, $(datadir)/qaz. Effectively, our $(datadir)/qaz
structure would look as follows:
$(datadir)/qaz
+-bar
| +-baz
| | +-1.x
| | `-2.x
| `-3.x
`-4.x

With recursive build system it was really simple - just putting
Makefile.am in $(top_srcdir)/foo directory with contents as follows:
list_of_files = bar/baz/1.x bar/baz/2.x bar/3.x 4.x
qazdir = $(datadir)/qaz
nobase_dist_qaz_DATA = $(list_of_files)

In nonrecursive build system, where Makefile in only at $(top_srcdir)
this is not going to work, because there is no such file like
$(top_srcdir)/4.x - it is in foo directory. Also, adding `foo/' prefix
to all elements of list_of_files variable won't work in the way we want,
because foo directory will be put into $(datadir)/qaz.

For now, as a workaround, we have to list all directories and
subdirectories explicitly:
qazdir = $(datadir)/qaz
dist_qaz_DATA = foo/4.x
qaz_bardir = $(datadir)/qaz/bar
dist_qaz_bar_DATA = foo/bar/3.x
qaz_bar_bazdir = $(datadir)/qaz/bar/baz
dist_qaz_bar_baz_DATA = foo/bar/baz/1.x foo/bar/baz/2.x

This can be bit tedious when directory structure is bit more complex -
maybe some kind of script generating a filelist.am with the contents
above could be employed, but it would obscure the build system more.

Another solution would be just using install-{data,exec}-hook.

My proposal would be maybe a special dynamic prefix like
`nobasecut<num>', where `<num>' is a number of directories to strip from
name (just like -p parameter in `patch' utility works) before installing
it in target directory. That way, we could then write in our top-level
Makefile.am:
list_of_files = foo/bar/baz/1.x foo/bar/baz/2.x foo/bar/3.x foo/4.x
qazdir = $(datadir)/qaz
nobasecut1_dist_qaz_DATA = $(list_of_files)

Question is if this is even possible for Automake to deduce from
`nobasecut1' that one level of directories should be stripped and what
additional features of make that would need?

What do you think?