在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不能理解
謝謝。
uj5u.com熱心網友回復:
$$ : 顯示bash的行程號shell:是一種解釋性腳本,批量處理命令
uj5u.com熱心網友回復:
白話一點,$(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
uj5u.com熱心網友回復:
雙美元符號$$, 第一個由make解釋,第二個由shell命令解釋uj5u.com熱心網友回復:
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).
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/152218.html
標籤:應用程序開發區
