git Makefile 错误:看到意外的行尾

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2557787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:12:44  来源:igfitidea点击:

Makefile error: Unexpected end of line seen

gitmakefilesolarissunsunos

提问by Winston C. Yang

Trying to install Git, I ran configure and make, but got the following error message:

尝试安装 Git,我运行了 configure 和 make,但收到以下错误消息:

make: Fatal error in reader: Makefile, line 221: Unexpected end of line seen

make:阅读器中的致命错误:Makefile,第 221 行:看到意外的行尾

The Makefile looks like:

Makefile 看起来像:

218:    GIT-VERSION-FILE: FORCE
219:            @$(SHELL_PATH) ./GIT-VERSION-GEN
220:    -include GIT-VERSION-FILE
221:
222:    uname_S := $(shell sh -c 'uname -s 2>/dev/null ?? echo not')

What's causing the error?

导致错误的原因是什么?

The following information may or may not be relevant:

以下信息可能相关,也可能不相关:

  • I tried to install Git 1.7.0.3 on SunOS 5.9 (Solaris 9) in a directory in my account.
  • The gcc version is 3.4.2 (older then the version of 3.4.6 stated by sunfreeware.com).
  • I don't have root privileges.
  • 我尝试在 SunOS 5.9 (Solaris 9) 上的帐户目录中安装 Git 1.7.0.3。
  • gcc 版本是 3.4.2(比 sunfreeware.com 声明的 3.4.6 版本旧)。
  • 我没有root权限。

回答by user2554726

Using gmakeon SunOS instead of makefixed this issue for me.

gmake在 SunOS 上使用而不是make为我解决了这个问题。

回答by rashok

Use gmakeinstead of make.

使用gmake代替make

Genrally solaris has two command, gmakeand make. In this gmakeis GNU style make command, and makeis solaris style make command. I hope you have written your makefile in GNU style. So use gmakecommand.

一般而言,solaris 有两个命令,gmakemake. 这gmake是GNU风格的make命令,make也是solaris风格的make命令。我希望你已经用 GNU 风格编写了你的​​ makefile。所以使用gmake命令。

回答by Paulus

This might be due to DOS line endings (CRLF) in your makefile. I have just had a similar problem and solved it by running dos2unix on the makefile. Linux make seems unfazed by the same makefile.

这可能是由于 makefile 中的 DOS 行结尾 (CRLF)。我刚刚遇到了类似的问题,并通过在 makefile 上运行 dos2unix 解决了它。Linux make 似乎对相同的 makefile 毫不在意。

回答by xpert

Its a problem with your "make", install "make-3.81.tar" and then try

你的“make”有问题,安装“make-3.81.tar”然后试试

回答by Diavolche

Make sure that you have actually tabbed the line and it is not all spaces. I had this issue but I found out the command was not properly tabbed in and that is why I was running into this error.

确保您实际上已使用制表符标记该行,并且并非所有空格。我遇到了这个问题,但我发现该命令没有正确标记,这就是我遇到此错误的原因。

回答by Hatebit

I came to this error with 2 simple makefiles, one of which was working, and one which produced the error.

我用 2 个简单的 makefile 遇到了这个错误,其中一个正在运行,另一个产生了错误。

Both had properly tabbed lines, and both had "CRLF" line endings.

两者都有正确的标签行,并且都有“CRLF”行结尾。

For one reason or another, I managed to fix the problem by changing the line endings to "LF", but I am confused as to why the other makefile was parsed successfully even though it had "CRLF" endings. There is, however, a clue: the first one or two times, "make" gave another error:

出于某种原因,我设法通过将行结尾更改为 "LF" 来解决问题,但我很困惑为什么即使另一个 makefile 具有 "CRLF" 结尾也能成功解析。然而,有一个线索:前一两次,“make”又给出了另一个错误:

mksh: Warning: newline is not last character...

After opening the makefile in a text-editor, and adding a line ending at the end, it started producing the OP's error.

在文本编辑器中打开 makefile 并在末尾添加一行后,它开始产生 OP 的错误。

In this situation, it's good to have an editor that can display line endings and tabs.

在这种情况下,最好有一个可以显示行尾和制表符的编辑器。