help-make
[Top][All Lists]
Advanced

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

Re: Dumb Questions


From: Paul Smith
Subject: Re: Dumb Questions
Date: Mon, 11 Nov 2019 08:41:15 -0500
User-agent: Evolution 3.34.1-2

On Sun, 2019-11-10 at 23:18 -0800, Lee Eric wrote:
> Hi,
> 
> New to Make and after reading some pages from the GNU Make book I'm
> confused about some explanations.

Just to be clear, the O'Reilly book was not written by the FSF or the
GNU project so we can't really speak for it.  I personally don't think
I even own a copy.

We do take responsibility for the GNU make user's manual, which you can
find in various forms here: https://www.gnu.org/software/make/manual/
and, it's free!  If you want a dead tree version please purchase it
from the FSF/GNU rather than somewhere else: that way the funding goes
to the FSF/GNU project.

There are other books out there as well such as The GNU Make Book by
John Graham-Cumming (obdisclosure: I was a technical reviewer for this
book but I don't get any royalties :)): https://nostarch.com/gnumake

Not that I have anything against the O'Reilly book: I'm sure it's very
good like all their books.  Just to say on this list we can't be called
on to justify it or even know what it says beyond what you've quoted
here.

> 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.

The GNU make manual describes how make processes targets:

https://www.gnu.org/software/make/manual/html_node/How-Make-Works.html

You might want to just read the entire introductory chapter:

https://www.gnu.org/software/make/manual/html_node/Introduction.html

I think the O'Reilly book means, _if_ that rule needs to be executed,
then it will _always_ be executed regardless of whether the target
appears to be out of date or not.

> 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?

In this case, it's used to run the size(1) program which will print out
the size info for the input file (use "man size" to see what it does).

So it's not intended to change the build output (which is why not
running it doesn't matter) it's meant to show the user some information
about the built artifact.




reply via email to

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