Merge branch 'micro' into maint
[platform/upstream/automake.git] / lib / am / texibuild.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994-2013 Free Software Foundation, Inc.
3
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
8
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
13
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18 ?GENERIC_INFO?%SOURCE_SUFFIX%%DEST_SUFFIX%:
19 ?!GENERIC_INFO?%DEST_INFO_PREFIX%%DEST_SUFFIX%: %SOURCE_INFO% %DEPS%
20 ## It is wrong to have 'info' files dependent on %DIRSTAMP%, because
21 ## 'info' files are distributed and %DIRSTAMP% isn't: a distributed file
22 ## should never be dependent upon a non-distributed built file.
23 ## Therefore we ensure that %DIRSTAMP% exists in the rule.
24 ?!INSRC??DIRSTAMP?      @test -f %DIRSTAMP% || $(MAKE) $(AM_MAKEFLAGS) %DIRSTAMP%
25 ## Back up the info files before running makeinfo. This is the cheapest
26 ## way to ensure that
27 ## 1) If the texinfo file shrinks (or if you start using --no-split),
28 ##    you'll not be left with some dead info files lying around -- dead
29 ##    files which would end up in the distribution.
30 ## 2) If the texinfo file has some minor mistakes which cause makeinfo
31 ##    to fail, the info files are not removed.  (They are needed by the
32 ##    developer while he writes documentation.)
33 ## *.iNN files are used on DJGPP.  See the comments in install-info-am
34         %AM_V_MAKEINFO%restore=: && backupdir="$(am__leading_dot)am$$$$" && \
35 ?INSRC? am__cwd=`pwd` && $(am__cd) $(srcdir) && \
36         rm -rf $$backupdir && mkdir $$backupdir && \
37 ## If makeinfo is not installed we must not backup the files so
38 ## 'missing' can do its job and touch $@ if it exists.
39         if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
40           for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
41             if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
42           done; \
43         else :; fi && \
44 ?INSRC? cd "$$am__cwd"; \
45         if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS% \
46 ?!INSRC?         -o $@ `test -f '%SOURCE_INFO%' || echo '$(srcdir)/'`%SOURCE_INFO%; \
47 ?INSRC??!GENERIC_INFO?   -o $@ $(srcdir)/%SOURCE_INFO%; \
48 ?INSRC??GENERIC_INFO?    -o $@ $<; \
49         then \
50           rc=0; \
51 ?INSRC?   $(am__cd) $(srcdir); \
52         else \
53           rc=$$?; \
54 ## Beware that backup info files might come from a subdirectory.
55 ?INSRC?   $(am__cd) $(srcdir) && \
56           $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
57         fi; \
58         rm -rf $$backupdir; exit $$rc
59
60 INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX%
61
62 ?GENERIC?%SOURCE_SUFFIX%.dvi:
63 ?!GENERIC?%DEST_PREFIX%.dvi: %SOURCE% %DEPS% %DIRSTAMP%
64         %AM_V_TEXI2DVI%TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
65 ## Must set MAKEINFO like this so that version.texi will be found even
66 ## if it is in srcdir (-I $(srcdir) is set in %MAKEINFOFLAGS%).
67         MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS%' \
68 ## texi2dvi doesn't silence everything with -q, redirect to /dev/null instead.
69 ## We still want -q (%TEXIQUIET%) because it turns on batch mode.
70 ## Use '--build-dir' so that TeX and Texinfo auxiliary files and build
71 ## by-products are left in there, instead of cluttering the current
72 ## directory (see automake bug#11146).  Use a different build-dir for
73 ## each file (and distinct from that of the corresponding PDF file) to
74 ## avoid hitting a Texinfop bug that could cause low-probability racy
75 ## failure when doing parallel builds; see:
76 ## http://lists.gnu.org/archive/html/automake-patches/2012-06/msg00073.html
77         $(TEXI2DVI) %TEXIQUIET% --build-dir=$(@:.dvi=.t2d) -o $@ %TEXIDEVNULL% \
78 ?GENERIC?       %SOURCE%
79 ?!GENERIC?      `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
80
81 ?GENERIC?%SOURCE_SUFFIX%.pdf:
82 ?!GENERIC?%DEST_PREFIX%.pdf: %SOURCE% %DEPS% %DIRSTAMP%
83         %AM_V_TEXI2PDF%TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
84 ## Must set MAKEINFO like this so that version.texi will be found even
85 ## if it is in srcdir (-I $(srcdir) is set in %MAKEINFOFLAGS%).
86         MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS%' \
87 ## texi2pdf doesn't silence everything with -q, redirect to /dev/null instead.
88 ## We still want -q (%TEXIQUIET%) because it turns on batch mode.
89 ## Use '--build-dir' so that TeX and Texinfo auxiliary files and build
90 ## by-products are left in there, instead of cluttering the current
91 ## directory (see automake bug#11146).  Use a different build-dir for
92 ## each file (and distinct from that of the corresponding DVI file) to
93 ## avoid hitting a Texinfop bug that could cause low-probability racy
94 ## failure when doing parallel builds; see:
95 ## http://lists.gnu.org/archive/html/automake-patches/2012-06/msg00073.html
96         $(TEXI2PDF) %TEXIQUIET% --build-dir=$(@:.pdf=.t2p) -o $@ %TEXIDEVNULL% \
97 ?GENERIC?       %SOURCE%
98 ?!GENERIC?      `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
99
100 ?GENERIC?%SOURCE_SUFFIX%.html:
101 ?!GENERIC?%DEST_PREFIX%.html: %SOURCE% %DEPS% %DIRSTAMP%
102 ## When --split (the default) is used, makeinfo will output a
103 ## directory.  However it will not update the time stamp of a
104 ## previously existing directory, and when the names of the nodes
105 ## in the manual change, it may leave unused pages.  Our fix
106 ## is to build under a temporary name, and replace the target on
107 ## success.
108         %AM_V_MAKEINFO%rm -rf $(@:.html=.htp)
109         %SILENT%if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS% \
110 ?GENERIC?        -o $(@:.html=.htp) %SOURCE%; \
111 ?!GENERIC?       -o $(@:.html=.htp) `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%; \
112         then \
113           rm -rf $@ && mv $(@:.html=.htp) $@; \
114         else \
115           rm -rf $(@:.html=.htp); exit 1; \
116         fi
117
118 ## If we are using the generic rules, we need separate dependencies.
119 ## (Don't wonder about %DIRSTAMP% here, this is used only by non-generic
120 ## rules.)
121 if %?GENERIC_INFO%
122 %DEST_INFO_PREFIX%%DEST_SUFFIX%: %SOURCE_REAL% %DEPS%
123 endif %?GENERIC_INFO%
124 if %?GENERIC%
125 %DEST_PREFIX%.dvi: %SOURCE_REAL% %DEPS%
126 %DEST_PREFIX%.pdf: %SOURCE_REAL% %DEPS%
127 %DEST_PREFIX%.html: %SOURCE_REAL% %DEPS%
128 endif %?GENERIC%