bug-make
[Top][All Lists]
Advanced

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

"bug" is in the manual. Program is great!


From: Andrew Sackett
Subject: "bug" is in the manual. Program is great!
Date: Thu, 14 Jun 2001 09:50:25 -0500

I recently picked up GNU make 3.79.1, and it works wonderfully.
However, I did find the manual (both the INFO version and the web version at
http://www.gnu.org/manual/make-3.79.1 misleading in one section.

When dealing with Generating Pre-requisites Automatically, you provided a
nice rule to turn %.c into %.d, and also showed that you could then include
$(ALL_D) into your makefile so that header dependencies could be considered.
Fantastic!

But my C programming habits had me including things at or near the top of
the makefile.  IMHO, the manual should note that the cc -M command (and
hence the %.d : %.c rule) generates lines that make (quite properly)
interprets as targets with pre-requisites.  Hence, if you put 'include
$(ALL_D)' before your explicit targets (like all:), then suddenly the first
line of the first included %.d file becomes the default goal.

It would be nice if the manual displayed a sample makefile showing the
proper placement of the 'include $(ALL_D)' line somewhere past the
programmer's first explicit target.


bad:
# The following is bad because the
# 'include $(ALL_D)' declares an
# implicit and unintended default goal

include rules.mk

LIB_C= mod1.c mod2.c mod3.c
ALL_C= $(LIB_C) mainline.c

LIB_0=$(LIB_C:.c=.o)
ALL_O=$(ALL_C:.c=.o)

ALL_D=$(ALL_C:.c=.d)

include $(ALL_D)

all: mainline
        @ echo "$@ up to date"

mainline : mainline.o lib
        $(CC) ...

lib: mylib.a($(LIB_0))
        @ echo "$@ up to date"

good:
# The following is better.
# The 'include $(ALL_D)' can safely appear
# anywhere past the more intuitive default
# goal of all:

include rules.mk

LIB_C= mod1.c mod2.c mod3.c
ALL_C= $(LIB_C) mainline.c

LIB_0=$(LIB_C:.c=.o)
ALL_O=$(ALL_C:.c=.o)

ALL_D=$(ALL_C:.c=.d)

all: mainline
        @ echo "$@ up to date"

include $(ALL_D)

mainline : mainline.o lib
        $(CC) ...

lib: mylib.a($(LIB_0))
        @ echo "$@ up to date"



Andrew Sackett
SmartCall Back End Development, Austin
Email   address@hidden
VNet        671 5162
DID     512 684 5162
Page    1 800 PAGE MCI [724 3624] PIN 140 2823
Click   http://www.skytel.com/paging/pageme.cgi?pin=1402823,4
AOL IM  ABS144





reply via email to

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