2002-05-03 Paolo Bonzini <bonzini@gnu.org>
[platform/upstream/automake.git] / lib / am / texinfos.am
1 ## automake - create Makefile.in from Makefile.am
2
3 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 ## Free Software Foundation, Inc.
5
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2, or (at your option)
9 ## any later version.
10
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, write to the Free Software
18 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 ## 02111-1307, USA.
20
21 ## ----------- ##
22 ## Variables.  ##
23 ## ----------- ##
24
25 if %?LOCAL-TEXIS%
26 if ! %?CYGNUS%
27 MAKEINFO = @MAKEINFO@
28 TEXI2DVI = texi2dvi
29
30 else %?CYGNUS%
31
32 ## Find these programs wherever they may lie.  Yes, this has
33 ## intimate knowledge of the structure of the texinfo distribution.
34 MAKEINFO = `if test -f $(top_builddir)/../texinfo/makeinfo/makeinfo; then \
35             echo $(top_builddir)/../texinfo/makeinfo/makeinfo; \
36           else \
37             echo makeinfo; \
38           fi`
39
40 TEXI2DVI = `if test -f $(top_srcdir)/../texinfo/util/texi2dvi; then \
41              echo $(top_srcdir)/../texinfo/util/texi2dvi; \
42            else \
43              echo texi2dvi; \
44            fi`
45 endif %?CYGNUS%
46
47 TEXI2PDF = $(TEXI2DVI) --pdf
48 endif %?LOCAL-TEXIS%
49
50
51 ## ---------- ##
52 ## Building.  ##
53 ## ---------- ##
54
55 ## The way to make PostScript, for those who want it.
56 if %?LOCAL-TEXIS%
57 DVIPS = dvips
58 .dvi.ps:
59         $(DVIPS) $< -o $@
60 endif %?LOCAL-TEXIS%
61
62 .PHONY: info info-am dvi dvi-am pdf pdf-am
63 if %?SUBDIRS%
64 RECURSIVE_TARGETS += info-recursive dvi-recursive pdf-recursive
65 .PHONY info: info-recursive
66 .PHONY dvi: dvi-recursive
67 .PHONY pdf: pdf-recursive
68 else !%?SUBDIRS%
69 info: info-am
70 dvi: dvi-am
71 pdf: pdf-am
72 endif !%?SUBDIRS%
73
74 if %?LOCAL-TEXIS%
75 info-am: $(INFO_DEPS)
76 dvi-am: $(DVIS)
77 pdf-am: $(PDFS)
78 else ! %?LOCAL-TEXIS%
79 info-am:
80 dvi-am:
81 pdf-am:
82 endif ! %?LOCAL-TEXIS%
83
84
85 ## ------------ ##
86 ## Installing.  ##
87 ## ------------ ##
88
89 ## Look in both . and srcdir because the info pages might have been
90 ## rebuilt in the build directory.  Can't cd to srcdir; that might
91 ## break a possible install-sh reference.
92 ##
93 ## Funny name due to --cygnus influence; we want to reserve
94 ## `install-info' for the user.
95 ##
96 ## TEXINFOS primary are always installed in infodir, hence install-data
97 ## is hard coded.
98 if %?INSTALL-INFO%
99 if %?LOCAL-TEXIS%
100 _am_installdirs += $(DESTDIR)$(infodir)
101 install-data-am: install-info-am
102 endif %?LOCAL-TEXIS%
103 if %?SUBDIRS%
104 RECURSIVE_TARGETS += install-info-recursive
105 .PHONY install-info: install-info-recursive
106 else !%?SUBDIRS%
107 install-info: install-info-am
108 endif !%?SUBDIRS%
109 endif %?INSTALL-INFO%
110
111 .PHONY: install-info-am
112
113 if %?LOCAL-TEXIS%
114 install-info-am: $(INFO_DEPS)
115         @$(NORMAL_INSTALL)
116         $(mkinstalldirs) $(DESTDIR)$(infodir)
117         @list='$(INFO_DEPS)'; \
118         for file in $$list; do \
119 ?CYGNUS?          if test -f $$file; then d=.; else d=$(srcdir); fi; \
120 ?!CYGNUS?         d=$(srcdir); \
121           for ifile in echo $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9]; do \
122             if test -f $$ifile; then \
123 ## Strip leading '$$d/'.
124               relfile=`expr "$$ifile" : "$$d/\(.*\)"`; \
125               echo " $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile"; \
126               $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile; \
127             else : ; fi; \
128           done; \
129         done
130         @$(POST_INSTALL)
131 ## Only run this code if install-info actually exists, and it is not
132 ## the Debian install-info.  FIXME: once Debian install-info goes
133 ## away, we can remove this hack.  Debian install-info v1.8.3
134 ## prints version info to stderr.
135 ##
136 ## Do not use
137 ##    install-info --version 2>&1 | sed 1q | grep -s -v -i debian
138 ## as if install-info does not exist, grep -v will be happy, and
139 ## therefore the code will be triggered although install-info is missing.
140         @if (install-info --version && \
141              install-info --version | grep -i -v debian) >/dev/null 2>&1; then \
142           list='$(INFO_DEPS)'; \
143           for file in $$list; do \
144 ## Run `:' after install-info in case install-info fails.  We really
145 ## don't care about failures here, because they can be spurious.  For
146 ## instance if you don't have a dir file, install-info will fail.  I
147 ## think instead it should create a new dir file for you.  This bug
148 ## causes the `make distcheck' target to fail reliably.
149             echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\
150 ## Use `|| :' here because Sun make passes -e to sh; if install-info
151 ## fails then we'd fail if we used `;'.
152             install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\
153           done; \
154         else : ; fi
155 else ! %?LOCAL-TEXIS%
156 install-info-am:
157 endif ! %?LOCAL-TEXIS%
158
159
160 ## -------------- ##
161 ## Uninstalling.  ##
162 ## -------------- ##
163
164 ?SUBDIRS?RECURSIVE_TARGETS += uninstall-info-recursive
165 ?SUBDIRS?.PHONY uninstall-info: uninstall-info-recursive
166 ?INSTALL-INFO?uninstall-am: uninstall-info-am
167
168 .PHONY: uninstall-info-am
169
170 if %?LOCAL-TEXIS%
171 uninstall-info-am:
172         $(PRE_UNINSTALL)
173 ## Run two loops here so that we can handle PRE_UNINSTALL and
174 ## NORMAL_UNINSTALL correctly.  Debian install-info v1.8.3 prints
175 ## version info to stderr.
176         @if (install-info --version && \
177              install-info --version | grep -i -v debian) >/dev/null 2>&1; then \
178           list='$(INFO_DEPS)'; \
179           for file in $$list; do \
180 ## install-info needs the actual info file.  We use the installed one,
181 ## rather than relying on one still being in srcdir or builddir.
182             echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$file"; \
183             install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$file; \
184           done; \
185         else :; fi
186         @$(NORMAL_UNINSTALL)
187         @list='$(INFO_DEPS)'; \
188         for file in $$list; do \
189           (if cd $(DESTDIR)$(infodir); then \
190              echo " rm -f $$file $$file-[0-9] $$file-[0-9][0-9])"; \
191              rm -f $$file $$file-[0-9] $$file-[0-9][0-9]; \
192            else :; fi); \
193         done
194 else ! %?LOCAL-TEXIS%
195 uninstall-info-am:
196 endif ! %?LOCAL-TEXIS%
197
198 if %?LOCAL-TEXIS%
199 .PHONY: dist-info
200 dist-info: $(INFO_DEPS)
201         list='$(INFO_DEPS)'; \
202         for base in $$list; do \
203 ## In Cygnus mode, allow info file to be in source or build dir.  In
204 ## other modes, allow only source dir.
205 ?!CYGNUS?         d=$(srcdir); \
206 ?CYGNUS?          if test -f $$base; then d=.; else d=$(srcdir); fi; \
207           for file in $$d/$$base*; do \
208 ## Strip leading '$$d/'.
209             relfile=`expr "$$file" : "$$d/\(.*\)"`; \
210             test -f $(distdir)/$$relfile || \
211               cp -p $$file $(distdir)/$$relfile; \
212           done; \
213         done
214 endif %?LOCAL-TEXIS%
215
216
217 ## ---------- ##
218 ## Cleaning.  ##
219 ## ---------- ##
220
221 ## The funny name is due to --cygnus influence; in Cygnus mode,
222 ## `clean-info' is a target that users can use.
223
224 if %?LOCAL-TEXIS%
225 .PHONY: mostlyclean-aminfo
226 mostlyclean-am: mostlyclean-aminfo
227 mostlyclean-aminfo:
228         -rm -f %TEXICLEAN%
229
230 .PHONY: maintainer-clean-aminfo
231 maintainer-clean-am: maintainer-clean-aminfo
232 maintainer-clean-aminfo:
233 ## Eww.  But how else can we find all the output files from makeinfo?
234 ?!CYGNUS?       cd $(srcdir) && \
235         list='$(INFO_DEPS)'; for i in $$list; do \
236           rm -f $$i; \
237           if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
238             rm -f $$i-[0-9]*; \
239           fi; \
240         done
241
242 ?CYGNUS?.PHONY: clean-info
243 ?CYGNUS?clean-info: mostlyclean-aminfo
244 endif %?LOCAL-TEXIS%