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