Makefile 抛出检查 OS 的错误
Makefile throws an error for checking the OS
我是 Makefile 的新手。这是我目前拥有的:
install:
ifeq ($(OS),Windows_NT)
# do something
else
# do something
endif
但是 make 抛出这个错误:
ifeq (Windows_NT)
/bin/sh: -c: line 0: syntax error near unexpected token `Windows_NT'
/bin/sh: -c: line 0: `ifeq (Windows_NT)'
make: *** [install] Error 2
我不知道如何解决这个问题。请帮助我。
makefile 的内容采用 Make 语法,recipe 除外。
$(info hello)
foo:
echo working
echo still working
$(info ...)
行是Make函数调用; echo
行是 shell 命令,包含 foo
规则的配方。每个 shell 命令开头的空格是制表符,而不是空格。这就是 Make 如何知道它 是 一个 shell 命令,将被传递给 shell 而不是解释为 Make 代码。
你写的条件是一个Make条件,你用Make语法写的,但是你把制表符放在行的开头,所以Make把它们传递给一个shell,shell 抱怨它们无效(用它的语言)。
删除条件行开头的制表符,但保留 shell 命令开头的制表符:
install:
ifeq ($(OS),Windows_NT)
echo doing something
else
echo doing something else
endif
我是 Makefile 的新手。这是我目前拥有的:
install:
ifeq ($(OS),Windows_NT)
# do something
else
# do something
endif
但是 make 抛出这个错误:
ifeq (Windows_NT)
/bin/sh: -c: line 0: syntax error near unexpected token `Windows_NT'
/bin/sh: -c: line 0: `ifeq (Windows_NT)'
make: *** [install] Error 2
我不知道如何解决这个问题。请帮助我。
makefile 的内容采用 Make 语法,recipe 除外。
$(info hello)
foo:
echo working
echo still working
$(info ...)
行是Make函数调用; echo
行是 shell 命令,包含 foo
规则的配方。每个 shell 命令开头的空格是制表符,而不是空格。这就是 Make 如何知道它 是 一个 shell 命令,将被传递给 shell 而不是解释为 Make 代码。
你写的条件是一个Make条件,你用Make语法写的,但是你把制表符放在行的开头,所以Make把它们传递给一个shell,shell 抱怨它们无效(用它的语言)。
删除条件行开头的制表符,但保留 shell 命令开头的制表符:
install:
ifeq ($(OS),Windows_NT)
echo doing something
else
echo doing something else
endif