在config.mk文件中
SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
    else if [ -x /bin/bash ]; then echo /bin/bash; \
    else echo sh; fi ; fi)
(shell )括号中的shell是什么,echo $$BASH这里为什么是$$呢TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
这里就是ROPDIR=非空的PWD目录,但是这个表达式也是shell,和$$PWD不能理解谢谢。

解决方案 »

  1.   

    $$ : 显示bash的进程号shell:是一种解释性脚本,批量处理命令
      

  2.   

    白话一点,$(shell ... ...)就是开辟一个终端执行后面的脚本命令
    $$BASH就是再展开,就是说在shell环境中是否有 $BASH这个环境变量,有的话就输出$BASH这个环境变量的值,正好SHELL=$BASH
    如:
    BASH=/usr/bash
    在shell这个环境中,因为BASH存在了,所以SHELL=$BASH,即SHELL=/usr/bash
    如果没有$BASH这个环境变量,有/bin/bash这个执行文件在,SHELL=/bin/bash
    如果都没有SHELL=sh
    同理
    后面的$$PWD也是,在这个环境变量中,如果有$PWD这个变量,并且这个变量不等于NULL,那么TOPDIR =echo $PWD
    否则就执行命令pwd
      

  3.   

    双美元符号$$, 第一个由make解释,第二个由shell命令解释
      

  4.   

    shell 是 GNU make 的函数,可以用 info make 命令查看
    8.11 The `shell' Function
    =========================The `shell' function is unlike any other function other than the
    `wildcard' function (*note The Function `wildcard': Wildcard Function.)
    in that it communicates with the world outside of `make'.   The `shell' function performs the same function that backquotes
    (``') perform in most shells: it does "command expansion".  This means
    that it takes as an argument a shell command and evaluates to the
    output of the command.  The only processing `make' does on the result
    is to convert each newline (or carriage-return / newline pair) to a
    single space.  If there is a trailing (carriage-return and) newline it
    will simply be removed.   The commands run by calls to the `shell' function are run when the
    function calls are expanded (*note How `make' Reads a Makefile: Reading
    Makefiles.).  Because this function involves spawning a new shell, you
    should carefully consider the performance implications of using the
    `shell' function within recursively expanded variables vs. simply
    expanded variables (*note The Two Flavors of Variables: Flavors.).   Here are some examples of the use of the `shell' function:     contents := $(shell cat foo)sets `contents' to the contents of the file `foo', with a space (rather
    than a newline) separating each line.     files := $(shell echo *.c)sets `files' to the expansion of `*.c'.  Unless `make' is using a very
    strange shell, this has the same result as `$(wildcard *.c)' (as long
    as at least one `.c' file exists).