* lib/am/texibuild.am (?!GENERIC_INFO?%DEST_INFO_PREFIX%%DEST_SUFFIX%):
[automake.git] / lib / am / texibuild.am
blobf2c96f1dae910144038d0821d6ebe94999c526b3
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 ##   2003, 2004  Free Software Foundation, Inc.
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.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 ## 02111-1307, USA.
21 ?GENERIC_INFO?%SOURCE_SUFFIX%%DEST_SUFFIX%:
22 ?!GENERIC_INFO?%DEST_INFO_PREFIX%%DEST_SUFFIX%: %SOURCE_INFO% %DEPS%
23 ## It is wrong to have `info' files dependent on %DIRSTAMP%, because
24 ## `info' files are distributed and %DIRSTAMP% isn't: a distributed file
25 ## should never be dependent upon a non-distributed built file.
26 ## Therefore we ensure that %DIRSTAMP% exists in the rule.
27 ?!INSRC??DIRSTAMP?      @test -f %DIRSTAMP% || $(MAKE) %DIRSTAMP%
28 ## Back up the info files before running makeinfo. This is the cheapest
29 ## way to ensure that
30 ## 1) If the texinfo file shrinks (or if you start using --no-split),
31 ##    you'll not be left with some dead info files lying around -- dead
32 ##    files which would end up in the distribution.
33 ## 2) If the texinfo file has some minor mistakes which cause makeinfo
34 ##    to fail, the info files are not removed.  (They are needed by the
35 ##    developer while he writes documentation.)
36 ## *.iNN files are used on DJGPP.  See the comments in install-info-am
37         restore=: && backupdir="$(am__leading_dot)am$$$$" && \
38 ?INSRC? am__cwd=`pwd` && cd $(srcdir) && \
39         rm -rf $$backupdir && mkdir $$backupdir && \
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 ?INSRC? cd "$$am__cwd"; \
44         if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS% \
45 ?!INSRC?         -o $@ `test -f '%SOURCE_INFO%' || echo '$(srcdir)/'`%SOURCE_INFO%; \
46 ?INSRC??!GENERIC_INFO?   -o $@ $(srcdir)/%SOURCE_INFO%; \
47 ?INSRC??GENERIC_INFO?    -o $@ $<; \
48         then \
49           rc=0; \
50 ?INSRC?   cd $(srcdir); \
51         else \
52           rc=$$?; \
53 ## Beware that backup info files might come from a subdirectory.
54 ?INSRC?   cd $(srcdir) && \
55           $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
56         fi; \
57         rm -rf $$backupdir; exit $$rc
59 INFO_DEPS += %DEST_INFO_PREFIX%%DEST_SUFFIX%
61 ?GENERIC?%SOURCE_SUFFIX%.dvi:
62 ?!GENERIC?%DEST_PREFIX%.dvi: %SOURCE% %DEPS% %DIRSTAMP%
63         TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
64 ## Must set MAKEINFO like this so that version.texi will be found even
65 ## if it is in srcdir (-I $(srcdir) is set in %MAKEINFOFLAGS%).
66         MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS%' \
67 ## Do not use `-o' unless necessary: it is only supported since Texinfo 4.1.
68 ?GENERIC?       $(TEXI2DVI) %SOURCE%
69 ?!GENERIC?      $(TEXI2DVI) -o $@ `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
71 ?GENERIC?%SOURCE_SUFFIX%.pdf:
72 ?!GENERIC?%DEST_PREFIX%.pdf: %SOURCE% %DEPS% %DIRSTAMP%
73         TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
74 ## Must set MAKEINFO like this so that version.texi will be found even
75 ## if it is in srcdir (-I $(srcdir) is set in %MAKEINFOFLAGS%).
76         MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS%' \
77 ## Do not use `-o' unless necessary: it is only supported since Texinfo 4.1.
78 ?GENERIC?       $(TEXI2PDF) %SOURCE%
79 ?!GENERIC?      $(TEXI2PDF) -o $@ `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
81 ?GENERIC?%SOURCE_SUFFIX%.html:
82 ?!GENERIC?%DEST_PREFIX%.html: %SOURCE% %DEPS% %DIRSTAMP%
83         $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS% \
84 ?GENERIC?        -o $@ %SOURCE%
85 ?!GENERIC?       -o $@ `test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
86 ## Work around a bug in Texinfo 4.1 (-o foo.html outputs files in foo/
87 ## instead of foo.html/).
88         if test ! -d $@ && test -d $(@:.html=); then \
89           mv $(@:.html=) $@; else :; fi
91 ## If we are using the generic rules, we need separate dependencies.
92 ## (Don't wonder about %DIRSTAMP% here, this is used only by non-generic
93 ## rules.)
94 if %?GENERIC_INFO%
95 %DEST_INFO_PREFIX%%DEST_SUFFIX%: %SOURCE_REAL% %DEPS%
96 endif %?GENERIC_INFO%
97 if %?GENERIC%
98 %DEST_PREFIX%.dvi: %SOURCE_REAL% %DEPS%
99 %DEST_PREFIX%.pdf: %SOURCE_REAL% %DEPS%
100 %DEST_PREFIX%.html: %SOURCE_REAL% %DEPS%
101 endif %?GENERIC%