* lib/am/texinfos.am (install-info-am, uninstall-info-am): Strip
[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 --batch
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 ps-recursive
65 .PHONY info: info-recursive
66 .PHONY dvi: dvi-recursive
67 .PHONY pdf: pdf-recursive
68 .PHONY ps: ps-recursive
69 else !%?SUBDIRS%
70 info: info-am
71 dvi: dvi-am
72 pdf: pdf-am
73 ps: ps-am
74 endif !%?SUBDIRS%
75
76 if %?LOCAL-TEXIS%
77 info-am: $(INFO_DEPS)
78 dvi-am: $(DVIS)
79 pdf-am: $(PDFS)
80 ps-am: $(PSS)
81 else ! %?LOCAL-TEXIS%
82 info-am:
83 dvi-am:
84 pdf-am:
85 ps-am:
86 endif ! %?LOCAL-TEXIS%
87
88
89 ## ------------ ##
90 ## Installing.  ##
91 ## ------------ ##
92
93 ## Look in both . and srcdir because the info pages might have been
94 ## rebuilt in the build directory.  Can't cd to srcdir; that might
95 ## break a possible install-sh reference.
96 ##
97 ## Funny name due to --cygnus influence; we want to reserve
98 ## `install-info' for the user.
99 ##
100 ## TEXINFOS primary are always installed in infodir, hence install-data
101 ## is hard coded.
102 if %?INSTALL-INFO%
103 if %?LOCAL-TEXIS%
104 am__installdirs += $(DESTDIR)$(infodir)
105 install-data-am: install-info-am
106 endif %?LOCAL-TEXIS%
107 if %?SUBDIRS%
108 RECURSIVE_TARGETS += install-info-recursive
109 .PHONY install-info: install-info-recursive
110 else !%?SUBDIRS%
111 install-info: install-info-am
112 endif !%?SUBDIRS%
113 endif %?INSTALL-INFO%
114
115 .PHONY: install-info-am
116
117 if %?LOCAL-TEXIS%
118 install-info-am: $(INFO_DEPS)
119         @$(NORMAL_INSTALL)
120         $(mkinstalldirs) $(DESTDIR)$(infodir)
121         @list='$(INFO_DEPS)'; \
122         for file in $$list; do \
123           if test -f $$file; then d=.; else d=$(srcdir); fi; \
124           for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9]; do \
125             if test -f $$ifile; then \
126 ## Strip directory
127               relfile=`echo "$$ifile" | sed 's|^.*/||'`; \
128               echo " $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile"; \
129               $(INSTALL_DATA) $$ifile $(DESTDIR)$(infodir)/$$relfile; \
130             else : ; fi; \
131           done; \
132         done
133         @$(POST_INSTALL)
134 ## Only run this code if install-info actually exists, and it is not
135 ## the Debian install-info.  FIXME: once Debian install-info goes
136 ## away, we can remove this hack.  Debian install-info v1.8.3
137 ## prints version info to stderr.
138 ##
139 ## Do not use
140 ##    install-info --version 2>&1 | sed 1q | grep -s -v -i debian
141 ## as if install-info does not exist, grep -v will be happy, and
142 ## therefore the code will be triggered although install-info is missing.
143         @if (install-info --version && \
144              install-info --version | grep -i -v debian) >/dev/null 2>&1; then \
145           list='$(INFO_DEPS)'; \
146           for file in $$list; do \
147 ## Strip directory
148             relfile=`echo "$$file" | sed 's|^.*/||'`; \
149 ## Run `:' after install-info in case install-info fails.  We really
150 ## don't care about failures here, because they can be spurious.  For
151 ## instance if you don't have a dir file, install-info will fail.  I
152 ## think instead it should create a new dir file for you.  This bug
153 ## causes the `make distcheck' target to fail reliably.
154             echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile";\
155 ## Use `|| :' here because Sun make passes -e to sh; if install-info
156 ## fails then we'd fail if we used `;'.
157             install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$relfile || :;\
158           done; \
159         else : ; fi
160 else ! %?LOCAL-TEXIS%
161 install-info-am:
162 endif ! %?LOCAL-TEXIS%
163
164
165 ## -------------- ##
166 ## Uninstalling.  ##
167 ## -------------- ##
168
169 ?SUBDIRS?RECURSIVE_TARGETS += uninstall-info-recursive
170 ?SUBDIRS?.PHONY uninstall-info: uninstall-info-recursive
171 ?INSTALL-INFO?uninstall-am: uninstall-info-am
172
173 .PHONY: uninstall-info-am
174
175 if %?LOCAL-TEXIS%
176 uninstall-info-am:
177         $(PRE_UNINSTALL)
178 ## Run two loops here so that we can handle PRE_UNINSTALL and
179 ## NORMAL_UNINSTALL correctly.  Debian install-info v1.8.3 prints
180 ## version info to stderr.
181         @if (install-info --version && \
182              install-info --version | grep -i -v debian) >/dev/null 2>&1; then \
183           list='$(INFO_DEPS)'; \
184           for file in $$list; do \
185             relfile=`echo "$$file" | sed 's|^.*/||'`; \
186 ## install-info needs the actual info file.  We use the installed one,
187 ## rather than relying on one still being in srcdir or builddir.
188             echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$relfile"; \
189             install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$relfile; \
190           done; \
191         else :; fi
192         @$(NORMAL_UNINSTALL)
193         @list='$(INFO_DEPS)'; \
194         for file in $$list; do \
195           relfile=`echo "$$file" | sed 's|^.*/||'`; \
196           (if cd $(DESTDIR)$(infodir); then \
197              echo " rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9])"; \
198              rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9]; \
199            else :; fi); \
200         done
201 else ! %?LOCAL-TEXIS%
202 uninstall-info-am:
203 endif ! %?LOCAL-TEXIS%
204
205 if %?LOCAL-TEXIS%
206 .PHONY: dist-info
207 dist-info: $(INFO_DEPS)
208         list='$(INFO_DEPS)'; \
209         for base in $$list; do \
210           if test -f $$base; then d=.; else d=$(srcdir); fi; \
211           for file in $$d/$$base*; do \
212 ## Strip leading '$$d/'.
213             relfile=`expr "$$file" : "$$d/\(.*\)"`; \
214             test -f $(distdir)/$$relfile || \
215               cp -p $$file $(distdir)/$$relfile; \
216           done; \
217         done
218 endif %?LOCAL-TEXIS%
219
220
221 ## ---------- ##
222 ## Cleaning.  ##
223 ## ---------- ##
224
225 ## The funny name is due to --cygnus influence; in Cygnus mode,
226 ## `clean-info' is a target that users can use.
227
228 if %?LOCAL-TEXIS%
229 .PHONY: mostlyclean-aminfo
230 mostlyclean-am: mostlyclean-aminfo
231 mostlyclean-aminfo:
232         -rm -f %TEXICLEAN%
233
234 .PHONY: maintainer-clean-aminfo
235 maintainer-clean-am: maintainer-clean-aminfo
236 maintainer-clean-aminfo:
237 ## Eww.  But how else can we find all the output files from makeinfo?
238         list='$(INFO_DEPS)'; for i in $$list; do \
239           rm -f $$i; \
240           if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
241             rm -f $$i-[0-9]*; \
242           fi; \
243         done
244
245 ?CYGNUS?.PHONY: clean-info
246 ?CYGNUS?clean-info: mostlyclean-aminfo
247 endif %?LOCAL-TEXIS%