Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding a Makefile with $(basename $(notdir $@))

I am trying to understand a Makefile, but I don't understand the recipe line with the comment.

...
...
sample.a:
    cd ../$(basename $(notdir $@)) && make    ##i don't understand this
...
...

I'm still a newbie at this. Can you give me a very simple explanation about:

$(basename $(notdir $@))


1 Answers

If you break it down:

$(notdir $@) takes away the path from the file name leaving just the file name (so /x/y/foo.a becomes foo.a) $(basename ...) takes away the extension (so foo.a becomes foo)

There's a decent reference here: http://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html

like image 170
lurker Avatar answered Sep 07 '25 22:09

lurker