* lib/am/texibuild.am (%DEST_PREFIX%%DEST_SUFFIX%): Rename as ...
[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, 2003
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 TEXI2DVI = texi2dvi
28
29 else %?CYGNUS%
30
31 ## Find these programs wherever they may lie.  Yes, this has
32 ## intimate knowledge of the structure of the texinfo distribution.
33 MAKEINFO = `if test -f $(top_builddir)/../texinfo/makeinfo/makeinfo; then \
34             echo $(top_builddir)/../texinfo/makeinfo/makeinfo; \
35           else \
36             echo makeinfo; \
37           fi`
38
39 TEXI2DVI = `if test -f $(top_srcdir)/../texinfo/util/texi2dvi; then \
40              echo $(top_srcdir)/../texinfo/util/texi2dvi; \
41            else \
42              echo texi2dvi; \
43            fi`
44 endif %?CYGNUS%
45
46 TEXI2PDF = $(TEXI2DVI) --pdf --batch
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         $(DVIPS) -o $@ $<
59 endif %?LOCAL-TEXIS%
60
61 .PHONY: dvi dvi-am html html-am info info-am pdf pdf-am ps ps-am
62 if %?SUBDIRS%
63 RECURSIVE_TARGETS += dvi-recursive html-recursive info-recursive
64 RECURSIVE_TARGETS += pdf-recursive ps-recursive
65 dvi: dvi-recursive
66 html: html-recursive
67 info: info-recursive
68 pdf: pdf-recursive
69 ps: ps-recursive
70 else !%?SUBDIRS%
71 dvi: dvi-am
72 html: html-am
73 info: info-am
74 pdf: pdf-am
75 ps: ps-am
76 endif !%?SUBDIRS%
77
78 if %?LOCAL-TEXIS%
79 dvi-am: $(DVIS)
80 html-am: $(HTMLS)
81 info-am: $(INFO_DEPS)
82 pdf-am: $(PDFS)
83 ps-am: $(PSS)
84 else ! %?LOCAL-TEXIS%
85 dvi-am:
86 html-am:
87 info-am:
88 pdf-am:
89 ps-am:
90 endif ! %?LOCAL-TEXIS%
91
92
93 ## ------------ ##
94 ## Installing.  ##
95 ## ------------ ##
96
97 ## Look in both . and srcdir because the info pages might have been
98 ## rebuilt in the build directory.  Can't cd to srcdir; that might
99 ## break a possible install-sh reference.
100 ##
101 ## Funny name due to --cygnus influence; we want to reserve
102 ## `install-info' for the user.
103 ##
104 ## TEXINFOS primary are always installed in infodir, hence install-data
105 ## is hard coded.
106 if %?INSTALL-INFO%
107 if %?LOCAL-TEXIS%
108 am__installdirs += $(DESTDIR)$(infodir)
109 install-data-am: install-info-am
110 endif %?LOCAL-TEXIS%
111 .PHONY: install-info
112 if %?SUBDIRS%
113 RECURSIVE_TARGETS += install-info-recursive
114 install-info: install-info-recursive
115 else !%?SUBDIRS%
116 install-info: install-info-am
117 endif !%?SUBDIRS%
118 endif %?INSTALL-INFO%
119
120 .PHONY: install-info-am
121 if %?LOCAL-TEXIS%
122 install-info-am: $(INFO_DEPS)
123         @$(NORMAL_INSTALL)
124         $(mkinstalldirs) $(DESTDIR)$(infodir)
125         @list='$(INFO_DEPS)'; \
126         for file in $$list; do \
127           if test -f $$file; then d=.; else d=$(srcdir); fi; \
128 ## 8+3 filesystems cannot deal with foo.info-N filenames: they all
129 ## conflict.  DJGPP comes with a tool, DJTAR, that will rename these
130 ## files to foo.iNN while extracting the archive.  DJGPP's makeinfo
131 ## is patched to grok these filenames.  However we have to account
132 ## for the renaming when installing the info files.
133 ##
134 ## If $file == foo.info, then $file_i == foo.i.  The reason we use two
135 ## shell commands instead of one ('s|\.info$$|.i|') is so that a suffix-less
136 ## `foo' becomes `foo.i' too.
137           file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \
138           for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \
139                        $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
140             if test -f $$ifile; then \
141 ## Strip directory
142               relfile=`echo "$$ifile" | sed 's|^.*/||'`; \
143               echo " $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile"; \
144               $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile; \
145             else : ; fi; \
146           done; \
147         done
148         @$(POST_INSTALL)
149 ## Only run this code if install-info actually exists, and it is not
150 ## the Debian install-info.  FIXME: once Debian install-info goes
151 ## away, we can remove this hack.  Some versions of Debian install-info
152 ## print their version on stderr (e.g. 1.8.3), other do it in
153 ## on stdout (e.g. 1.10.15).
154 ##
155 ## Do not use
156 ##    install-info --version 2>&1 | sed 1q | grep -v -i debian
157 ## as if install-info does not exist, grep -v will be happy, and
158 ## therefore the code will be triggered although install-info is missing.
159         @if (install-info --version && \
160              install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
161           list='$(INFO_DEPS)'; \
162           for file in $$list; do \
163 ## Strip directory
164             relfile=`echo "$$file" | sed 's|^.*/||'`; \
165 ## Run `:' after install-info in case install-info fails.  We really
166 ## don't care about failures here, because they can be spurious.  For
167 ## instance if you don't have a dir file, install-info will fail.  I
168 ## think instead it should create a new dir file for you.  This bug
169 ## causes the `make distcheck' target to fail reliably.
170             echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile";\
171 ## Use `|| :' here because Sun make passes -e to sh; if install-info
172 ## fails then we'd fail if we used `;'.
173             install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile || :;\
174           done; \
175         else : ; fi
176 else ! %?LOCAL-TEXIS%
177 install-info-am:
178 endif ! %?LOCAL-TEXIS%
179
180
181 ## -------------- ##
182 ## Uninstalling.  ##
183 ## -------------- ##
184
185 ?SUBDIRS?RECURSIVE_TARGETS += uninstall-info-recursive
186 ?SUBDIRS?uninstall-info: uninstall-info-recursive
187 ?INSTALL-INFO?uninstall-am: uninstall-info-am
188
189 .PHONY: uninstall-info-am
190
191 if %?LOCAL-TEXIS%
192 uninstall-info-am:
193         $(PRE_UNINSTALL)
194 ## Run two loops here so that we can handle PRE_UNINSTALL and
195 ## NORMAL_UNINSTALL correctly.
196         @if (install-info --version && \
197              install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
198           list='$(INFO_DEPS)'; \
199           for file in $$list; do \
200             relfile=`echo "$$file" | sed 's|^.*/||'`; \
201 ## install-info needs the actual info file.  We use the installed one,
202 ## rather than relying on one still being in srcdir or builddir.
203             echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$relfile"; \
204             install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$relfile; \
205           done; \
206         else :; fi
207         @$(NORMAL_UNINSTALL)
208         @list='$(INFO_DEPS)'; \
209         for file in $$list; do \
210           relfile=`echo "$$file" | sed 's|^.*/||'`; \
211 ## DJGPP-style info files.  See comment in install-info-am.
212           relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
213           (if cd $(DESTDIR)$(infodir); then \
214              echo " rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9])"; \
215              rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
216            else :; fi); \
217         done
218 else ! %?LOCAL-TEXIS%
219 uninstall-info-am:
220 endif ! %?LOCAL-TEXIS%
221
222 if %?LOCAL-TEXIS%
223 .PHONY: dist-info
224 dist-info: $(INFO_DEPS)
225         @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
226         list='$(INFO_DEPS)'; \
227         for base in $$list; do \
228           case $$base in \
229             $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
230           esac; \
231           if test -f $$base; then d=.; else d=$(srcdir); fi; \
232           for file in $$d/$$base*; do \
233 ## Strip leading '$$d/'.
234             relfile=`expr "$$file" : "$$d/\(.*\)"`; \
235             test -f $(distdir)/$$relfile || \
236               cp -p $$file $(distdir)/$$relfile; \
237           done; \
238         done
239 endif %?LOCAL-TEXIS%
240
241
242 ## ---------- ##
243 ## Cleaning.  ##
244 ## ---------- ##
245
246 ## The funny name is due to --cygnus influence; in Cygnus mode,
247 ## `clean-info' is a target that users can use.
248
249 if %?LOCAL-TEXIS%
250 .PHONY mostlyclean-am: mostlyclean-aminfo
251 .PHONY: mostlyclean-aminfo
252 mostlyclean-aminfo:
253 ## Use `-rf', not just `-f', because %TEXICLEAN% also contains
254 ## any directory created by `makeinfo --html'.
255         -rm -rf %TEXICLEAN%
256
257 .PHONY maintainer-clean-am: maintainer-clean-aminfo
258 maintainer-clean-aminfo:
259         @list='$(INFO_DEPS)'; for i in $$list; do \
260 ## .iNN files are DJGPP-style info files.
261           i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \
262           echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \
263           rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \
264         done
265
266 ?CYGNUS?.PHONY: clean-info
267 ?CYGNUS?clean-info: mostlyclean-aminfo
268 endif %?LOCAL-TEXIS%