patsubst and dir usage

15,081

$(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

Share:
15,081
bobby
Author by

bobby

Updated on June 04, 2022

Comments

  • bobby
    bobby about 2 years

    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