bobby
bobby

Reputation: 2789

patsubst and dir usage

I am trying to figure out what the following two lines in a .mk file mean

include $(ROOTDIRECT)/target/$(MYSUBDIR)/defs.mk
include $(ROOTDIRECT)/target/$(dir $(patsubst %/,%,$(MYSUBDIR)))/defs.mk

For clarity let ROOTDIRECT be "/home/me" and MYSUBDIR be "platform"
The first line I guess is straight forward and includes "/home/me/target/platform/defs.mk"

The second line I dont understand and my guess from my environment is that it includes "/home/me/target/defs.mk"
Am I right/wrong and could could someone help me to understand the second line

Upvotes: 2

Views: 15630

Answers (1)

Didier Trosset
Didier Trosset

Reputation: 37467

$(patsubst %/,%,$(MYSUBDIR)) will substitute anything matching the pattern %/ by %, where % can be anything.

In other words, it will remove the trailing / of $(MYSUBDIR).

See GNU Make Manual 8.2 Functions for String Substitution and Analysis

Upvotes: 6

Related Questions