求助:makefile错误 : commands commence before first target. Stop

软件和网站开发以及相关技术探讨
回复
emmanule
帖子: 4
注册时间: 2009-03-26 14:06

求助:makefile错误 : commands commence before first target. Stop

#1

帖子 emmanule » 2010-08-05 11:37

初学makefile 编写脚本如下:

var1 =
var2 = hello

all:
ifndef $var1
$var1 = hello
endif
ifeq ($var1,$var2)
echo "equal"
else
echo "not equal"
endif

.PHONY: all

运行错误:
testmf:11: *** commands commence before first target. Stop.
第11行echo "not equal" 与第9行 echo "not equal" 前面均有tab建,
不知道到底哪里出错了。求大家指点一下
emmanule
帖子: 4
注册时间: 2009-03-26 14:06

Re: 求助:makefile错误 : commands commence before first target.

#2

帖子 emmanule » 2010-08-05 15:57

经过几次实验发现错误处在echo命令行处。
如果echo语句开始前未输入[Tab]建 则提示
testsubst:9: *** missing separator. Stop.
如果echo语句以[Tab]建开始 则提示
testsubst:9: *** commands commence before first target. Stop.

我又测试了教程上的几个不同的例子,发现都是如此。在条件判断语句中,一使用echo语句就出错*** commands commence before first target. Stop.。
继续纳闷中............
zhyjp
帖子: 3
注册时间: 2008-07-23 8:22

Re: 求助:makefile错误 : commands commence before first target.

#3

帖子 zhyjp » 2010-12-07 17:04

emmanule 写了:初学makefile 编写脚本如下:

var1 =
var2 = hello

all:
ifndef $var1
$var1 = hello
endif
ifeq ($var1,$var2)
echo "equal"
else
echo "not equal"
endif

.PHONY: all

运行错误:
testmf:11: *** commands commence before first target. Stop.
第11行echo "not equal" 与第9行 echo "not equal" 前面均有tab建,
不知道到底哪里出错了。求大家指点一下
在第一个endif之后加入;\
testsubst:9: *** missing separator. Stop. 提示 2个if语句之间没有分隔符
yanzhi17xue
帖子: 1
注册时间: 2013-06-08 10:54
系统: windows

Re: 求助:makefile错误 : commands commence before first target.

#4

帖子 yanzhi17xue » 2013-06-08 10:56

make[1]: Entering directory `/home/yanzhixue/桌面/BSR_full/BSR/grouping/source/gpb_src/src'
rm -f
rm -f
make[2]: Entering directory `/home/yanzhixue/桌面/BSR_full/BSR/grouping/source/gpb_src/src/concurrent'
Makefile:1: *** missing separator. Stop.
make[2]: Leaving directory `/home/yanzhixue/桌面/BSR_full/BSR/grouping/source/gpb_src/src/concurrent'
make[2]: Entering directory `/home/yanzhixue/桌面/BSR_full/BSR/grouping/source/gpb_src/src/io'
但是makefile 和Rules.make两个文件都只有一行
../makefile
../Rules.make
每一个行加了tab后出现错误:
make[2]: Entering directory `/home/yanzhixue/桌面/BSR_full/BSR/grouping/source/gpb_src/src/concurrent'
Makefile:1: *** commands commence before first target. Stop.
make[2]: Leaving directory `/home/yanzhixue/桌面/BSR_full/BSR/grouping/source/gpb_src/src/concurrent'

不知道怎么改
回复