automake
[Top][All Lists]
Advanced

[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+ `Makefile.am' and own thoughts,
I came up with this:


[file `aux/list.make']

SUFFIXES = .list

$(LIST_STAMP_FILES) : Makefile $(PARSE_LIST_COMMAND)

# `PARSE_LIST_COMMAND' and `PARSE_LIST_FLAGS' should be set by the
# includer.
#
PARSE_LIST = $(PARSE_LIST_COMMAND) $(PARSE_LIST_FLAGS)

# 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)/'`$<  \
                         $*.h.new $*.c.new; then                \
          if cmp -s $*.c.new $*.c;                              \
            then rm -f $*.c.new; else mv -f $*.c.new $*.c;      \
          fi;                                                   \
          if cmp -s $*.h.new $*.h;                              \
            then rm -f $*.h.new; else mv -f $*.h.new $*.h;      \
          fi;                                                   \
          echo timestamp > $@;                                  \
        else                                                    \
          (rm -f $*.c $*.c.new $*.h $*.h.new ; exit 1)          \
        fi

.list.stamp:
        $(PARSE_LIST_BUILD_RULE)

# 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.''
#
$(LIST_GENERATED_FILES):
        rm -f $*.stamp;
        $(MAKE) $(AM_MAKEFLAGS) $*.stamp


[usage]

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

PARSE_LIST_COMMAND = ...
PARSE_LIST_FLAGS   = ...

include $(top_srcdir)/aux/list.make

libfoo_a_SOURCES = ... $(LIST_FILES)

nodist_libfoo_a_SOURCES = $(LIST_GENERATED_FILES)

BUILT_SOURCES = $(LIST_STAMP_FILES)

MOSTLYCLEANFILES = $(LIST_STAMP_FILES) $(LIST_GENERATED_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...)

Paul





reply via email to

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