[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: builddir vs. srcdir
From: |
Paul Pogonyshev |
Subject: |
Re: builddir vs. srcdir |
Date: |
Fri, 18 Mar 2005 21:34:15 +0200 |
User-agent: |
KMail/1.4.3 |
> Hello,
>
> On Sat, Mar 12, 2005 at 06:56:20PM +0200, Paul Pogonyshev wrote:
> > Everything seems to work just fine and as expected,
>
> your code, which is in whole cited below, doesn't actually know
> about the dependency
> foo.c foo.h: foo.list
>
> So if you change the .list file, the other files won't be rebuilt.
> This might be a dangerous bug.
It doesn't know about the dependency, but the files will be rebuilt
as a ``side-effect'' of the timestamp rule. I actually just tried
this out.
> In general, stamps are always dangerous, so it's good to avoid them if
> possible. I'd try something like this:
>
> [file `aux/list.make']
> SUFFIXES = .list
> .list.c: Makefile $(PARSE_LIST_COMMAND)
> $(PARSE_LIST_BUILD_RULE)
> .list.h: Makefile $(PARSE_LIST_COMMAND)
> $(PARSE_LIST_BUILD_RULE)
> PARSE_LIST_BUILD_RULE = \
> $(PARSE_LIST_COMMAND) $(PARSE_LIST_FLAGS) \
> `test -f '$<' || echo '$(srcdir)/'`$< $*.h $*.c && \
> touch $*.h
>
> [usage]
> LIST_FILES = foo.list bar.list
> # Prevent problems with parallel make:
> foo.h: foo.c
> bar.h: bar.c
>
> PARSE_LIST_COMMAND = ...
> PARSE_LIST_FLAGS = ...
>
> noinst_LIBRARIES = libfoo.a
> libfoo_a_SOURCES = ... $(LIST_FILES)
>
> # This hint is needed only for included files; *.c files
> # are handled by normal target dependencies:
> BUILT_SOURCES = $(LIST_FILES:.list=.h)
>
> MOSTLYCLEANFILES = $(LIST_FILES:.list=.h) $(LIST_FILES:.list=.c)
>
> include $(top_srcdir)/aux/list.make
Sorry, but I'll stick with my setup. My parser depends on my lowest-
level library (`libutils') and almost the whole build-tree depends on
the generated files. So, when I touched my `libutils' in any way, I
would get a full-blown rebuild of the project. That's why I used `cmp'
and only replaced the `.[ch]' files with the newly generated if they
differed. And so I need timestamps to avoid unecessary commands run
all the time (I want to see ``nothing to be done...'' when it is the
case.)
> Let me add some comments:
> 1) The maintainer of Automake said that $(LIST_FILES:.list=.h) is safe,
> and I trust him.
Oh, great, that is what I was looking for!
> 2) nodist_libfoo_a_SOURCES was redundant, especially the .c files.
> Automake knows how to transform .list to .o, and listing the
> intermediate files again could cause problems.
With your setup, yes. Not with mine, unfortunately.
> 3) I try to have the BUILT_SOURCES hist as small as possible, so when
> the .c file is a prerequisite of the corresponding .o, there is no
> need to pre-build it using BUILT_SOURCES.
> 4) With parallel make, the PARSE_LIST_COMMAND cnnot be run twice in
> parallel, because of the "foo.c: foo.h" dependency. So we are safe.
I need to add this rule in my setup too.
Anyway, even if I don't accept your advice this time, thank you for
the help. :)
Paul
- builddir vs. srcdir, Paul Pogonyshev, 2005/03/09
- Re: builddir vs. srcdir, Stepan Kasal, 2005/03/09
- Re: builddir vs. srcdir, Paul Pogonyshev, 2005/03/09
- Re: builddir vs. srcdir, Stepan Kasal, 2005/03/10
- Re: builddir vs. srcdir, Paul Pogonyshev, 2005/03/10
- Re: builddir vs. srcdir, Stepan Kasal, 2005/03/11
- Re: builddir vs. srcdir, Paul Pogonyshev, 2005/03/12
- Re: builddir vs. srcdir, Stepan Kasal, 2005/03/16
- Re: builddir vs. srcdir,
Paul Pogonyshev <=
- Re: builddir vs. srcdir, Stepan Kasal, 2005/03/21
Re: builddir vs. srcdir, Harald Dunkel, 2005/03/10