Makefile生成错误

时间:2017-03-29 17:54:20

标签: c makefile

每次我在UNIX上输入命令

unix1% make clean

它会返回错误消息

mksh: Warning: newline is not last character in file makefile
Current working directory /home/s/m/mel
rm -f *.o core firstpass 
unix1%

这是我的makefile:

firstpass: main.o hashFunct.o symbolTable.o opcodeTable.o 
        gcc main.o hashFunct.o symbolTable.o opcodeTable.o -o firstpass

main.o: main.c
        gcc -c main.c

hashFunct.o: hashFunct.c
        gcc -c hashFunct.c

symbolTable.o: symbolTable.c
        gcc -c symbolTable.c

opcodeTable.o: opcodeTable.c
        gcc -c opcodeTable.c

clean:
       rm -f *.o core firstpass

我不明白这个问题,我试图在emacs中打开它,看不到任何神秘的字符。 firstpass这个词也是makefile中的最后一个字符。这个错误究竟意味着什么?

1 个答案:

答案 0 :(得分:4)

  

mksh:警告:换行符不是文件makefile中的最后一个字符

问题正是它所说的,它想要换行作为文件的最后一个字符。目前,最后一个字符可能是s的{​​{1}}。

在编辑器中打开它,转到文件的末尾,点击返回。

有些编辑会为您添加文件的最终换行符。

文件末尾的换行符不应该是必需的。这种警告在旧系统中很常见,如果在没有换行符的情况下给出输入,解析器可能会出现问题。 Perl 1是我唯一一次在野外看到这个,那是1987年以来的事情,但是C编译器仍然会发出这个警告。