help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

auto dependencies of generated headers


From: twk
Subject: auto dependencies of generated headers
Date: Mon, 12 Jan 2004 20:42:22 -0500

I'm trying to enhance a make system to support machine-generated
header files, but have run into a problem I can't figure out.
(And can't seem to Google, either.  Sigh.)  I'm hoping the experts here
can give me guidance or hints.  Thanks!

The code is scattered across a bunch of directories.  The top-level
makefile does an include of all the local makefiles, so it can maximize
parallelism of the makes.

We want to introduce some code generators.  Each local directory might
contain an input to the generator, conceptually:
  foo_output/foo.h: foo.gen
    generator foo.gen > foo_output/foo.h

Inside other directories, there might be consumers of foo.h:
  bar1.cpp contains #include "foo_output/foo.h"

The dependencies are being included into the makefiles
so in theory there should be an entry in bar1.d to record this
  bar_output/bar1.o: foo_output/foo.h

My question pertains to automatic extraction of the dependencies.

If I could run makedepend, I could discover the dependency
between bar1.cpp and foo_output/foo.h; but until foo_output/foo.h
exists, makedepend (which is really "g++ -MM") on bar1.cpp will
fail because it cannot do the #include.  On the other hand, I
can't tell to delay the makedepend on bar1.cpp until I foo_output/foo.h
unless I have discovered the dependency.  So I seem to have run
into a cycle which I need to break.

The only thing I've been able to think of so far is to modify each
local makefile to do something like
  ALL_GENERATED_FILES += ....        # everything produced from .gen files
  ALL_NON_GENERATED_OUTPUTS += ....  # every output to be produced from other 
srcs
and then the global makefile can add a dependency like
  $(ALL_NON_GENERATED_OUTPUTS) :| $(ALL_GENERATED_FILES)
which (if I understand "|") would inform make to compute all the generated
stuff across all the directories prior to computing any of the stuff which
might rely on it.

I haven't actually tried this yet; does it seem like a plausible approach?
Or am I about to shoot myself in the foot?

Is there some better/standard answer to this kind of problem which
I haven't come across or thought of yet?

Any advice, hints, or pointers to docs will be greatly appreciated!




--
address@hidden





reply via email to

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