Fix multi-file installation for files in srcdir.
[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)'; for p in $$list; do \
148           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
149           echo "$$d$$p"; \
150         done | $(am__base_list) | \
151         while read files; do \
152           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \
153           $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)"; done
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" || { echo "$$list2" | $(am__base_list) | \
171         while read files; do \
172           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \
173           $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)"; done; }
174
175 install-info-am: $(INFO_DEPS)
176         @$(NORMAL_INSTALL)
177         test -z "$(infodir)" || $(MKDIR_P) "$(DESTDIR)$(infodir)"
178         @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
179         list='$(INFO_DEPS)'; \
180         for file in $$list; do \
181 ## Strip possible $(srcdir) prefix.
182           case $$file in \
183             $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
184           esac; \
185           if test -f $$file; then d=.; else d=$(srcdir); fi; \
186 ## 8+3 filesystems cannot deal with foo.info-N filenames: they all
187 ## conflict.  DJGPP comes with a tool, DJTAR, that will rename these
188 ## files to foo.iNN while extracting the archive.  DJGPP's makeinfo
189 ## is patched to grok these filenames.  However we have to account
190 ## for the renaming when installing the info files.
191 ##
192 ## If $file == foo.info, then $file_i == foo.i.  The reason we use two
193 ## shell commands instead of one ('s|\.info$$|.i|') is so that a suffix-less
194 ## `foo' becomes `foo.i' too.
195           file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \
196           for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \
197                        $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
198             if test -f $$ifile; then \
199               echo "$$ifile"; \
200             else : ; fi; \
201           done; \
202         done | $(am__base_list) | \
203         while read files; do \
204           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \
205           $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)"; done
206         @$(POST_INSTALL)
207 ## Only run this code if install-info actually exists, and it is not
208 ## the Debian install-info.  FIXME: once Debian install-info goes
209 ## away, we can remove this hack.  Some versions of Debian install-info
210 ## print their version on stderr (e.g. 1.8.3), other do it in
211 ## on stdout (e.g. 1.10.15).
212 ##
213 ## Do not use
214 ##    install-info --version 2>&1 | sed 1q | grep -v -i debian
215 ## as if install-info does not exist, grep -v will be happy, and
216 ## therefore the code will be triggered although install-info is missing.
217         @if (install-info --version && \
218              install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
219           list='$(INFO_DEPS)'; \
220           for file in $$list; do \
221 ## Strip directory
222             relfile=`echo "$$file" | sed 's|^.*/||'`; \
223 ## Run `:' after install-info in case install-info fails.  We really
224 ## don't care about failures here, because they can be spurious.  For
225 ## instance if you don't have a dir file, install-info will fail.  I
226 ## think instead it should create a new dir file for you.  This bug
227 ## causes the `make distcheck' target to fail reliably.
228             echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\
229 ## Use `|| :' here because Sun make passes -e to sh; if install-info
230 ## fails then we'd fail if we used `;'.
231             install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\
232           done; \
233         else : ; fi
234
235 install-pdf-am: $(PDFS)
236         @$(NORMAL_INSTALL)
237         test -z "$(pdfdir)" || $(MKDIR_P) "$(DESTDIR)$(pdfdir)"
238         @list='$(PDFS)'; for p in $$list; do \
239           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
240           echo "$$d$$p"; \
241         done | $(am__base_list) | \
242         while read files; do \
243           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdfdir)'"; \
244           $(INSTALL_DATA) $$files "$(DESTDIR)$(pdfdir)"; done
245
246 install-ps-am: $(PSS)
247         @$(NORMAL_INSTALL)
248         test -z "$(psdir)" || $(MKDIR_P) "$(DESTDIR)$(psdir)"
249         @list='$(PSS)'; for p in $$list; do \
250           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
251           echo "$$d$$p"; \
252         done | $(am__base_list) | \
253         while read files; do \
254           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(psdir)'"; \
255           $(INSTALL_DATA) $$files "$(DESTDIR)$(psdir)"; done
256
257 else ! %?LOCAL-TEXIS%
258 install-dvi-am:
259 install-html-am:
260 install-info-am:
261 install-pdf-am:
262 install-ps-am:
263 endif ! %?LOCAL-TEXIS%
264
265
266 ## -------------- ##
267 ## Uninstalling.  ##
268 ## -------------- ##
269
270 if %?LOCAL-TEXIS%
271 .PHONY uninstall-am: \
272   uninstall-dvi-am \
273   uninstall-html-am \
274   uninstall-info-am \
275   uninstall-ps-am \
276   uninstall-pdf-am
277
278 uninstall-dvi-am:
279         @$(NORMAL_UNINSTALL)
280         @list='$(DVIS)'; for p in $$list; do \
281           $(am__strip_dir) \
282           echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \
283           rm -f "$(DESTDIR)$(dvidir)/$$f"; \
284         done
285
286 uninstall-html-am:
287         @$(NORMAL_UNINSTALL)
288         @list='$(HTMLS)'; for p in $$list; do \
289           $(am__strip_dir) \
290 ## $f can be a directory, hence the -r.
291           echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \
292           rm -rf "$(DESTDIR)$(htmldir)/$$f"; \
293         done
294
295 uninstall-info-am:
296         @$(PRE_UNINSTALL)
297 ## Run two loops here so that we can handle PRE_UNINSTALL and
298 ## NORMAL_UNINSTALL correctly.
299         @if test -d '$(DESTDIR)$(infodir)' && \
300             (install-info --version && \
301              install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
302           list='$(INFO_DEPS)'; \
303           for file in $$list; do \
304             relfile=`echo "$$file" | sed 's|^.*/||'`; \
305 ## install-info needs the actual info file.  We use the installed one,
306 ## rather than relying on one still being in srcdir or builddir.
307             echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \
308             install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
309           done; \
310         else :; fi
311         @$(NORMAL_UNINSTALL)
312         @list='$(INFO_DEPS)'; \
313         for file in $$list; do \
314           relfile=`echo "$$file" | sed 's|^.*/||'`; \
315 ## DJGPP-style info files.  See comment in install-info-am.
316           relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
317           (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \
318              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]"; \
319              rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
320            else :; fi); \
321         done
322
323 uninstall-pdf-am:
324         @$(NORMAL_UNINSTALL)
325         @list='$(PDFS)'; for p in $$list; do \
326           $(am__strip_dir) \
327           echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \
328           rm -f "$(DESTDIR)$(pdfdir)/$$f"; \
329         done
330
331 uninstall-ps-am:
332         @$(NORMAL_UNINSTALL)
333         @list='$(PSS)'; for p in $$list; do \
334           $(am__strip_dir) \
335           echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \
336           rm -f "$(DESTDIR)$(psdir)/$$f"; \
337         done
338 endif %?LOCAL-TEXIS%
339
340 if %?LOCAL-TEXIS%
341 .PHONY: dist-info
342 dist-info: $(INFO_DEPS)
343         @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
344         list='$(INFO_DEPS)'; \
345         for base in $$list; do \
346 ## Strip possible $(srcdir) prefix.
347           case $$base in \
348             $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
349           esac; \
350           if test -f $$base; then d=.; else d=$(srcdir); fi; \
351           base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \
352           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 \
353             if test -f $$file; then \
354 ## Strip leading '$$d/'.
355               relfile=`expr "$$file" : "$$d/\(.*\)"`; \
356               test -f "$(distdir)/$$relfile" || \
357                 cp -p $$file "$(distdir)/$$relfile"; \
358             else :; fi; \
359           done; \
360         done
361 endif %?LOCAL-TEXIS%
362
363
364 ## ---------- ##
365 ## Cleaning.  ##
366 ## ---------- ##
367
368 ## The funny name is due to --cygnus influence; in Cygnus mode,
369 ## `clean-info' is a target that users can use.
370
371 if %?LOCAL-TEXIS%
372 .PHONY mostlyclean-am: mostlyclean-aminfo
373 .PHONY: mostlyclean-aminfo
374 mostlyclean-aminfo:
375 ## Use `-rf', not just `-f', because %TEXICLEAN% also contains
376 ## any directory created by `makeinfo --html'.
377         -rm -rf %TEXICLEAN%
378
379 .PHONY maintainer-clean-am: maintainer-clean-aminfo
380 maintainer-clean-aminfo:
381         @list='$(INFO_DEPS)'; for i in $$list; do \
382 ## .iNN files are DJGPP-style info files.
383           i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \
384           echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \
385           rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \
386         done
387
388 ?CYGNUS?.PHONY: clean-info
389 ?CYGNUS?clean-info: mostlyclean-aminfo
390 endif %?LOCAL-TEXIS%