Update.
[glibc.git] / manual / Makefile
blob52c12aea6abcc0238e808610b80afd0b81b3f632
1 # Copyright (C) 1992-1999, 2000, 2001 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 Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of 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 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 # 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 pdf info html
28 all: dvi
29 dvi: libc.dvi
30 pdf: libc.pdf
32 # Get glibc's configuration info.
33 ifneq (,$(wildcard ../Makeconfig))
34 include ../Makeconfig
35 else
36 MAKEINFO = makeinfo
37 TEXI2DVI = texi2dvi
38 AWK = gawk
39 endif
41 TEXI2PDF = texi2dvi --pdf
43 ifneq ($(strip $(MAKEINFO)),:)
44 all: info
45 info: libc.info dir-add.info
46 endif
48 # scripts we use
49 ifndef move-if-change
50 move-if-change = ./move-if-change
51 endif
52 mkinstalldirs = $(..)scripts/mkinstalldirs
54 chapters = $(addsuffix .texi, \
55 intro errno memory ctype string charset locale \
56 message search pattern io stdio llio filesys \
57 pipe socket terminal syslog math arith time \
58 resource setjmp signal startup process job nss \
59 users sysinfo conf crypt debug)
60 add-chapters = $(wildcard $(foreach d, $(add-ons), ../$d/$d.texi))
61 appendices = lang.texi header.texi install.texi maint.texi contrib.texi
63 -include texis
64 texis: texis.awk $(chapters) $(add-chapters) $(appendices) lesser.texi fdl.texi
65 $(AWK) -f $^ > $@.T
66 mv -f $@.T $@
68 nonexamples = $(filter-out $(add-chapters) %.c.texi, $(texis))
69 examples = $(filter-out $(foreach d, $(add-ons), ../$d/%.c.texi), \
70 $(filter %.c.texi, $(texis)))
72 # Kludge: implicit rule so Make knows the one command does it all.
73 chapters.% top-menu.%: libc-texinfo.sh $(texis) Makefile
74 AWK=$(AWK) $(SHELL) $< '$(chapters)' '$(add-chapters)' '$(appendices)'
76 libc.dvi libc.pdf libc.info: chapters.texi top-menu.texi libm-err.texi
77 libc.dvi libc.pdf: texinfo.tex
79 html: libc/index.html
80 libc/index.html: chapters.texi top-menu.texi libm-err.texi
81 $(MAKEINFO) --html libc.texinfo
83 # Generate the summary from the Texinfo source files for each chapter.
84 summary.texi: stamp-summary ;
85 stamp-summary: summary.awk $(filter-out summary.texi, $(texis))
86 $(AWK) -f $^ | sort -t'\f' -df +0 -1 | tr '\014' '\012' > summary-tmp
87 $(move-if-change) summary-tmp summary.texi
88 touch $@
90 # Generate a file which can be added to the `dir' content to provide direct
91 # access to the documentation of the function, variables, and other
92 # definitions.
93 dir-add.info: xtract-typefun.awk $(texis)
94 (echo "INFO-DIR-SECTION GNU C library functions"; \
95 echo "START-INFO-DIR-ENTRY"; \
96 $(AWK) -f $^ | sort; \
97 echo "END-INFO-DIR-ENTRY") > $@.new
98 mv -f $@.new $@
100 # The table with the math errors is generated.
101 libm-err.texi: stamp-libm-err
102 stamp-libm-err: libm-err-tab.pl $(wildcard $(foreach dir,$(sysdirs),\
103 $(dir)/libm-test-ulps))
104 pwd=`pwd`; \
105 $(PERL) $< $$pwd/.. > libm-err-tmp
106 $(move-if-change) libm-err-tmp libm-err.texi
107 touch $@
109 # Generate Texinfo files from the C source for the example programs.
110 %.c.texi: examples/%.c
111 sed -e 's,[{}],@&,g' \
112 -e 's,/\*\(@.*\)\*/,\1,g' \
113 -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \
114 -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\
115 $< | expand > $@.new
116 mv -f $@.new $@
118 %.info: %.texinfo
119 LANGUAGE=C LC_ALL=C $(MAKEINFO) $<
121 %.dvi: %.texinfo
122 $(TEXI2DVI) $<
124 %.pdf: %.texinfo
125 $(TEXI2PDF) $<
127 # Distribution.
128 minimal-dist = summary.awk texis.awk tsort.awk libc-texinfo.sh libc.texinfo \
129 libm-err.texi stamp-libm-err \
130 $(filter-out summary.texi, $(nonexamples)) \
131 $(patsubst %.c.texi,examples/%.c, $(examples))
133 doc-only-dist = Makefile COPYING.LIB
134 distribute = $(minimal-dist) $(examples) stdio-fp.c \
135 libc.info* libc.?? libc.??s texinfo.tex \
136 xtract-typefun.awk dir-add.info dir libm-err-tab.pl
137 export distribute := $(distribute)
139 tar-it = tar chovf $@ $^
141 manual.tar: $(doc-only-dist) $(minimal-dist) ; $(tar-it)
142 mandist.tar: $(doc-only-dist) $(distribute) ; $(tar-it)
144 edition := $(shell sed -n 's/^@set EDITION \([0-9][0-9.]*\)[^0-9.]*.*$$/\1/p' \
145 libc.texinfo)
147 glibc-doc-$(edition).tar: $(doc-only-dist) $(distribute)
148 @rm -f glibc-doc-$(edition)
149 ln -s . glibc-doc-$(edition)
150 tar chovf $@ $(addprefix glibc-doc-$(edition)/,$^)
151 rm -f glibc-doc-$(edition)
153 %.Z: %
154 compress -c $< > $@.new
155 mv -f $@.new $@
156 %.gz: %
157 gzip -9 -c $< > $@.new
158 mv -f $@.new $@
159 %.uu: %
160 uuencode $< < $< > $@.new
161 mv -f $@.new $@
163 .PHONY: mostlyclean distclean realclean clean
164 mostlyclean:
165 -rm -f libc.dvi libc.pdf libc.tmp libc.info* dir-add.info
166 -rm -f $(objpfx)stubs $(objpfx)distinfo
167 -rm -f $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
168 clean: mostlyclean
169 distclean: clean
170 indices = cp fn pg tp vr ky
171 realclean: distclean
172 -rm -f texis summary.texi stamp-summary *.c.texi
173 -rm -f $(foreach index,$(indices),libc.$(index) libc.$(index)s)
174 -rm -f libc.log libc.aux libc.toc dir-add.texinfo
175 -rm -f top-menu.texi chapters.texi
177 .PHONY: install subdir_install installdirs install-data
178 install-data subdir_install: install
179 ifneq ($(strip $(MAKEINFO)),:)
180 # There are two variants of install-info out there. The GNU version
181 # knows about the INFO-DIR-SECTION tag, the Debian version doesn't.
182 ifneq ($(OLD_DEBIAN_INSTALL_INFO),yes)
183 install: $(inst_infodir)/libc.info dir-add.info
184 @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
185 test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\
186 $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\
187 $(INSTALL_INFO) --info-dir=$(inst_infodir) dir-add.info;\
188 else : ; fi
189 else
190 install: $(inst_infodir)/libc.info dir-add.info
191 @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
192 test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\
193 $(INSTALL_INFO) --info-dir=$(inst_infodir) \
194 --section '^GNU Libraries:' 'GNU Libraries:' \
195 $(inst_infodir)/libc.info;\
196 $(INSTALL_INFO) --info-dir=$(inst_infodir) \
197 --section '^GNU C Library functions:' 'GNU C Library functions:' \
198 dir-add.info;\
199 else : ; fi
200 endif
201 endif
202 # Catchall implicit rule for other installation targets from the parent.
203 install-%: ;
205 $(inst_infodir)/libc.info: libc.info installdirs
206 for file in $<*; do \
207 $(INSTALL_DATA) $$file $(@D)/$$file; \
208 done
210 installdirs:
211 $(mkinstalldirs) $(inst_infodir)
213 .PHONY: dist
214 dist: # glibc-doc-$(edition).tar.gz
216 ifneq (,$(wildcard ../Make-dist))
217 dist: ../Make-dist
218 $(MAKE) -f $< $(Make-dist-args)
219 endif
221 ifndef ETAGS
222 ETAGS = etags -T
223 endif
224 TAGS: $(minimal-dist)
225 $(ETAGS) -o $@ $^
227 # The parent makefile sometimes invokes us with targets `subdir_REAL-TARGET'.
228 subdir_%: % ;
229 # For targets we don't define, do nothing.
230 subdir_%: ;
232 # These are targets that each glibc subdirectory is expected to understand.
233 # ../Rules defines them for code subdirectories; for us, they are no-ops.
234 # None of these should be `subdir_TARGET'; those targets are transformed
235 # by the implicit rule above into `TARGET' deps.
236 glibc-targets := lib objects objs others tests lint.out \
237 echo-headers echo-distinfo
238 .PHONY: $(glibc-targets)
239 $(glibc-targets):
241 # Create stamp files if they don't exist, so the parent makefile's rules for
242 # updating the library archives are happy with us, and never think we have
243 # changed the library.
244 lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
245 ifdef objpfx
246 .PHONY: stubs
247 stubs: $(objpfx)stubs
248 endif
249 $(objpfx)stubs ../po/manual.pot $(objpfx)stamp%:
250 $(make-target-directory)
251 touch $@
253 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
254 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
255 define make-target-directory
256 $(addprefix $(mkinstalldirs) ,\
257 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
258 endef
260 # The top-level glibc Makefile expects subdir_install to update the stubs file.
261 subdir_install: stubs
263 # Get rid of these variables if they came from the parent.
264 routines =
265 aux =
266 sources =
267 objects =
268 headers =