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