From 005407338d8943cbb5ce551ee7f6ae9ac94091a6 Mon Sep 17 00:00:00 2001 From: Martin Herkt Date: Mon, 9 Sep 2013 04:23:06 +0200 Subject: Add PDF manual target This builds a PDF version of the manpage using rst2latex and pdflatex, and installs it to PREFIX/share/doc/mpv by default. --- DOCS/man/docutils.conf | 20 ++++++++++++++++++++ DOCS/man/en/mpv.rst | 11 +++++------ Makefile | 36 +++++++++++++++++++++++------------- configure | 27 +++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 19 deletions(-) create mode 100644 DOCS/man/docutils.conf diff --git a/DOCS/man/docutils.conf b/DOCS/man/docutils.conf new file mode 100644 index 0000000000..cd6e3acd52 --- /dev/null +++ b/DOCS/man/docutils.conf @@ -0,0 +1,20 @@ +[latex2e writer] +use-latex-docinfo: yes +use-latex-toc: yes +hyperlink-color: Blue!30!RoyalPurple!70!Black +latex-preamble: \usepackage[usenames,dvipsnames]{xcolor} + \usepackage{fullpage} + \usepackage{graphicx} + \renewcommand{\familydefault}{\sfdefault} + + \makeatletter + \renewcommand{\maketitle}{ + \begin{center} + \includegraphics{etc/mpv-icon-8bit-64x64.png}\\ + \vspace*{-1.5em} + \begin{Huge} + \@title + \end{Huge} + \end{center} + } + \makeatother diff --git a/DOCS/man/en/mpv.rst b/DOCS/man/en/mpv.rst index d769d34b29..74cc70f1e5 100644 --- a/DOCS/man/en/mpv.rst +++ b/DOCS/man/en/mpv.rst @@ -1,9 +1,3 @@ -.. - Hint: To generate a nicely formatted XeLaTeX document from this file, use - rst2xetex --use-latex-docinfo --use-latex-toc --hyperlink-color=MidnightBlue --latex-preamble="\usepackage[usenames,dvipsnames]{xcolor}\usepackage{fullpage}\setmainfont{Droid Sans}\setsansfont{Linux Biolinum O}\setmonofont[HyphenChar=None]{DejaVu Sans Mono}" mpv.rst - - You might want to put the .. contents:: directive below to generate a TOC. - mpv ### @@ -18,6 +12,11 @@ a movie player :Manual section: 1 :Manual group: multimedia +.. raw:: latex + + \tableofcontents + \pagebreak + SYNOPSIS ======== diff --git a/Makefile b/Makefile index d40f890790..b0ea74208e 100644 --- a/Makefile +++ b/Makefile @@ -290,12 +290,18 @@ ALL_TARGETS += mpv$(EXESUF) INSTALL_BIN += install-mpv INSTALL_BIN_STRIP += install-mpv-strip INSTALL_MAN = +INSTALL_PDF = ifeq ($(BUILD_MAN),yes) INSTALL_MAN += install-mpv-man ALL_TARGETS += DOCS/man/en/mpv.1 endif +ifeq ($(BUILD_PDF),yes) + INSTALL_PDF += install-mpv-pdf + ALL_TARGETS += DOCS/man/en/mpv.pdf +endif + DIRS = . \ audio \ audio/decode \ @@ -329,6 +335,12 @@ endif all: $(ALL_TARGETS) +%.tex: %.rst + $(RST2LATEX) --config=DOCS/man/docutils.conf $< $@ + +%.pdf: %.tex + pdflatex -interaction=batchmode -jobname=$(basename $@) $<; pdflatex -interaction=batchmode -jobname=$(basename $@) $< + %.1: %.rst $(RST2MAN) $< $@ @@ -403,21 +415,11 @@ mpvcore/version.c osdep/mpv-rc.o: version.h osdep/mpv-rc.o: osdep/mpv.exe.manifest etc/mpv-icon.ico -DOCS/man/en/mpv.1: DOCS/man/en/af.rst \ - DOCS/man/en/ao.rst \ - DOCS/man/en/changes.rst \ - DOCS/man/en/encode.rst \ - DOCS/man/en/input.rst \ - DOCS/man/en/options.rst \ - DOCS/man/en/vf.rst \ - DOCS/man/en/vo.rst - - ###### installation / clean / generic rules ####### -install: $(INSTALL_BIN) $(INSTALL_MAN) +install: $(INSTALL_BIN) $(INSTALL_MAN) $(INSTALL_PDF) install-no-man: $(INSTALL_BIN) -install-strip: $(INSTALL_BIN_STRIP) $(INSTALL_MAN) +install-strip: $(INSTALL_BIN_STRIP) $(INSTALL_MAN) $(INSTALL_PDF) install-strip-no-man: $(INSTALL_BIN_STRIP) install-dirs: @@ -435,16 +437,24 @@ install-mpv-man-en: DOCS/man/en/mpv.1 if test ! -d $(MANDIR)/man1 ; then $(INSTALL) -d $(MANDIR)/man1 ; fi $(INSTALL) -m 644 DOCS/man/en/mpv.1 $(MANDIR)/man1/ +install-mpv-pdf: install-mpv-pdf-en + +install-mpv-pdf-en: DOCS/man/en/mpv.pdf + if test ! -d $(DOCDIR)/mpv ; then $(INSTALL) -d $(DOCDIR)/mpv ; fi + $(INSTALL) -m 644 DOCS/man/en/mpv.pdf $(DOCDIR)/mpv/ + uninstall: $(RM) $(BINDIR)/mpv$(EXESUF) $(RM) $(MANDIR)/man1/mpv.1 $(RM) $(MANDIR)/en/man1/mpv.1 + $(RM) $(DOCDIR)/mpv/mpv.pdf clean: -$(RM) $(call ADD_ALL_DIRS,/*.o /*.d /*.a /*.ho /*~) -$(RM) $(call ADD_ALL_DIRS,/*.o /*.a /*.ho /*~) -$(RM) $(call ADD_ALL_EXESUFS,mpv) - -$(RM) DOCS/man/en/mpv.1 + -$(RM) $(call ADDSUFFIXES,.pdf .tex .log .aux .out .toc,DOCS/man/*/mpv) + -$(RM) DOCS/man/*/mpv.1 -$(RM) version.h -$(RM) mpvcore/input/input_conf.h -$(RM) video/out/vdpau_template.c diff --git a/configure b/configure index a613fee571..abf6982091 100755 --- a/configure +++ b/configure @@ -286,6 +286,7 @@ Installation directories: --datadir=DIR directory for installing machine independent data files (skins, etc) [PREFIX/share/mpv] --mandir=DIR directory for installing man pages [PREFIX/share/man] + --docdir=DIR directory for installing other docs [PREFIX/share/doc] --confdir=DIR directory for installing configuration files [PREFIX/etc/mpv] --localedir=DIR directory for gettext locales [PREFIX/share/locale] @@ -382,6 +383,7 @@ Miscellaneous options: --enable-static build a statically linked binary --with-install=PATH path to a custom install program --disable-manpage do not build and install manpage [auto] + --disable-pdf do not build and install PDF manual [auto] --disable-build-date do not include binary compile time Advanced options: @@ -495,6 +497,7 @@ _priority=no def_dos_paths="#define HAVE_DOS_PATHS 0" def_priority="#undef CONFIG_PRIORITY" _build_man=auto +_build_pdf=auto _build_date=yes for ac_option do case "$ac_option" in @@ -510,6 +513,9 @@ for ac_option do --mandir=*) _mandir=$(echo $ac_option | cut -d '=' -f 2) ;; + --docdir=*) + _docdir=$(echo $ac_option | cut -d '=' -f 2) + ;; --confdir=*) _confdir=$(echo $ac_option | cut -d '=' -f 2) ;; @@ -721,6 +727,8 @@ for ac_option do --enable-manpage) _build_man=yes ;; --disable-manpage) _build_man=no ;; + --enable-pdf) _build_pdf=yes ;; + --disable-pdf) _build_pdf=no ;; --enable-build-date) _build_date=yes ;; --disable-build-date) _build_date=no ;; @@ -735,6 +743,7 @@ done # Atmos: moved this here, to be correct, if --prefix is specified test -z "$_bindir" && _bindir="$_prefix/bin" test -z "$_mandir" && _mandir="$_prefix/share/man" +test -z "$_docdir" && _docdir="$_prefix/share/doc" test -z "$_confdir" && _confdir="$_prefix/etc/mpv" test -z "$_localedir" && _localedir="$_prefix/share/locale" @@ -928,6 +937,21 @@ else fi echores "$_build_man" +_rst2latex=rst2latex +if [ -f "$(which rst2latex.py)" ] ; then + _rst2latex=rst2latex.py +fi + +echocheck "whether to build manual PDFs with rst2latex" +if test "$_build_pdf" = auto ; then + _build_pdf=no + command_check "$_rst2latex" --version && + command_check pdflatex -version && _build_pdf=yes +else + _build_pdf=no +fi +echores "$_build_pdf" + echocheck "whether to print binary build date" if test "$_build_date" = yes ; then _build_yes=yes @@ -3071,6 +3095,7 @@ CONFIGURATION = $configuration prefix = \$(DESTDIR)$_prefix BINDIR = \$(DESTDIR)$_bindir MANDIR = \$(DESTDIR)$_mandir +DOCDIR = \$(DESTDIR)$_docdir CONFDIR = \$(DESTDIR)$_confdir LOCALEDIR = \$(DESTDIR)$_localedir @@ -3089,6 +3114,8 @@ GETCH = $_getch TIMER = $_timer RST2MAN = $_rst2man BUILD_MAN = $_build_man +RST2LATEX = $_rst2latex +BUILD_PDF = $_build_pdf EXESUF = $_exesuf EXESUFS_ALL = .exe -- cgit v1.2.3