Home > OS >  The Makefile grammar problems
The Makefile grammar problems

Time:11-01

In the config. Mk file
SHELL:=$(SHELL if [-x $$" BASH "]. Then the echo $$BASH; \
Else if - x/bin/bash. Then the echo/bin/bash. \
The else echo sh; Fi; Fi)
(shell) what is the shell in parentheses, echo $$BASH is why $$here

TOPDIR:=$(shell if [" $$PWD "!=""); Then the echo $$PWD. The else PWD; Fi)
Here is the PWD ROPDIR=not empty directory, but this expression is a shell, and $$PWD cannot understand

thank you

CodePudding user response:

$$: show bash process number

Shell: is a kind of explanatory script, batch processing orders

CodePudding user response:

Colloquialism, $(shell... . ) is to open up a terminal performs at the back of the script command
$$BASH is launched, that is to say whether there is a $BASH this environment in the shell environment variables, so as the output value of the variable $BASH this environment, just the shell=$BASH
Such as:
BASH=/usr/BASH
In this environment, the shell because BASH exist, so the shell=$BASH, namely the shell=/usr/BASH
Without the environment variable $BASH,/bin/BASH the executable files in SHELL=/bin/BASH
If no SHELL=sh
Similarly
At the back of the $$PWD is also, in this environment variable, if you have $PWD this variable, and the variable is not equal to NULL, then TOPDIR=echo $PWD
Otherwise, perform the PWD command

CodePudding user response:

Double the dollar sign $$, and make explanations of the first and the second is interpreted by a shell command

CodePudding user response:

The shell is a function of the GNU make, you can use the info make command to see
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 will shells: it does "command expansion". This means
That it takes as an argument a shell command and evaluates to the
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 newline (carriage return and) it
Will simple be removed.

The commands run by calls to The ` shell 'function are run when The
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. simple
Expanded The variables (* note The Two Flavors of The 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) particulary if 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 further one `. C 'file exists).
  • Related