Only load 4 bytes.
[glibc.git] / manual / Makefile
blob8bcc5d0ae2084d269503a3cbc56d2c939ac968e1
1 # Copyright (C) 1992-1999,2000,2001,2002,2003 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
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 \
62 freemanuals.texi
64 -include texis
65 texis: texis.awk $(chapters) $(add-chapters) $(appendices) lesser.texi fdl.texi
66 $(AWK) -f $^ > $@.T
67 mv -f $@.T $@
69 nonexamples = $(filter-out $(add-chapters) %.c.texi, $(texis))
70 examples = $(filter-out $(foreach d, $(add-ons), ../$d/%.c.texi), \
71 $(filter %.c.texi, $(texis)))
73 # Kludge: implicit rule so Make knows the one command does it all.
74 chapters.% top-menu.%: libc-texinfo.sh $(texis) Makefile
75 AWK=$(AWK) $(SHELL) $< '$(chapters)' '$(add-chapters)' '$(appendices)'
77 libc.dvi libc.pdf libc.info: chapters.texi top-menu.texi dir-add.texi \
78 libm-err.texi
79 libc.dvi libc.pdf: texinfo.tex
81 html: libc/index.html
82 libc/index.html: chapters.texi top-menu.texi libm-err.texi
83 $(MAKEINFO) --html libc.texinfo
85 # Generate the summary from the Texinfo source files for each chapter.
86 summary.texi: stamp-summary ;
87 stamp-summary: summary.awk $(filter-out summary.texi, $(texis))
88 $(AWK) -f $^ | sort -t'\f' -df +0 -1 | tr '\014' '\012' > summary-tmp
89 $(move-if-change) summary-tmp summary.texi
90 touch $@
92 # Generate a file which can be added to the `dir' content to provide direct
93 # access to the documentation of the function, variables, and other
94 # definitions.
95 dir-add.texi: xtract-typefun.awk $(texis)
96 (echo "@dircategory GNU C library functions and macros"; \
97 echo "@direntry"; \
98 $(AWK) -f $^ | sort; \
99 echo "@end direntry") > $@.new
100 mv -f $@.new $@
102 # The table with the math errors is generated.
103 libm-err.texi: stamp-libm-err
104 stamp-libm-err: libm-err-tab.pl $(wildcard $(foreach dir,$(sysdirs),\
105 $(dir)/libm-test-ulps))
106 pwd=`pwd`; \
107 $(PERL) $< $$pwd/.. > libm-err-tmp
108 $(move-if-change) libm-err-tmp libm-err.texi
109 touch $@
111 # Generate Texinfo files from the C source for the example programs.
112 %.c.texi: examples/%.c
113 sed -e 's,[{}],@&,g' \
114 -e 's,/\*\(@.*\)\*/,\1,g' \
115 -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \
116 -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\
117 $< | expand > $@.new
118 mv -f $@.new $@
120 %.info: %.texinfo
121 LANGUAGE=C LC_ALL=C $(MAKEINFO) $<
123 %.dvi: %.texinfo
124 $(TEXI2DVI) $<
126 %.pdf: %.texinfo
127 $(TEXI2PDF) $<
129 # Distribution.
130 minimal-dist = summary.awk texis.awk tsort.awk libc-texinfo.sh libc.texinfo \
131 libm-err.texi stamp-libm-err \
132 $(filter-out summary.texi, $(nonexamples)) \
133 $(patsubst %.c.texi,examples/%.c, $(examples))
135 doc-only-dist = Makefile COPYING.LIB
136 distribute = $(minimal-dist) $(examples) stdio-fp.c \
137 libc.info* libc.?? libc.??s texinfo.tex \
138 xtract-typefun.awk dir-add.texi dir libm-err-tab.pl
139 export distribute := $(distribute)
141 tar-it = tar chovf $@ $^
143 manual.tar: $(doc-only-dist) $(minimal-dist) ; $(tar-it)
144 mandist.tar: $(doc-only-dist) $(distribute) ; $(tar-it)
146 edition := $(shell sed -n 's/^@set EDITION \([0-9][0-9.]*\)[^0-9.]*.*$$/\1/p' \
147 libc.texinfo)
149 glibc-doc-$(edition).tar: $(doc-only-dist) $(distribute)
150 @rm -f glibc-doc-$(edition)
151 ln -s . glibc-doc-$(edition)
152 tar chovf $@ $(addprefix glibc-doc-$(edition)/,$^)
153 rm -f glibc-doc-$(edition)
155 %.Z: %
156 compress -c $< > $@.new
157 mv -f $@.new $@
158 %.gz: %
159 gzip -9 -c $< > $@.new
160 mv -f $@.new $@
161 %.uu: %
162 uuencode $< < $< > $@.new
163 mv -f $@.new $@
165 .PHONY: mostlyclean distclean realclean clean
166 mostlyclean:
167 -rm -f libc.dvi libc.pdf libc.tmp libc.info*
168 -rm -f $(objpfx)stubs $(objpfx)distinfo
169 -rm -f $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
170 clean: mostlyclean
171 distclean: clean
172 indices = cp fn pg tp vr ky
173 realclean: distclean
174 -rm -f texis summary.texi stamp-summary *.c.texi dir-add.texi
175 -rm -f $(foreach index,$(indices),libc.$(index) libc.$(index)s)
176 -rm -f libc.log libc.aux libc.toc dir-add.texinfo
177 -rm -f top-menu.texi chapters.texi
179 .PHONY: install subdir_install installdirs install-data
180 install-data subdir_install: install
181 ifneq ($(strip $(MAKEINFO)),:)
182 install: $(inst_infodir)/libc.info
183 @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
184 test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\
185 $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\
186 else : ; fi
187 endif
188 # Catchall implicit rule for other installation targets from the parent.
189 install-%: ;
191 $(inst_infodir)/libc.info: libc.info installdirs
192 for file in $<*; do \
193 $(INSTALL_DATA) $$file $(@D)/$$file; \
194 done
196 installdirs:
197 $(mkinstalldirs) $(inst_infodir)
199 .PHONY: dist
200 dist: # glibc-doc-$(edition).tar.gz
202 ifneq (,$(wildcard ../Make-dist))
203 dist: ../Make-dist
204 $(MAKE) -f $< $(Make-dist-args)
205 endif
207 ifndef ETAGS
208 ETAGS = etags -T
209 endif
210 TAGS: $(minimal-dist)
211 $(ETAGS) -o $@ $^
213 # The parent makefile sometimes invokes us with targets `subdir_REAL-TARGET'.
214 subdir_%: % ;
215 # For targets we don't define, do nothing.
216 subdir_%: ;
218 # These are targets that each glibc subdirectory is expected to understand.
219 # ../Rules defines them for code subdirectories; for us, they are no-ops.
220 # None of these should be `subdir_TARGET'; those targets are transformed
221 # by the implicit rule above into `TARGET' deps.
222 glibc-targets := lib objects objs others tests xtests lint.out \
223 echo-headers echo-distinfo
224 .PHONY: $(glibc-targets)
225 $(glibc-targets):
227 # Create stamp files if they don't exist, so the parent makefile's rules for
228 # updating the library archives are happy with us, and never think we have
229 # changed the library.
230 lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
231 ifdef objpfx
232 .PHONY: stubs
233 stubs: $(objpfx)stubs
234 endif
235 $(objpfx)stubs ../po/manual.pot $(objpfx)stamp%:
236 $(make-target-directory)
237 touch $@
239 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
240 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
241 define make-target-directory
242 $(addprefix $(mkinstalldirs) ,\
243 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
244 endef
246 # The top-level glibc Makefile expects subdir_install to update the stubs file.
247 subdir_install: stubs
249 # Get rid of these variables if they came from the parent.
250 routines =
251 aux =
252 sources =
253 objects =
254 headers =