Thanks a lot. That is the problem. I made a mistake in .d modification command.
Thanks again. ------------------ L.Guo 2009-12-14 ------------------------------------------------------------- From: Philip Guenther At: 2009-12-09 09:28:03 Subject: Re: Cancelling a Implicit Rule ? 2009/12/8 L.Guo <[email protected]>: ... > I have a main makefile 'Makefile' and two sub (common) makefile 'default.mk' > and 'rules.mk'. > > The source files all in 'src' dir, the output in 'out'. As these: > > ???�SRCS = src/a.c src/main.c src/version.h > ???�DEPS = out/a.d out/main.d > ???�OBJS = out/a.o out/main.o > ???�TGTS = out/programme > > I want to use pattern rules in 'rules.mk' to handle the dependencies > generating. > > $(OUTDIR)/%.d: $(SRCDIR)/%.c $(OUTDIR) > ???...@{ set -e; $(RM) $@;\ > ?????echo 'Generate $@ from $<'\ > ?????$(CC) -M $(CFLAGS) $< > $...@.$$$$;\ > ?????sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $...@.$$$$ > $@;\ > ?????$(RM) $...@.$$$$;\ > ????} > > $(OBJS): $(OUTDIR)/%.o: $(SRCDIR)/%.c $(OUTDIR)/%.d > ????(CC) -c $(CFLAGS) -o $@ $< I suggest you read http://make.paulandlesley.org/autodep.html#advanced to see how having actual targets for the files included by make is unnecessary and wasteful. It's sufficient (and more efficient) to just have them created as a side-effect of the rule that generates the .o files. > When using the whole thing to build my project, 'make' gives me an error > report: > > ???�make: *** No rule to make target `main.c', needed by `out/main.d'. �Stop. I don't think this can be determined from what you've provided. I suggest you check the output of make -Rpq and examine all the lines that include ".d" to see whether anything stands out as "Not What I Meant". Philip Guenther
_______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
