Makefile 在通过 ./configure --host=mingw32 后制作时崩溃

Makefile crashed while making after pass the ./configure --host=mingw32

每个人:情况:带有 x86_64-w64-mingw32 编译工具链的 MacOS 我尝试从 GDB 的源代码为 Windows 编译 GDB。但是,在 ./configure 之后,我得到了

/bin/sh ./libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Wno-format -I./../zlib -Iincludedir -D__USE_MINGW_ACCESS  -release `cat libtool-soversion`  -Llibdir -Wl,--stack,12582912 -o libbfd.la -rpath /usr/local/lib archive.lo archures.lo bfd.lo bfdio.lo bfdwin.lo cache.lo coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo hash.lo init.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo `cat ofiles`   -L./../zlib -lz 
./libtool: line 5208: cd: libdir: No such file or directory
libtool: link: cannot determine absolute directory name of `libdir'
make[4]: *** [libbfd.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-bfd] Error 2

我确定我的 MingW32 已经完全构建并且功能强大。

x86_64-w64-mingw32-addr2line   x86_64-w64-mingw32-dllwrap     x86_64-w64-mingw32-gcc-ranlib  x86_64-w64-mingw32-ld.bfd      x86_64-w64-mingw32-size
x86_64-w64-mingw32-ar          x86_64-w64-mingw32-elfedit     x86_64-w64-mingw32-gcov        x86_64-w64-mingw32-lto-dump    x86_64-w64-mingw32-strings
x86_64-w64-mingw32-as          x86_64-w64-mingw32-g++         x86_64-w64-mingw32-gcov-dump   x86_64-w64-mingw32-nm          x86_64-w64-mingw32-strip
x86_64-w64-mingw32-c++         x86_64-w64-mingw32-gcc         x86_64-w64-mingw32-gcov-tool   x86_64-w64-mingw32-objcopy     x86_64-w64-mingw32-windmc
x86_64-w64-mingw32-c++filt     x86_64-w64-mingw32-gcc-10.2.0  x86_64-w64-mingw32-gfortran    x86_64-w64-mingw32-objdump     x86_64-w64-mingw32-windres
x86_64-w64-mingw32-cpp         x86_64-w64-mingw32-gcc-ar      x86_64-w64-mingw32-gprof       x86_64-w64-mingw32-ranlib      
x86_64-w64-mingw32-dlltool     x86_64-w64-mingw32-gcc-nm      x86_64-w64-mingw32-ld          x86_64-w64-mingw32-readelf   

我通过 HomeBrew 安装它这是我的 Makefile 中 libdir 的配置

prefix = /usr/local
exec_prefix = ${prefix}
libdir = ${exec_prefix}/lib
LDFLAGS = -Llibdir
...
    "libdir=$(libdir)" \
...

完全不知道如何解决这个问题。任何的想法?或者,如果您需要更多信息来解决这个问题,请告诉我。

只需下载 GDB 的源代码,我认为您可以复制相同的场景。

./libtool: line 5208: cd: libdir: No such file or directory
libtool: link: cannot determine absolute directory name of `libdir'
make[4]: *** [libbfd.la] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-bfd] Error 2
make: *** [all] Error 2

如命令行和错误消息所述,您为 libtool 提供的路径不正确。

命令行包含 -Llibdir 并且错误消息为“无法确定 'libdir' 的绝对目录名称”。

所以你写了你的 Makefile 来按字面意思使用 libdir 而不是它应该的变量。改成:

LDFLAGS = -L$(libdir)

LDFLAGS = -L${libdir}

圆括号和大括号之间没有真正的区别,只是不要混淆它们。有用的链接是: The difference between parentheses and curly braces in GNU MakeWhat's the difference between parenthesis $() and curly bracket ${} syntax in Makefile?