Autoconf/Automake 条件和 dist 规则
我最近开始在我正在进行的一个项目中使用 autoconf 和 automake。该项目的文档是用 LaTeX 编写的。由于我不想将 LaTeX 作为依赖项,所以我想使用 autoconf 检查 pdflatex 二进制文件是否存在,然后使用 Makefile.am 中的信息来决定是简单地将 .tex 文件复制到文档目录,还是生成 PDF 并复制两者。
这是 configure.ac 中的相关部分:
# Check for presence of pdfLaTeX
AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex)
if test -z "$PDFLATEX"; then
AC_MSG_WARN([Unable to create PDF version of the user manual.])
fi
AM_CONDITIONAL([HAVE_PDFLATEX], test -n "$PDFLATEX")
在 doc/ 目录中,我有以下 Makefile.am:
docfiles = manual.tex QuickStart.txt
if HAVE_PDFLATEX
docfiles += manual.pdf
MANNAME = manual
MANTEXSRC = $(MANNAME).tex
MANAUX = $(MANNAME).aux
MANPDF = $(MANNAME).pdf
CLEANFILES = $(MANPDF) $(MANNAME).log $(MANNAME).idx $(MANNAME).out \
$(MANNAME).toc $(MANAUX)
$(MANPDF): $(srcdir)/$(MANTEXSRC)
$(PDFLATEX) $<
endif
dist_doc_DATA = $(docfiles)
此设置在以下情况下有效: >pdflatex 存在,但是当它不存在时,运行 make 可以工作,但是 make distcheck 要求构建 PDF 文件的方法:
make[1]: *** No rule to make target `manual.pdf', needed by `distdir'. Stop.
查看 make >Makefile automake 生成的我看到:
#am__append_1 = manual.pdf
am__dist_doc_DATA_DIST = manual.tex QuickStart.txt manual.pdf
并进一步向下我发现:
docfiles = manual.tex QuickStart.txt $(am__append_1)
#MANNAME = manual
#MANTEXSRC = $(MANNAME).tex
#MANAUX = $(MANNAME).aux
#MANPDF = $(MANNAME).pdf
#CLEANFILES = $(MANPDF) $(MANNAME).log $(MANNAME).idx $(MANNAME).out \
# $(MANNAME).toc $(MANAUX) .btmp
dist_doc_DATA = $(docfiles)
我在这里错过了什么?
I recently started using autoconf and automake for a project I'm working on. The project's documentation is written in LaTeX. Since I don't want to have LaTeX as a dependency I want to check the presence of the pdflatex binary with autoconf and then use that information in the Makefile.am to decide whether to simply copy the .tex file to the documentation directory, or to generate the PDF and copy both.
This is the relevant section in configure.ac:
# Check for presence of pdfLaTeX
AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex)
if test -z "$PDFLATEX"; then
AC_MSG_WARN([Unable to create PDF version of the user manual.])
fi
AM_CONDITIONAL([HAVE_PDFLATEX], test -n "$PDFLATEX")
In the doc/ directory I have the following Makefile.am:
docfiles = manual.tex QuickStart.txt
if HAVE_PDFLATEX
docfiles += manual.pdf
MANNAME = manual
MANTEXSRC = $(MANNAME).tex
MANAUX = $(MANNAME).aux
MANPDF = $(MANNAME).pdf
CLEANFILES = $(MANPDF) $(MANNAME).log $(MANNAME).idx $(MANNAME).out \
$(MANNAME).toc $(MANAUX)
$(MANPDF): $(srcdir)/$(MANTEXSRC)
$(PDFLATEX) lt;
endif
dist_doc_DATA = $(docfiles)
This setup works when pdflatex is present, but when it is absent running make works, but make distcheck asks for a way to build the PDF file:
make[1]: *** No rule to make target `manual.pdf', needed by `distdir'. Stop.
Looking in the Makefile that automake generated I see:
#am__append_1 = manual.pdf
am__dist_doc_DATA_DIST = manual.tex QuickStart.txt manual.pdf
and further down I find:
docfiles = manual.tex QuickStart.txt $(am__append_1)
#MANNAME = manual
#MANTEXSRC = $(MANNAME).tex
#MANAUX = $(MANNAME).aux
#MANPDF = $(MANNAME).pdf
#CLEANFILES = $(MANPDF) $(MANNAME).log $(MANNAME).idx $(MANNAME).out \
# $(MANNAME).toc $(MANAUX) .btmp
dist_doc_DATA = $(docfiles)
What am I missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的问题是你有条件地“分发”
manual.pdf
,而 automake 对于 dist 规则相当保守。试试这个:I think your problem is that you're conditionally "distributing"
manual.pdf
, and automake's rather conservative about dist rules. Try this: