[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Computing dependencies in the presence of generated files
From: |
Dan Kegel |
Subject: |
Computing dependencies in the presence of generated files |
Date: |
Wed, 10 Sep 2003 10:41:38 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030617 |
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,^[^:]*:,address@hidden $@: ,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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Computing dependencies in the presence of generated files,
Dan Kegel <=