help-make
[Top][All Lists]
Advanced

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

Re: Cancelling a Implicit Rule ?


From: Philip Guenther
Subject: Re: Cancelling a Implicit Rule ?
Date: Tue, 8 Dec 2009 17:28:02 -0800

2009/12/8 L.Guo <address@hidden>:
...
> 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)
>       address@hidden set -e; $(RM) $@;\
>           echo 'Generate $@ from $<'\
>           $(CC) -M $(CFLAGS) $< > address@hidden;\
>           sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < address@hidden > $@;\
>           $(RM) address@hidden;\
>         }
>
> $(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




reply via email to

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