2016-01-03 50 views
0

我有以下的目標,在我的Makefile:/bin/sh的:變量:找不到命令

~/.zshrc: zsh/* 
    DESTDIR ?= $(shell echo '~/.') 
    SUDO ?= $(shell echo '') 
    sed -e "s_DESTDIR_$(DESTDIR)_" \ 
     -e "s_SUDO_$(SUDO)_" \ 
     -e "s_LIBDIR_$(LIBDIR)_" \ 
     -e '/^#/ d' $+ > [email protected] 

但每當我跑make ~.zshrc我得到以下錯誤:

DESTDIR ?= ~/. 
/bin/sh: DESTDIR: command not found 
make: *** [/Users/henrikgiesel/.zshrc] Error 127 

我有不知道是什麼原因造成的。我必須逃避什麼嗎?我在文件的另一處有PWD ?= $(shell pwd),它工作得很好。

+1

你不能像這樣在食譜中聲明變量。 –

+0

請注意,'make'使用'/ bin/sh',並且這不是'zsh'的鏈接。分配周圍的空間在常規的'/ bin/sh'中無效; '?='也是無效的'sh'語法。而且你必須使用分號和反斜槓,以確保第3行及其後的命令序列中設置的內容可用。 –

回答

0

target: respondencies -block的內部與Makefile的文件級別不同。

DESTDIR ?= $(shell echo '~/.')這樣的命令只能在文件級執行。 target -block中的所有內容基本上都是一個shell命令,由/ bin/sh執行。