【问题标题】:Makefile syntax error in windows: unexpected end of fileWindows中的Makefile语法错误:文件意外结束
【发布时间】:2018-04-14 14:15:09
【问题描述】:

我想使用MinGW在win10中使用下面的Makefile编译C++代码:

# Include platform dependent makefiles
ifeq ($(OS),Windows_NT)
include Makefile.nt
else
include Makefile.unix
endif

PREFIX:=bin/

#############################################################################
# Default target
all: $(PREFIX)rdf3xdump$(EXEEXT) $(PREFIX)rdf3xload$(EXEEXT) $(PREFIX)rdf3xquery$(EXEEXT) $(PREFIX)rdf3xupdate$(EXEEXT) $(PREFIX)rdf3xembedded$(EXEEXT) $(PREFIX)rdf3xreorg$(EXEEXT) $(PREFIX)translatesparql$(EXEEXT) $(PREFIX)buildmonetdb$(EXEEXT) $(PREFIX)buildpostgresql$(EXEEXT)

#############################################################################
# Collect all sources

include cts/LocalMakefile
include infra/LocalMakefile
include makeutil/LocalMakefile
include rts/LocalMakefile
include gtest/LocalMakefile
include test/LocalMakefile
include api/LocalMakefile

ifeq ($(LINEEDITOR),1)
src_lineeditor:=lineeditor/LineInput.cpp lineeditor/LineEditor.cpp lineeditor/Terminal.cpp lineeditor/Display.cpp lineeditor/Buffer.cpp
endif

include tools/LocalMakefile


source:=$(src_cts) $(src_infra) $(src_rts) $(src_tools) $(src_lineeditor)

#############################################################################
# Dependencies

generatedependencies=$(call nativefile,$(PREFIX)makeutil/getdep) -o$(basename $@).d $(IFLAGS) $< $(basename $@)$(OBJEXT) $(genheaders) $(GENERATED-$<)

ifneq ($(IGNORE_DEPENDENCIES),1)
-include $(addprefix $(PREFIX),$(source:.cpp=.d)) $(addsuffix .d,$(basename $(wildcard $(generatedsource))))
endif

#############################################################################
# Compiling

compile=$(CXX) -c  $(TARGET)$(call nativefile,$@) $(CXXFLAGS) $(CXXFLAGS-$(firstword $(subst /, ,$<))) $(IFLAGS) $(IFLAGS-$(firstword $(subst /, ,$<))) $(call nativefile,$<)

$(PREFIX)%$(OBJEXT): %.cpp $(PREFIX)makeutil/getdep$(EXEEXT)
    $(checkdir)
    $(generatedependencies)
    $(compile)

#############################################################################
# Cleanup

clean:
    find bin -name '*.d' -delete -o -name '*.o' -delete -o '(' -perm -u=x '!' -type d ')' -delete

#############################################################################
# Executable

$(PREFIX)query: $(addprefix $(PREFIX),$(source:.cpp=$(OBJEXT)))

我输入 mingw32-make 后,似乎出现了一些错误:

D:\rdf3x>mingw32-make
/usr/bin/sh: -c: line 1: syntax error: unexpected end of file
makeutil/LocalMakefile:3: recipe for target 'bin/makeutil/getdep.o' failed
mingw32-make: *** [bin/makeutil/getdep.o] Error 1

我也曾通过 dos2unix 将 Makefile 转换为 unix 样式。 所有的 makefile 和代码都是从 github 克隆的:https://github.com/gh-rdf3x/gh-rdf3x。许多其他人完成了代码的编译。

我该如何解决这个问题?我的操作系统是windows10 64bit版本,编译工具是MinGW

----------更新--------------

感谢@MadScientist的提醒,文件makeutil/LocalMakefile附在下面:

# Separate build rules to avoid cyclic dependencies
$(PREFIX)makeutil/getdep$(OBJEXT): makeutil/getdep.cpp
    $(checkdir)
    $(compile)

$(PREFIX)makeutil/getdep$(EXEEXT): $(PREFIX)makeutil/getdep$(OBJEXT)
    $(buildexe)

【问题讨论】:

  • 嗯,错误消息清楚地表明问题出在文件 makeutil/LocalMakefile 的第 3 行。您没有向我们展示该文件的任何内容,因此我们无法猜测问题可能是什么是。但是,这不是 dos2unix 的事情(我不期望),因为 GNU make 可以使用 Windows CRLF 换行符而无需转换(如果您在解析过程中更早出现错误)。
  • 感谢您的提醒,我已经重新发布了该问题描述中的文件'LocalMakefile',有什么问题吗?@MadScientist
  • 看起来你的 makefile 文件与“@-everywhere”的常见问题相冲突,人们在所有命令前加上@,所以没有人可以看到命令是什么。我希望checkdir 扩展为一些非法但以@ 开头的shell 命令,因此make 不会将其打印出来并且您看不到它。您应该删除您的 makefile 中的所有或大部分 @ 符号并改用 .SILENT:请参阅 make.mad-scientist.net/managing-recipe-echoing 以获取一些提示。无论如何,在我们看到 $(checkdir) 扩展到什么之前,我们无能为力。

标签: windows makefile mingw


【解决方案1】:

$(checkdir) 扩展为不完整的 shell 命令(你没有向我们展示什么)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-17
    • 2011-09-16
    • 2017-06-08
    • 2013-04-13
    • 1970-01-01
    • 1970-01-01
    • 2016-03-07
    相关资源
    最近更新 更多