在 makefile 中逃跑

我试图在 makefile 中完成这个操作,但是失败得很可怕:

M_ARCH := $(shell g++ -dumpmachine | awk '{split($1,a,"-");print a[1]}')

你知道为什么吗? 我想这和逃跑有关,但是是什么,在哪里?

49419 次浏览

It's the dollar sign, in makefiles you'll have to type $$ to get a single dollar sign:

M_ARCH := $(shell g++ -dumpmachine | awk '{split($$1,a,"-");print a[1]}')

Make is quite lispy when you get down to it. Here's a non-awk version that does the same thing:

space := $() #


M_ARCH := $(firstword $(subst -,$(space),$(shell g++ -dumpmachine)))


all:
$(info $(M_ARCH))