开发者

Autoconf/Automake conditionals and dist rules

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) $<
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 开发者_如何学C\
# $(MANNAME).toc $(MANAUX) .btmp

dist_doc_DATA = $(docfiles)

What am I missing here?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜