如何在嵌套包含中相对于当前.am文件进行包含?

时间:2018-09-20 10:45:21

标签: automake

考虑此构建目录:

grep "" . -r
./sub/Makefile.include.am:include ../Makefile.include.am
./sub/Makefile.am:include Makefile.include.am
./sub/dir/Makefile.include.am:include ../Makefile.include.am
./sub/dir/Makefile.am:include Makefile.include.am
./Makefile.include.am:# empty file
./Makefile.am:include Makefile.include.am
./clean.sh:rm -fr \
./clean.sh:     aclocal.m4 \
./clean.sh:     autom4te.cache \
./clean.sh:     Makefile.in \
./clean.sh:     sub/Makefile.in \
./clean.sh:     sub/dir/Makefile.in \
./clean.sh:     install-sh missing INSTALL NEWS README AUTHORS ChangeLog COPYING \
./configure.ac:AC_INIT([Foo],[0.8.15],[me@pricavy.net])
./configure.ac:AM_INIT_AUTOMAKE([])
./configure.ac:
./configure.ac:AC_CONFIG_FILES([
./configure.ac: Makefile
./configure.ac: sub/Makefile
./configure.ac: sub/dir/Makefile
./configure.ac:])
./run.sh:aclocal
./run.sh:touch install-sh missing INSTALL NEWS README AUTHORS ChangeLog COPYING
./run.sh:automake

执行./run.sh会产生此错误:

Deep recursion on subroutine "Automake::read_am_file" at /usr/bin/automake-1.15 line 6536, <GEN115> line 1.
automake-1.15: error: cannot open < sub/dir/../Makefile.include.am: Too many open files

问题是,在生成sub/dir/Makefile时,当前工作目录为sub/dir,并且在包含sub/Makefile.include.am时仍然保持这种方式,因此,当sub/Makefile.include.am尝试包含时Makefile.include.am,实际上它包括创建一个无穷循环,直到自动制作错误消失。

有几种解决方案,例如使用绝对路径,但是,我非常想尽可能地使用相对路径来显示此处显示的模式。我该如何改写那些包含行来做我想做的事?

理想情况下像include $(selfdir)/../Makefile.include.am这样的东西而不必自己定义selfdir

用于创建以上目录结构的帮助脚本:

mkdir foo || exit
cd foo || exit

mkdir sub sub/dir || exit

echo "include ../Makefile.include.am" > sub/Makefile.include.am
echo "include Makefile.include.am" > sub/Makefile.am
echo "include ../Makefile.include.am" > sub/dir/Makefile.include.am
echo "include Makefile.include.am" > sub/dir/Makefile.am
echo "# empty file" > Makefile.include.am
echo "include Makefile.include.am" > Makefile.am
echo -e "rm -fr \\\\\n\taclocal.m4 \\\\\n\tautom4te.cache \\\\\n\tMakefile.in \\\\\n\tsub/Makefile.in \\\\\n\tsub/dir/Makefile.in \\\\\n\tinstall-sh missing INSTALL NEWS README AUTHORS ChangeLog COPYING \\" > clean.sh
echo -e "AC_INIT([Foo],[0.8.15],[me@pricavy.net])\nAM_INIT_AUTOMAKE([])\n\nAC_CONFIG_FILES([\n\tMakefile\n\tsub/Makefile\n\tsub/dir/Makefile\n])" > configure.ac
echo -e "aclocal\ntouch install-sh missing INSTALL NEWS README AUTHORS ChangeLog COPYING\nautomake" > run.sh
chmod +x clean.sh run.sh

0 个答案:

没有答案