Update.
[glibc.git] / manual / Makefile
blobc5ca263537d1ff03cc059b997a1ccdc17b500eed
1 # Copyright (C) 1992, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Library General Public License
6 # as published by the Free Software Foundation; either version 2 of
7 # the License, or (at your option) any later version.
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB. If not,
16 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
19 # Makefile for the GNU C Library manual.
21 subdir := manual
22 export subdir := $(subdir)
24 # Allow override
25 INSTALL_INFO = install-info
27 .PHONY: all dvi info
28 all: dvi
29 dvi: libc.dvi
31 # Get glibc's configuration info.
32 ifneq (,$(wildcard ../Makeconfig))
33 include ../Makeconfig
34 else
35 MAKEINFO = makeinfo
36 TEXI2DVI = texi2dvi
37 endif
39 ifneq ($(strip $(MAKEINFO)),)
40 all: info
41 info: libc.info dir-add.info
42 endif
44 # Set chapters and chapters-incl[12].
45 -include chapters
46 chapters: libc.texinfo
47 $(find-includes)
48 ifdef chapters
49 # @includes in chapter files
50 -include chapters-incl1
51 chapters-incl1: $(chapters)
52 $(find-includes)
53 chapters-incl1 := $(filter-out summary.texi,$(chapters-incl1))
54 endif
55 ifdef chapters-incl1
56 # @includes in files included by chapter files, if any
57 -include chapters-incl2
58 chapters-incl2: $(chapters-incl1)
59 $(find-includes)
60 endif
62 chapters-incl := $(chapters-incl1) $(chapters-incl2)
64 define find-includes
65 (echo '$(@F) :=' \\ ;\
66 $(AWK) '$$1 == "@include" { print $$2 " \\" }' $^) > $@.new
67 mv -f $@.new $@
68 endef
70 # scripts we use
71 ifndef move-if-change
72 move-if-change = ./move-if-change
73 endif
74 mkinstalldirs = $(..)scripts/mkinstalldirs
76 libc.dvi libc.info: $(chapters) summary.texi $(chapters-incl)
77 libc.dvi: texinfo.tex
79 %.info: %.texinfo
80 $(MAKEINFO) $<
82 %.dvi: %.texinfo
83 $(TEXI2DVI) $<
85 # Generate the summary from the Texinfo source files for each chapter.
86 summary.texi: stamp-summary ;
87 stamp-summary: summary.awk $(chapters) $(chapters-incl)
88 $(AWK) -f $^ \
89 | sort -df +1 -2 | tr '\014' '\012' > summary-tmp
90 $(move-if-change) summary-tmp summary.texi
91 touch $@
93 # Generate a file which can be added to the `dir' content to provide direct
94 # access to the documentation of the function, variables, and other
95 # definitions.
96 dir-add.texinfo: xtract-typefun.awk $(chapters) $(chapters-incl)
97 (echo "@dircategory GNU C library functions"; \
98 echo "@direntry"; \
99 $(AWK) -f $^; \
100 echo "@end direntry") > $@.new
101 mv -f $@.new $@
103 # Generate Texinfo files from the C source for the example programs.
104 %.c.texi: examples/%.c
105 sed -e 's,[{}],@&,g' \
106 -e 's,/\*\(@.*\)\*/,\1,g' \
107 -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \
108 -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\
109 $< | expand > $@.new
110 mv -f $@.new $@
113 minimal-dist = summary.awk libc.texinfo $(chapters) \
114 $(patsubst %.c.texi,examples/%.c, \
115 $(filter-out summary.texi,$(chapters-incl)))
116 doc-only-dist = Makefile COPYING.LIB
117 distribute = $(minimal-dist) \
118 $(patsubst examples/%.c,%.c.texi,$(filter examples/%.c, \
119 $(minimal-dist))) \
120 libc.info* libc.?? libc.??s texinfo.tex summary.texi \
121 stamp-summary chapters chapters-incl1 chapters-incl2 \
122 xtract-typefun.awk dir-add.texinfo dir-add.info dir \
123 stdio-fp.c
124 export distribute := $(distribute)
126 tar-it = tar chovf $@ $^
128 manual.tar: $(doc-only-dist) $(minimal-dist) ; $(tar-it)
129 mandist.tar: $(doc-only-dist) $(distribute) ; $(tar-it)
131 edition := $(shell sed -n 's/^@set EDITION \([0-9][0-9.]*\)[^0-9.]*.*$$/\1/p' \
132 libc.texinfo)
134 glibc-doc-$(edition).tar: $(doc-only-dist) $(distribute)
135 @rm -f glibc-doc-$(edition)
136 ln -s . glibc-doc-$(edition)
137 tar chovf $@ $(addprefix glibc-doc-$(edition)/,$^)
138 rm -f glibc-doc-$(edition)
140 %.Z: %
141 compress -c $< > $@.new
142 mv -f $@.new $@
143 %.gz: %
144 gzip -9 -c $< > $@.new
145 mv -f $@.new $@
146 %.uu: %
147 uuencode $< < $< > $@.new
148 mv -f $@.new $@
150 .PHONY: mostlyclean distclean realclean clean
151 mostlyclean:
152 -rm -f libc.dvi libc.info* dir-add.info stubs
153 -rm -f $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
154 clean: mostlyclean
155 distclean: clean
156 indices = cp fn pg tp vr ky
157 realclean: distclean
158 -rm -f chapters chapters-incl* summary.texi stamp-summary *.c.texi
159 -rm -f $(foreach index,$(indices),libc.$(index) libc.$(index)s)
160 -rm -f libc.log libc.aux libc.toc dir-add.texi
162 .PHONY: install subdir_install installdirs install-data
163 install-data subdir_install: install
164 ifneq ($(strip $(MAKEINFO)),)
165 install: $(inst_infodir)/libc.info dir-add.info
166 @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
167 test -f $(inst_infodir)/dir || cp dir $(inst_infodir);\
168 $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\
169 $(INSTALL_INFO) --info-dir=$(inst_infodir) dir-add.info;\
170 else : ; fi
171 endif
172 # Catchall implicit rule for other installation targets from the parent.
173 install-%: ;
175 $(inst_infodir)/libc.info: libc.info installdirs
176 for file in $<*; do \
177 name=`basename $$file`; \
178 $(INSTALL_DATA) $$file \
179 `echo $@ | sed "s,$<\$$,$$name,"`; \
180 done
182 installdirs:
183 $(mkinstalldirs) $(inst_infodir)
185 .PHONY: dist
186 dist: # glibc-doc-$(edition).tar.gz
188 ifneq (,$(wildcard ../Make-dist))
189 dist: ../Make-dist
190 $(MAKE) -f $< $(Make-dist-args)
191 endif
193 ifndef ETAGS
194 ETAGS = etags -T
195 endif
196 TAGS: $(minimal-dist)
197 $(ETAGS) -o $@ $^
199 # The parent makefile sometimes invokes us with targets `subdir_REAL-TARGET'.
200 subdir_%: % ;
201 # For targets we don't define, do nothing.
202 subdir_%: ;
204 # These are targets that each glibc subdirectory is expected to understand.
205 # ../Rules defines them for code subdirectories; for us, they are no-ops.
206 # None of these should be `subdir_TARGET'; those targets are transformed
207 # by the implicit rule above into `TARGET' deps.
208 glibc-targets := lib objects objs others tests lint.out \
209 echo-headers echo-distinfo
210 .PHONY: $(glibc-targets)
211 $(glibc-targets):
213 # Create stamp files if they don't exist, so the parent makefile's rules for
214 # updating the library archives are happy with us, and never think we have
215 # changed the library.
216 lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
217 ifdef objpfx
218 .PHONY: stubs
219 stubs: $(objpfx)stubs
220 endif
221 $(objpfx)stubs ../po/manual.pot $(objpfx)stamp%:
222 $(make-target-directory)
223 touch $@
225 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
226 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
227 define make-target-directory
228 $(addprefix $(mkinstalldirs) ,\
229 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
230 endef
232 # The top-level glibc Makefile expects subdir_install to update the stubs file.
233 subdir_install: stubs
235 # Get rid of these variables if they came from the parent.
236 routines =
237 aux =
238 sources =
239 objects =
240 headers =