C + Make

Stephen J Bevan bevan at cs.man.ac.uk
Tue Sep 11 07:00:41 AEST 1990


If you have .h files that include other .h files, such as the
following :-

/* foo.c */
#include "foo.h"

/* foo.h */
#include "a.h"
#include "b.h"

/* a.h */
lots of #includes

/* b.h */
lots of #includes

then inorder to get `make' to update foo.c if anything in the headers
change, you have to do something like :-

foo.o:	foo.c foo.h a.h b.h ... any file that a.h/b.h includes

i.e. you have to flatten the hierarchy you have built up.

What I'd like to know is there any way of writing this as :-

foo.o:	foo.c foo.h
foo.h:	a.h b.h

a.h:	a.h' includes
b.h:	b.h's includes

i.e. maintaining the hierarchy, but so still forcing foo.c to be
recompiled if one of a.h/b.h (or its includes) changes.

I have a kludgy solution, but as I store stuff under RCS, it can take
2 or 3 `makes' to get all the dependencies to update correctly (a bit
like using latex + bibtex :-)

What I'd like to know is :-

1. Should I even be trying to do this or should I go back to the ONE
   TRUE WAY of flattening the hierarchy.

2. If its an ok idea, has somebody got a solution that will update all
   the dependencies with just one run of `make'.

Ta

Stephen J. Bevan	bevan at cs.man.ac.uk



More information about the Comp.lang.c mailing list