d815186ed90bd6859b7cb95584ca5ac016cb89ce
[platform/upstream/glibc.git] / manual / Makefile
1 # Copyright (C) 1992-1999, 2000, 2001 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
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.
8
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.
13
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.
18
19 # Makefile for the GNU C Library manual.
20
21 subdir := manual
22 export subdir := $(subdir)
23
24 # Allow override
25 INSTALL_INFO = install-info
26
27 .PHONY: all dvi pdf info
28 all: dvi
29 dvi: libc.dvi
30 pdf: libc.pdf
31
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
40
41 TEXI2PDF = texi2dvi --pdf
42
43 ifneq ($(strip $(MAKEINFO)),:)
44 all: info
45 info: libc.info dir-add.info
46 endif
47
48 # scripts we use
49 ifndef move-if-change
50 move-if-change = ./move-if-change
51 endif
52 mkinstalldirs = $(..)scripts/mkinstalldirs
53
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
63 -include texis
64 texis: texis.awk $(chapters) $(add-chapters) $(appendices) lgpl.texinfo
65         $(AWK) -f $^ > $@.T
66         mv -f $@.T $@
67
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)))
71
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)'
75
76 libc.dvi libc.pdf libc.info: chapters.texi top-menu.texi libm-err.texi
77 libc.dvi libc.pdf: texinfo.tex
78
79 # Generate the summary from the Texinfo source files for each chapter.
80 summary.texi: stamp-summary ;
81 stamp-summary: summary.awk $(filter-out summary.texi, $(texis))
82         $(AWK) -f $^ | sort -t'\f' -df +0 -1 | tr '\014' '\012' > summary-tmp
83         $(move-if-change) summary-tmp summary.texi
84         touch $@
85
86 # Generate a file which can be added to the `dir' content to provide direct
87 # access to the documentation of the function, variables, and other
88 # definitions.
89 dir-add.info: xtract-typefun.awk $(texis)
90         (echo "INFO-DIR-SECTION GNU C library functions";               \
91          echo "START-INFO-DIR-ENTRY";                                   \
92          $(AWK) -f $^ | sort;                                           \
93          echo "END-INFO-DIR-ENTRY") > $@.new
94         mv -f $@.new $@
95
96 # The table with the math errors is generated.
97 libm-err.texi: stamp-libm-err
98 stamp-libm-err: libm-err-tab.pl $(wildcard $(foreach dir,$(sysdirs),\
99                                                      $(dir)/libm-test-ulps))
100         pwd=`pwd`; \
101         $(PERL) $< $$pwd/.. > libm-err-tmp
102         $(move-if-change) libm-err-tmp libm-err.texi
103         touch $@
104
105 # Generate Texinfo files from the C source for the example programs.
106 %.c.texi: examples/%.c
107         sed -e 's,[{}],@&,g'                            \
108             -e 's,/\*\(@.*\)\*/,\1,g'                   \
109             -e 's,/\*  *,/* @r{,g' -e 's,  *\*/,} */,'  \
110             -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\
111             $< | expand > $@.new
112         mv -f $@.new $@
113
114 %.info: %.texinfo
115         LANGUAGE=C LC_ALL=C $(MAKEINFO) $<
116
117 %.dvi: %.texinfo
118         $(TEXI2DVI) $<
119
120 %.pdf: %.texinfo
121         $(TEXI2PDF) $<
122
123 # Distribution.
124 minimal-dist = summary.awk texis.awk tsort.awk libc-texinfo.sh libc.texinfo \
125                libm-err.texi stamp-libm-err                                 \
126                $(filter-out summary.texi, $(nonexamples))                   \
127                $(patsubst %.c.texi,examples/%.c, $(examples))
128
129 doc-only-dist = Makefile COPYING.LIB
130 distribute = $(minimal-dist) $(examples) stdio-fp.c     \
131              libc.info* libc.?? libc.??s texinfo.tex    \
132              xtract-typefun.awk dir-add.info dir libm-err-tab.pl
133 export distribute := $(distribute)
134
135 tar-it = tar chovf $@ $^
136
137 manual.tar: $(doc-only-dist) $(minimal-dist) ; $(tar-it)
138 mandist.tar: $(doc-only-dist) $(distribute) ; $(tar-it)
139
140 edition := $(shell sed -n 's/^@set EDITION \([0-9][0-9.]*\)[^0-9.]*.*$$/\1/p' \
141                        libc.texinfo)
142
143 glibc-doc-$(edition).tar: $(doc-only-dist) $(distribute)
144         @rm -f glibc-doc-$(edition)
145         ln -s . glibc-doc-$(edition)
146         tar chovf $@ $(addprefix glibc-doc-$(edition)/,$^)
147         rm -f glibc-doc-$(edition)
148
149 %.Z: %
150         compress -c $< > $@.new
151         mv -f $@.new $@
152 %.gz: %
153         gzip -9 -c $< > $@.new
154         mv -f $@.new $@
155 %.uu: %
156         uuencode $< < $< > $@.new
157         mv -f $@.new $@
158
159 .PHONY: mostlyclean distclean realclean clean
160 mostlyclean:
161         -rm -f libc.dvi libc.pdf libc.tmp libc.info* dir-add.info
162         -rm -f $(objpfx)stubs $(objpfx)distinfo
163         -rm -f $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
164 clean: mostlyclean
165 distclean: clean
166 indices = cp fn pg tp vr ky
167 realclean: distclean
168         -rm -f texis summary.texi stamp-summary *.c.texi
169         -rm -f $(foreach index,$(indices),libc.$(index) libc.$(index)s)
170         -rm -f libc.log libc.aux libc.toc dir-add.texinfo
171         -rm -f top-menu.texi chapters.texi
172
173 .PHONY: install subdir_install installdirs install-data
174 install-data subdir_install: install
175 ifneq ($(strip $(MAKEINFO)),:)
176 # There are two variants of install-info out there.  The GNU version
177 # knows about the INFO-DIR-SECTION tag, the Debian version doesn't.
178 ifneq ($(OLD_DEBIAN_INSTALL_INFO),yes)
179 install: $(inst_infodir)/libc.info dir-add.info
180         @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
181          test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\
182          $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\
183          $(INSTALL_INFO) --info-dir=$(inst_infodir) dir-add.info;\
184         else : ; fi
185 else
186 install: $(inst_infodir)/libc.info dir-add.info
187         @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
188           test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\
189          $(INSTALL_INFO) --info-dir=$(inst_infodir) \
190              --section '^GNU Libraries:' 'GNU Libraries:' \
191              $(inst_infodir)/libc.info;\
192          $(INSTALL_INFO) --info-dir=$(inst_infodir) \
193              --section '^GNU C Library functions:' 'GNU C Library functions:' \
194              dir-add.info;\
195         else : ; fi
196 endif
197 endif
198 # Catchall implicit rule for other installation targets from the parent.
199 install-%: ;
200
201 $(inst_infodir)/libc.info: libc.info installdirs
202         for file in $<*; do \
203           $(INSTALL_DATA) $$file $(@D)/$$file; \
204         done
205
206 installdirs:
207         $(mkinstalldirs) $(inst_infodir)
208
209 .PHONY: dist
210 dist: # glibc-doc-$(edition).tar.gz
211
212 ifneq (,$(wildcard ../Make-dist))
213 dist: ../Make-dist
214         $(MAKE) -f $< $(Make-dist-args)
215 endif
216
217 ifndef ETAGS
218 ETAGS = etags -T
219 endif
220 TAGS: $(minimal-dist)
221         $(ETAGS) -o $@ $^
222 \f
223 # The parent makefile sometimes invokes us with targets `subdir_REAL-TARGET'.
224 subdir_%: % ;
225 # For targets we don't define, do nothing.
226 subdir_%: ;
227
228 # These are targets that each glibc subdirectory is expected to understand.
229 # ../Rules defines them for code subdirectories; for us, they are no-ops.
230 # None of these should be `subdir_TARGET'; those targets are transformed
231 # by the implicit rule above into `TARGET' deps.
232 glibc-targets   := lib objects objs others tests lint.out \
233                    echo-headers echo-distinfo
234 .PHONY: $(glibc-targets)
235 $(glibc-targets):
236
237 # Create stamp files if they don't exist, so the parent makefile's rules for
238 # updating the library archives are happy with us, and never think we have
239 # changed the library.
240 lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
241 ifdef objpfx
242 .PHONY: stubs
243 stubs: $(objpfx)stubs
244 endif
245 $(objpfx)stubs ../po/manual.pot $(objpfx)stamp%:
246         $(make-target-directory)
247         touch $@
248
249 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
250 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
251 define make-target-directory
252 $(addprefix $(mkinstalldirs) ,\
253             $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
254 endef
255
256 # The top-level glibc Makefile expects subdir_install to update the stubs file.
257 subdir_install: stubs
258 \f
259 # Get rid of these variables if they came from the parent.
260 routines =
261 aux =
262 sources =
263 objects =
264 headers =