views:

257

answers:

2

I'm new to make and makefiles, so forgive me if this is very basic.

I'm looking through some makefiles in my project and I'm seeing 2 types of targets -- targets that don't begin with a . character and targets that do.

And from what I'm guessing, it seems like the ".target-name" targets are always executed, is my assumption true? I did read about makefiles by Googling but didn't find anything specific to this.

And as always, thanks for the answers!

+2  A: 

No.

The targets with a dot are normally special meaning targets (i.e. their functioniality is builtin into make). One of them is .PHONY, this is the one that defines the targets which are always executed (that means, the commands in their rules are run unconditionally).

But there are also others, like .DEFAULT for the default rule, or .PRECIOUS with does not delete implicit built targets when interrupted.

flolo
Thanks! But very strange, I see names other than these in the documentation: http://www.gnu.org/software/autoconf/manual/make/Special-Targets.html#Special-Targets
artknish
What I meant was, I see ".some-random-name-not-in-documentation" targets in my project. So wandering from where they are called. I'll post it when I figure out.
artknish
Are behind the . names, or just combined file endings? The combined file ndings (like ".c.o") is and old way to declare general implicit rules (in the example for generating .o files from .c files). Else they are just normal targets which start with a ".".
flolo
+2  A: 

For learning about make, and especially gmake, I'd suggest having a look at the excellent book "Managing Projects with GNU Make" (sanitised Amazon link).

HTH.

cheers,

Rob Wells
@Rob: Thanks, I'll look into it if I do more of these stuff in future :) I'm learning a lot by looking at others' make files, a book certainly helps!
artknish