Discussion:
include verbatim or (escape %D%) possible?
Thomas Martitz
2015-07-24 21:15:54 UTC
Permalink
Hello,

my name is Thomas Martitz and I'd say quite knowledgeable with automake.
However I've hit a road block that I'm unable to resolve. I'm also new
to this list, so please bear with me.

I'm trying to port a project to non-recursive automake following[1]. I
have come across a problem with this specific project. It uses
convinience mk that are included by various Makefile.ams. For example,
one of those convinience .mk files fills EXTRA_DIST with files that are
expected in the directory of the Makefile.am. Below is a very simplified
example of that project.

$ cat build/vars.mk
EXTRA_DIST=README COPYING

$ cat plugin1/Makefile.am
include $(top_srcdir)/build/vars.mk
$ ls plugin1/{README,COPYING}
plugin1/README plugin1/COPYING

$ cat Makefile.am
SUBDIRS = plugin1

Now, the problem comes when I try to port that Makefile.am to be
included by the top-level Makefile.am
$ cat Makefile.am
EXTRA_DIST=
include plugin1/Makefile.am

$ cat build/vars.mk
EXTRA_DIST+=README COPYING

The problem: README and COPYING are now assumed to be in the root
directory (which is understandable, given vars.mk now is indirectly
included by top-level Makefile.am).

I tried to use %reldir% / %D%:
$ cat build/vars.mk
EXTRA_DIST+=%D%/README %D%7COPYING

But the effect is that README and COPYING are assumed to be in the
*build* directory. I guess this is because %D% is expanded to the dir of
the actual fragment file where it's used in.

So what I'm asking is: Can I somehow raw/verbatim include into
plugin1/Makefile.am so that %D% refers to plugin1? Or is there some way
to escape %D% once? Or is there another way to have README refer to the
plugin1/README file by using the convinience .mk file?

Please help me.

Best regards
Thomas Martitz

[1]: http://karelzak.blogspot.de/2013/02/non-recursive-automake.html
Bob Friesenhahn
2015-07-25 14:11:34 UTC
Permalink
Post by Thomas Martitz
So what I'm asking is: Can I somehow raw/verbatim include into
plugin1/Makefile.am so that %D% refers to plugin1? Or is there some way to
escape %D% once? Or is there another way to have README refer to the
plugin1/README file by using the convinience .mk file?
Given that everything ends up in one Makefile, I don't think that
including any given .mk file more than once is going to work at all.
The strategy of incuding common .mk files into a per-directory
Makefile is to support recursive build schemes.

Nothing prevents from using a script which builds specialized .mk
files for each subdirectory. A template file can be used with
substitutions performed on it to localize it for the subdirectory.
If there are a great many similar subdirectories, the same script can
write a .mk file with include statements to also include the many
subdirectory fragments.

When I converted my project to be non-recursive, it was before
Automake included any special support for includes in non-recursive
builds. I hard-coded the sub-directory offset inside each included
.mk file via a definition and then built all needed definitions based
on that. I did not even trust += syntax (due to lack of control over
order) so everything is explicit. This was ok since there were not
hundreds of subdirectories.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Loading...