help-make
[Top][All Lists]
Advanced

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

Dumb Questions


From: thutt
Subject: Dumb Questions
Date: Mon, 11 Nov 2019 05:55:21 -0800

Lee Eric writes:
 > Hi,
 > 
 > New to Make and after reading some pages from the GNU Make book I'm
 > confused about some explanations.
 > 
 > 1. From the O'Reilly book it mentions "Normally, phony targets will
 >    be always be executed ...". I don't quite follow it as "clean"
 >    is a typical phony target but it's not executed every time until
 >    we tell Make. So my question is, if a Makefile has multiple
 >    targets, what's the rule of Make to process the targets? Because
 >    after reading the book I have no idea what targets would be
 >    executed.

 A phony target is executed each time it is mentioned on the command
 line, or as a prerequisite of another target that is being built.

 Essentially, a phony target is never considered 'up-to-date' each
 time Make is started.

 > 
 > 2. What's the actual/practical use of Empty Targets? The example in that 
 > book is
 > 
 > prog: size prog.o
 >     $(CC) $(LDFLAGS) -o $@ $^
 > size: prog.o
 >     size $^
 >     touch size
 > 
 > but I didn't see the use of that size target, because even I change it to
 > 
 > prog: prog.o
 >     $(CC) $(LDFLAGS) -o $@ $^
 > 
 > is still valid. So why we need to use empty targets?

 The 'size' target here is used to encapsulate a sequence of commands
 that you might like to execute frequently during development.  In
 this case, it's showing the size of the contents of the prerequisite
 object files -- facilitating tracking code & data bloat.

 This 'size' is a little bit smart -- it only runs when the object
 file has changed since the last time 'size' was executed.  As an
 experiment, try making it phony and executing it without having
 prog.o change.


-- 
It's not about where you're from, it's wear your hat.




reply via email to

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