Autoconf/Automake 条件和 dist 规则

发布于 2024-11-28 23:57:26 字数 1686 浏览 2 评论 0原文

我最近开始在我正在进行的一个项目中使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹苦笑 2024-12-05 23:57:26

我认为你的问题是你有条件地“分发”manual.pdf,而 automake 对于 dist 规则相当保守。试试这个:

if HAVE_PDFLATEX
doc_DATA = manual.pdf
# Rest of your stuff...
endif

I think your problem is that you're conditionally "distributing" manual.pdf, and automake's rather conservative about dist rules. Try this:

if HAVE_PDFLATEX
doc_DATA = manual.pdf
# Rest of your stuff...
endif
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文