Anyone have a good idea about how to compute dependencies
when one installed .h file includes another?
Here's a test case.

::::::::::::::
Makefile
::::::::::::::
# Illustration of problem with dependency on generated files
# cf. http://mail.gnu.org/archive/html/help-make/2001-07/msg00031.html
# The first time you run 'make', it fails
# with "x.h:1: y.h: No such file or directory"
# because a.d doesn't notice the dependency of x.h on y.h
# because neither exists when gcc -MM is run.

SOURCES := a.c
OBJS    := $(patsubst %.c,%.o, $(SOURCES))
DEPENDS := $(patsubst %.c,%.d, $(SOURCES))

a: $(OBJS)
        gcc $(OBJS) -o a

# Generated (or, in this case, installed) .h files
x.h: source/x.h
        install -m 644 source/x.h x.h

y.h: source/y.h
        install -m 644 source/y.h y.h

$(DEPENDS): %.d: %.c
        $(CC) $(CFLAGS) $< -MM -MG | sed -e 's,^[^:]*:,[EMAIL PROTECTED] $@: ,g' -e 
's,\.d\.o,.o,' > $@
-include $(DEPENDS)

clean:
        -rm -f $(OBJS) $(DEPENDS) x.h y.h a
::::::::::::::
a.c
::::::::::::::
#include "x.h"
#include <stdio.h>
main()
{
        printf("YVAL is %d\n", YVAL);
        return 0;
}
::::::::::::::
source/x.h
::::::::::::::
#include "y.h"
::::::::::::::
source/y.h
::::::::::::::
#define YVAL 4



_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to