Exploit `install' with multiple files at once for some file types.
[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 ## 2003, 2004, 2005, 2006, 2007, 2008 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 3, 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, see <http://www.gnu.org/licenses/>.
18
19 ## ----------- ##
20 ## Variables.  ##
21 ## ----------- ##
22
23 if %?LOCAL-TEXIS%
24 if ! %?CYGNUS%
25 TEXI2DVI = texi2dvi
26
27 else %?CYGNUS%
28
29 ## Find these programs wherever they may lie.  Yes, this has
30 ## intimate knowledge of the structure of the texinfo distribution.
31 MAKEINFO = `if test -f $(top_builddir)/../texinfo/makeinfo/makeinfo; then \
32             echo $(top_builddir)/../texinfo/makeinfo/makeinfo; \
33           else \
34             echo makeinfo; \
35           fi`
36
37 TEXI2DVI = `if test -f $(top_srcdir)/../texinfo/util/texi2dvi; then \
38              echo $(top_srcdir)/../texinfo/util/texi2dvi; \
39            else \
40              echo texi2dvi; \
41            fi`
42 endif %?CYGNUS%
43
44 TEXI2PDF = $(TEXI2DVI) --pdf --batch
45 MAKEINFOHTML = $(MAKEINFO) --html
46 AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
47 endif %?LOCAL-TEXIS%
48
49
50 ## ---------- ##
51 ## Building.  ##
52 ## ---------- ##
53
54 ## The way to make PostScript, for those who want it.
55 if %?LOCAL-TEXIS%
56 DVIPS = dvips
57 .dvi.ps:
58         TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
59         $(DVIPS) -o $@ $<
60 endif %?LOCAL-TEXIS%
61
62 .PHONY: dvi dvi-am html html-am info info-am pdf pdf-am ps ps-am
63 if %?SUBDIRS%
64 RECURSIVE_TARGETS += dvi-recursive html-recursive info-recursive
65 RECURSIVE_TARGETS += pdf-recursive ps-recursive
66 dvi: dvi-recursive
67 html: html-recursive
68 info: info-recursive
69 pdf: pdf-recursive
70 ps: ps-recursive
71 else !%?SUBDIRS%
72 dvi: dvi-am
73 html: html-am
74 info: info-am
75 pdf: pdf-am
76 ps: ps-am
77 endif !%?SUBDIRS%
78
79 if %?LOCAL-TEXIS%
80 dvi-am: $(DVIS)
81 html-am: $(HTMLS)
82 info-am: $(INFO_DEPS)
83 pdf-am: $(PDFS)
84 ps-am: $(PSS)
85 else ! %?LOCAL-TEXIS%
86 dvi-am:
87 html-am:
88 info-am:
89 pdf-am:
90 ps-am:
91 endif ! %?LOCAL-TEXIS%
92
93
94 ## ------------ ##
95 ## Installing.  ##
96 ## ------------ ##
97
98 ## Look in both . and srcdir because the info pages might have been
99 ## rebuilt in the build directory.  Can't cd to srcdir; that might
100 ## break a possible install-sh reference.
101 ##
102 ## Funny name due to --cygnus influence; we want to reserve
103 ## `install-info' for the user.
104 ##
105 ## TEXINFOS primary are always installed in infodir, hence install-data
106 ## is hard coded.
107 if %?INSTALL-INFO%
108 if %?LOCAL-TEXIS%
109 am__installdirs += "$(DESTDIR)$(infodir)"
110 install-data-am: install-info-am
111 endif %?LOCAL-TEXIS%
112 endif %?INSTALL-INFO%
113 .PHONY: \
114   install-dvi  install-dvi-am \
115   install-html install-html-am \
116   install-info install-info-am \
117   install-pdf  install-pdf-am \
118   install-ps   install-ps-am
119
120 if %?SUBDIRS%
121 RECURSIVE_TARGETS += \
122   install-dvi-recursive \
123   install-html-recursive \
124   install-info-recursive \
125   install-pdf-recursive \
126   install-ps-recursive
127 install-dvi: install-dvi-recursive
128 install-html: install-html-recursive
129 install-info: install-info-recursive
130 install-pdf: install-pdf-recursive
131 install-ps: install-ps-recursive
132 else !%?SUBDIRS%
133 install-dvi: install-dvi-am
134 install-html: install-html-am
135 install-info: install-info-am
136 install-pdf: install-pdf-am
137 install-ps: install-ps-am
138 endif !%?SUBDIRS%
139
140 if %?LOCAL-TEXIS%
141
142 include inst-vars.am
143
144 install-dvi-am: $(DVIS)
145         @$(NORMAL_INSTALL)
146         test -z "$(dvidir)" || $(MKDIR_P) "$(DESTDIR)$(dvidir)"
147         @list='$(DVIS)'; list2=; for p in $$list; do \
148           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
149           list2="$$list2 $$d$$p"; \
150         done; \
151         test -z "$$list2" || { \
152           echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(dvidir)'"; \
153           $(INSTALL_DATA) $$list2 "$(DESTDIR)$(dvidir)"; }
154
155 install-html-am: $(HTMLS)
156         @$(NORMAL_INSTALL)
157         test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"
158         @list='$(HTMLS)'; list2=; for p in $$list; do \
159           if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \
160           $(am__strip_dir) \
161           if test -d "$$d$$p"; then \
162             echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \
163             $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
164             echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
165             $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
166           else \
167             list2="$$list2 $$d$$p"; \
168           fi; \
169         done; \
170         test -z "$$list2" || { \
171             echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(htmldir)'"; \
172             $(INSTALL_DATA) $$list2 "$(DESTDIR)$(htmldir)"; }
173
174 install-info-am: $(INFO_DEPS)
175         @$(NORMAL_INSTALL)
176         test -z "$(infodir)" || $(MKDIR_P) "$(DESTDIR)$(infodir)"
177         @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
178         list='$(INFO_DEPS)'; list2=; \
179         for file in $$list; do \
180 ## Strip possible $(srcdir) prefix.
181           case $$file in \
182             $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
183           esac; \
184           if test -f $$file; then d=.; else d=$(srcdir); fi; \
185 ## 8+3 filesystems cannot deal with foo.info-N filenames: they all
186 ## conflict.  DJGPP comes with a tool, DJTAR, that will rename these
187 ## files to foo.iNN while extracting the archive.  DJGPP's makeinfo
188 ## is patched to grok these filenames.  However we have to account
189 ## for the renaming when installing the info files.
190 ##
191 ## If $file == foo.info, then $file_i == foo.i.  The reason we use two
192 ## shell commands instead of one ('s|\.info$$|.i|') is so that a suffix-less
193 ## `foo' becomes `foo.i' too.
194           file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \
195           for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \
196                        $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
197             if test -f $$ifile; then \
198               list2="$$list2 $$ifile"; \
199             else : ; fi; \
200           done; \
201         done; \
202         test -z "$$list2" || { \
203           echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(infodir)'"; \
204           $(INSTALL_DATA) $$list2 "$(DESTDIR)$(infodir)"; }
205         @$(POST_INSTALL)
206 ## Only run this code if install-info actually exists, and it is not
207 ## the Debian install-info.  FIXME: once Debian install-info goes
208 ## away, we can remove this hack.  Some versions of Debian install-info
209 ## print their version on stderr (e.g. 1.8.3), other do it in
210 ## on stdout (e.g. 1.10.15).
211 ##
212 ## Do not use
213 ##    install-info --version 2>&1 | sed 1q | grep -v -i debian
214 ## as if install-info does not exist, grep -v will be happy, and
215 ## therefore the code will be triggered although install-info is missing.
216         @if (install-info --version && \
217              install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
218           list='$(INFO_DEPS)'; \
219           for file in $$list; do \
220 ## Strip directory
221             relfile=`echo "$$file" | sed 's|^.*/||'`; \
222 ## Run `:' after install-info in case install-info fails.  We really
223 ## don't care about failures here, because they can be spurious.  For
224 ## instance if you don't have a dir file, install-info will fail.  I
225 ## think instead it should create a new dir file for you.  This bug
226 ## causes the `make distcheck' target to fail reliably.
227             echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\
228 ## Use `|| :' here because Sun make passes -e to sh; if install-info
229 ## fails then we'd fail if we used `;'.
230             install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\
231           done; \
232         else : ; fi
233
234 install-pdf-am: $(PDFS)
235         @$(NORMAL_INSTALL)
236         test -z "$(pdfdir)" || $(MKDIR_P) "$(DESTDIR)$(pdfdir)"
237         @list='$(PDFS)'; list2=; for p in $$list; do \
238           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
239           list2="$$list2 $$d$$p"; \
240         done; \
241         test -z "$$list2" || { \
242           echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(pdfdir)'"; \
243           $(INSTALL_DATA) $$list2 "$(DESTDIR)$(pdfdir)"; }
244
245 install-ps-am: $(PSS)
246         @$(NORMAL_INSTALL)
247         test -z "$(psdir)" || $(MKDIR_P) "$(DESTDIR)$(psdir)"
248         @list='$(PSS)'; list2=; for p in $$list; do \
249           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
250           list2="$$list2 $$d$$p"; \
251         done; \
252         test -z "$$list2" || { \
253           echo " $(INSTALL_DATA) $$list2 '$(DESTDIR)$(psdir)'"; \
254           $(INSTALL_DATA) $$list2 "$(DESTDIR)$(psdir)"; }
255
256 else ! %?LOCAL-TEXIS%
257 install-dvi-am:
258 install-html-am:
259 install-info-am:
260 install-pdf-am:
261 install-ps-am:
262 endif ! %?LOCAL-TEXIS%
263
264
265 ## -------------- ##
266 ## Uninstalling.  ##
267 ## -------------- ##
268
269 if %?LOCAL-TEXIS%
270 .PHONY uninstall-am: \
271   uninstall-dvi-am \
272   uninstall-html-am \
273   uninstall-info-am \
274   uninstall-ps-am \
275   uninstall-pdf-am
276
277 uninstall-dvi-am:
278         @$(NORMAL_UNINSTALL)
279         @list='$(DVIS)'; for p in $$list; do \
280           $(am__strip_dir) \
281           echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \
282           rm -f "$(DESTDIR)$(dvidir)/$$f"; \
283         done
284
285 uninstall-html-am:
286         @$(NORMAL_UNINSTALL)
287         @list='$(HTMLS)'; for p in $$list; do \
288           $(am__strip_dir) \
289 ## $f can be a directory, hence the -r.
290           echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \
291           rm -rf "$(DESTDIR)$(htmldir)/$$f"; \
292         done
293
294 uninstall-info-am:
295         @$(PRE_UNINSTALL)
296 ## Run two loops here so that we can handle PRE_UNINSTALL and
297 ## NORMAL_UNINSTALL correctly.
298         @if test -d '$(DESTDIR)$(infodir)' && \
299             (install-info --version && \
300              install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
301           list='$(INFO_DEPS)'; \
302           for file in $$list; do \
303             relfile=`echo "$$file" | sed 's|^.*/||'`; \
304 ## install-info needs the actual info file.  We use the installed one,
305 ## rather than relying on one still being in srcdir or builddir.
306             echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \
307             install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
308           done; \
309         else :; fi
310         @$(NORMAL_UNINSTALL)
311         @list='$(INFO_DEPS)'; \
312         for file in $$list; do \
313           relfile=`echo "$$file" | sed 's|^.*/||'`; \
314 ## DJGPP-style info files.  See comment in install-info-am.
315           relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
316           (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \
317              echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \
318              rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
319            else :; fi); \
320         done
321
322 uninstall-pdf-am:
323         @$(NORMAL_UNINSTALL)
324         @list='$(PDFS)'; for p in $$list; do \
325           $(am__strip_dir) \
326           echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \
327           rm -f "$(DESTDIR)$(pdfdir)/$$f"; \
328         done
329
330 uninstall-ps-am:
331         @$(NORMAL_UNINSTALL)
332         @list='$(PSS)'; for p in $$list; do \
333           $(am__strip_dir) \
334           echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \
335           rm -f "$(DESTDIR)$(psdir)/$$f"; \
336         done
337 endif %?LOCAL-TEXIS%
338
339 if %?LOCAL-TEXIS%
340 .PHONY: dist-info
341 dist-info: $(INFO_DEPS)
342         @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
343         list='$(INFO_DEPS)'; \
344         for base in $$list; do \
345 ## Strip possible $(srcdir) prefix.
346           case $$base in \
347             $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
348           esac; \
349           if test -f $$base; then d=.; else d=$(srcdir); fi; \
350           base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \
351           for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \
352             if test -f $$file; then \
353 ## Strip leading '$$d/'.
354               relfile=`expr "$$file" : "$$d/\(.*\)"`; \
355               test -f "$(distdir)/$$relfile" || \
356                 cp -p $$file "$(distdir)/$$relfile"; \
357             else :; fi; \
358           done; \
359         done
360 endif %?LOCAL-TEXIS%
361
362
363 ## ---------- ##
364 ## Cleaning.  ##
365 ## ---------- ##
366
367 ## The funny name is due to --cygnus influence; in Cygnus mode,
368 ## `clean-info' is a target that users can use.
369
370 if %?LOCAL-TEXIS%
371 .PHONY mostlyclean-am: mostlyclean-aminfo
372 .PHONY: mostlyclean-aminfo
373 mostlyclean-aminfo:
374 ## Use `-rf', not just `-f', because %TEXICLEAN% also contains
375 ## any directory created by `makeinfo --html'.
376         -rm -rf %TEXICLEAN%
377
378 .PHONY maintainer-clean-am: maintainer-clean-aminfo
379 maintainer-clean-aminfo:
380         @list='$(INFO_DEPS)'; for i in $$list; do \
381 ## .iNN files are DJGPP-style info files.
382           i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \
383           echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \
384           rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \
385         done
386
387 ?CYGNUS?.PHONY: clean-info
388 ?CYGNUS?clean-info: mostlyclean-aminfo
389 endif %?LOCAL-TEXIS%