小编maz*_*nki的帖子

make 不支持反引号符号吗?

设想

我在尝试将命令中的值分配给 makefile 中的变量时遇到了一些麻烦。使用反引号表示法似乎工作得很好,但是一旦我使用更现代的$(pwd)表示法,变量的值就不会返回任何内容。

$ cat Makefile
FOO=moo
BAR=$(pwd)
BAZ=`pwd`

all: foo bar baz

foo: 
    @echo foo:$(FOO)';'
bar:
    @echo bar:$(BAR)';'
baz:
    @echo baz:$(BAZ)';'
$ make all
foo:moo;
bar:;
baz:/home/mazunki;
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,FOO 和 BAZ 按预期工作。但酒吧不是。

问题

现在让我们通过添加更多示例来看看我的问题。当你明白我的想法时,我将跳过回声。

$ cat Makefile
SHELL=/bin/env bash

FOO=dog
BAR=$(pwd)
BAZ=`pwd`
QUZ=`$(FOO)`/cat
ZOT=`\`FOO\``/owl
BIM=`$(BAZ)`/rat
BAM=`\`BAZ\``/pig
BUM=`BUM`/fox

all: foo bar baz quz zot bim bam bum
# targets for all the things

$ make
foo:dog;
bar:;
baz:/home/mazunki;
bash: dog: command not found
quz:/cat;
bash: FOO: command not …
Run Code Online (Sandbox Code Playgroud)

bash makefile

3
推荐指数
1
解决办法
2633
查看次数

标签 统计

bash ×1

makefile ×1