如何确定' ar'正在Makefile中调用?

时间:2017-10-13 23:59:53

标签: macos makefile libtool ar

我试图在OS X上构建Git.Git依赖于libidn2。 libidn2 2.0.0失败:

make  all-am
make[3]: Entering directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0/lib'
  CC       idna.lo
  CC       lookup.lo
  CC       decode.lo
  CC       register.lo
  CC       bidi.lo
  CC       version.lo
  CC       error.lo
  CC       punycode.lo
  CC       free.lo
  CC       data.lo
  CC       tr46map.lo
  CC       tables.lo
  CC       context.lo
  CCLD     libidn2.la
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
copying selected object files to avoid basename conflicts...
ar: temporary file: No such file or directory
Makefile:1027: recipe for target 'libidn2.la' failed
make[3]: *** [libidn2.la] Error 1
make[3]: Leaving directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0/lib'
Makefile:955: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0/lib'
Makefile:1065: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/Users/jwalton/Build-Scripts/libidn2-2.0.0'
Makefile:974: recipe for target 'all' failed
make: *** [all] Error 2

我构建libidn2的方法可以找到所有Makefile并修复ARARFLAGS

if [[ "$IS_DARWIN" -ne "0" ]]; then
    for mfile in $(find "$PWD" -name 'Makefile'); do
        echo "Fixing Makefile $mfile"
        sed -i "" 's|AR = ar|AR = /usr/bin/libtool|g' "$mfile"
        sed -i "" 's|ARFLAGS = cr|ARFLAGS = -static -o|g' "$mfile"
    done
fi

我已经确认它修复了所有Makefile:

$ find $PWD -name Makefile -exec grep 'AR =' {} \; | egrep -iv 'amtar|char'
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool
AR = /usr/bin/libtool
ac_ct_AR = /usr/bin/libtool

我还尝试了AR="/usr/bin/libtool" ARFLAGS="-static -o" ./configuremake AR="/usr/bin/libtool" ARFLAGS="-static -o",但这些选择并未受到尊重。它会产生额外的失败构建。

Makefile调试支持非常糟糕,所以我不确定如何继续。 make -d甚至无法完成最简单的任务,例如提供文件名和行号。 remake -d会产生同样无益的结果。其他人写的大项目加剧了这种情况。

$ make -d
...
Putting child 0x7f9bf0c45cf0 (libidn2.la) PID 75531 on the chain.
Live child 0x7f9bf0c45cf0 (libidn2.la) PID 75531
  CCLD     libidn2.la
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no name list
copying selected object files to avoid basename conflicts...
ar: temporary file: No such file or directory
Reaping losing child 0x7f9bf0c45cf0 PID 75531
Makefile:1027: recipe for target 'libidn2.la' failed

此处的第1027行,不是对ar的调用:

libidn2.la: $(libidn2_la_OBJECTS) $(libidn2_la_DEPENDENCIES) $(EXTRA_libidn2_la\
_DEPENDENCIES)
        $(AM_V_CCLD)$(libidn2_la_LINK) -rpath $(libdir) $(libidn2_la_OBJECTS) $\
(libidn2_la_LIBADD) $(LIBS)

如何找到ar集合中Makefiles的调用位置?

1 个答案:

答案 0 :(得分:-1)

要简单了解失败的食谱,您可以:

  1. 回应规则(即echo $(AM_V_CCLD)$(libidn2_la_LINK)...)
  2. 添加第二个无法停止make
  3. 的命令

    如果您需要其他帮助,请在此处报告这些更改后的make输出。

    在你的情况下,使用makefile选项--debug = m可以帮助