forgodsakehold
forgodsakehold

Reputation: 904

What's the meaning of targets in a Makefile that start with a ., and how is it different/similar to suffix rules?

In a Makefile, I saw this:

all: .made

# ... some other code

.made: $(Program) bashbug
    @echo "$(Program) last made for a $(Machine) running $(OS)" >.made

Is the .made rule a suffix rule as per: https://www.gnu.org/software/make/manual/make.html#Suffix-Rules?

Also, are all rules with targets that have a . in front suffix rules?

Otherwise, what is the significance of targets that start with .? It seems like there's a significance as per this in https://www.gnu.org/software/make/manual/make.html#How-Make-Works:

By default, make starts with the first target (not targets whose names start with ‘.’).

But its significance is not mentioned.

Also, if it is a suffix rule, how come .made can be used as a prerequisite in the all rule? (It's not mentioned that the targets of suffix rules can be used as prerequisites in other rules.)

P.S.: This question is related to but different from what is the meaning for . (dot) before the target in makefile. This question asks explicitly for the difference between a target with . and a target of a suffix rule.

Upvotes: 0

Views: 625

Answers (1)

melpomene
melpomene

Reputation: 85887

Is the .made rule a suffix rule

No, because .made is not a "known suffix".

Also, are all rules with targets that have a . in front suffix rules?

No, only those where the word after the dot is a "known suffix":

Your first two questions are answered by https://www.gnu.org/software/make/manual/make.html#Suffix-Rules:

Suffix rule definitions are recognized by comparing each rule’s target against a defined list of known suffixes. When make sees a rule whose target is a known suffix, this rule is considered a single-suffix rule. When make sees a rule whose target is two known suffixes concatenated, this rule is taken as a double-suffix rule.

In your example .made is an actual filename. Your Makefile has a rule for it that creates/updates the file:

#vvvv
.made: $(Program) bashbug
        @echo "$(Program) last made for a $(Machine) running $(OS)" >.made
#                                                                    ^^^^^

All pretty normal; it would work the same way with any other name.

The only significance of the leading dot is that it makes the file "hidden" by convention, i.e. ls won't show it (without specifying -a), plain * won't match it, etc.

Upvotes: 1

Related Questions