[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Shorter and less error-prone rule for automatic prerequisite genera
From: |
Mike Shal |
Subject: |
Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual |
Date: |
Wed, 28 Apr 2010 09:47:37 -0400 |
On 4/28/10, Robert Jørgensgaard Engdahl <address@hidden> wrote:
>
> Hello GNU Make bug-list subscribers
>
> On
>
> http://www.gnu.org/software/make/manual/make.html#Automatic-Prerequisites
>
> The rule for automatically generating prerequisites is
>
> %.d: %.c
> @set -e; rm -f $@; \
> $(CC) -M $(CPPFLAGS) $< > address@hidden; \
> sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < address@hidden > $@; \
> rm -f address@hidden
>
> but could be replaced with
>
> %.d : %.c
> @$(CC) -MT $@ -MT $*.o -MM $(CPPFLAGS) $< > $@
>
> This is simpler.
It's also unnecessary - you don't need a rule for %.d at all. You can
just generate the dependencies as a side-effect of compilation using
-MMD or similar. Then use '-include' to grab all the deps if they
exist. By providing a rule for the .d files you'll cause make to
re-execute itself, so you'll just end up parsing the Makefile twice.
-Mike
- Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Robert Jørgensgaard Engdahl, 2010/04/28
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual,
Mike Shal <=
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Edward Welbourne, 2010/04/28
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Philip Guenther, 2010/04/28
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Edward Welbourne, 2010/04/29
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Robert Jørgensgaard Engdahl, 2010/04/29
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Edward Welbourne, 2010/04/29
- RE: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Martin Dorey, 2010/04/29
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Mike Shal, 2010/04/29
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Philip Guenther, 2010/04/29
- Message not available
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Philip Guenther, 2010/04/30
- Re: Shorter and less error-prone rule for automatic prerequisite generation in the GNU Make manual, Robert Jørgensgaard Engdahl, 2010/04/28