25

我正在尝试理解 Makefile,但我不理解带有注释的配方行。

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

在这方面我还是个新手。你能给我一个非常简单的解释吗:

$(基本名称 $(notdir $@))

4

1 回答 1

44

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

于 2013-05-24T02:59:50.953 回答