[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: Sat, 12 Mar 2005 18:56:20 +0200
User-agent: KMail/1.4.3

Stepan Kasal wrote:
> About the side topic of suffixes:
> [...]

I finally decided that suffixes are good and ``are worth it'', mostly
because I use generated files in 4 different directories (with two
files in one of them), so rewriting the rule 5 times is kinda nasty.
Based on your suggestions, study of GTK+ `' and own thoughts,
I came up with this:

[file `aux/list.make']

SUFFIXES = .list


# `PARSE_LIST_COMMAND' and `PARSE_LIST_FLAGS' should be set by the
# includer.

# We use `cmp' here to avoid unneeded recompilations of files that
# depend on generated ones (only really useful for `.h' files.)
PARSE_LIST_BUILD_RULE =                                         \
        if $(PARSE_LIST) `test -f '$<' || echo '$(srcdir)/'`$<  \
                         $* $*; then                \
          if cmp -s $* $*.c;                              \
            then rm -f $*; else mv -f $* $*.c;      \
          fi;                                                   \
          if cmp -s $* $*.h;                              \
            then rm -f $*; else mv -f $* $*.h;      \
          fi;                                                   \
          echo timestamp > $@;                                  \
        else                                                    \
          (rm -f $*.c $* $*.h $* ; exit 1)          \


# Since $(LIST_GENERATED_FILES) defined by the includer don't (at
# least shouldn't) have any dependencies, if this rule is being
# executed, it probably means that one of the files was removed.
# Then all we can do is to force rebuilding of corresponding stamp
# file, which builds the required sources ``by side-effect.''
        rm -f $*.stamp;
        $(MAKE) $(AM_MAKEFLAGS) $*.stamp


noinst_LIBRARIES = libfoo.a

LIST_FILES = foo.list bar.list

LIST_STAMP_FILES = foo.stamp bar.stamp

LIST_GENERATED_FILES = foo.c bar.c foo.h bar.h


include $(top_srcdir)/aux/list.make

libfoo_a_SOURCES = ... $(LIST_FILES)




Everything seems to work just fine and as expected, however I suspect
that the ``rm -f $*.stamp; $(MAKE) $(AM_MAKEFLAGS) $*.stamp'' command
will cause the problem with parallel make you mentioned.  Is it so?

Also, is there a way to automatically set `LIST_STAMP_FILES' and
`LIST_GENERATED_FILES' from `LIST_FILES'?  (I'm aware of GNU make's
text manipulation functions, but they are GNU make specific...)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]