Update.
[glibc.git] / manual / Makefile
bloba952299ee7312a7e448582f690efb7873c60da86
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 # We need GNU awk for the xtract-typefun script.
25 GAWK = gawk
26 # Allow override
27 INSTALL_INFO = install-info
29 .PHONY: all dvi info
30 all: dvi
31 dvi: libc.dvi
33 ifneq ($(strip $(MAKEINFO)),)
34 all: info
35 info: libc.info dir-add.info
36 endif
38 # Get glibc's configuration info.
39 ifneq (,$(wildcard ../Makeconfig))
40 include ../Makeconfig
41 endif
43 # Set chapters and chapters-incl[12].
44 -include chapters
45 chapters: libc.texinfo
46 $(find-includes)
47 ifdef chapters
48 # @includes in chapter files
49 -include chapters-incl1
50 chapters-incl1: $(chapters)
51 $(find-includes)
52 chapters-incl1 := $(filter-out summary.texi,$(chapters-incl1))
53 endif
54 ifdef chapters-incl1
55 # @includes in files included by chapter files, if any
56 -include chapters-incl2
57 chapters-incl2: $(chapters-incl1)
58 $(find-includes)
59 endif
61 chapters-incl := $(chapters-incl1) $(chapters-incl2)
63 define find-includes
64 (echo '$(@F) :=' \\ ;\
65 awk '$$1 == "@include" { print $$2 " \\" }' $^) > $@.new
66 mv -f $@.new $@
67 endef
69 libc.dvi libc.info: $(chapters) summary.texi $(chapters-incl)
70 libc.dvi: texinfo.tex
72 %.info: %.texinfo
73 $(MAKEINFO) $<
75 %.dvi: %.texinfo
76 $(TEXI2DVI) $<
78 # Generate the summary from the Texinfo source files for each chapter.
79 summary.texi: stamp-summary ;
80 stamp-summary: summary.awk $(chapters) $(chapters-incl)
81 awk -f $^ \
82 | sort -df +1 -2 | tr '\014' '\012' > summary-tmp
83 ./move-if-change summary-tmp summary.texi
84 # touch is broken on our machines. Sigh.
85 date > $@
87 # Generate a file which can be added to the `dir' content to provide direct
88 # access to the documentation of the function, variables, and other
89 # definitions.
90 dir-add.texinfo: xtract-typefun.awk $(chapters) $(chapters-incl)
91 (echo "@dircategory GNU C library functions"; \
92 echo "@direntry"; \
93 $(GAWK) -f $^ | sort; \
94 echo "@end direntry";) > $@.new
95 mv -f $@.new $@
97 # Generate Texinfo files from the C source for the example programs.
98 %.c.texi: examples/%.c
99 sed -e 's,[{}],@&,g' \
100 -e 's,/\*\(@.*\)\*/,\1,g' \
101 -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \
102 -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\
103 $< | expand > $@.new
104 mv -f $@.new $@
107 minimal-dist = summary.awk move-if-change libc.texinfo $(chapters) \
108 $(patsubst %.c.texi,examples/%.c, \
109 $(filter-out summary.texi,$(chapters-incl)))
110 doc-only-dist = Makefile COPYING.LIB mkinstalldirs
111 distribute = $(minimal-dist) \
112 $(patsubst examples/%.c,%.c.texi,$(filter examples/%.c, \
113 $(minimal-dist))) \
114 libc.info* libc.?? libc.??s texinfo.tex summary.texi \
115 stamp-summary chapters chapters-incl1 chapters-incl2 \
116 xtract-typefun.awk dir-add.texinfo dir-add.info dir \
117 stdio-fp.c
118 export distribute := $(distribute)
120 tar-it = tar chovf $@ $^
122 manual.tar: $(doc-only-dist) $(minimal-dist) ; $(tar-it)
123 mandist.tar: $(doc-only-dist) $(distribute) ; $(tar-it)
125 edition := $(shell sed -n 's/^@set EDITION \([0-9][0-9.]*\)[^0-9.]*.*$$/\1/p' \
126 libc.texinfo)
128 glibc-doc-$(edition).tar: $(doc-only-dist) $(distribute)
129 @rm -f glibc-doc-$(edition)
130 ln -s . glibc-doc-$(edition)
131 tar chovf $@ $(addprefix glibc-doc-$(edition)/,$^)
132 rm -f glibc-doc-$(edition)
134 %.Z: %
135 compress -c $< > $@.new
136 mv -f $@.new $@
137 %.gz: %
138 gzip -9 -c $< > $@.new
139 mv -f $@.new $@
140 %.uu: %
141 uuencode $< < $< > $@.new
142 mv -f $@.new $@
144 .PHONY: mostlyclean distclean realclean clean
145 mostlyclean:
146 -rm -f libc.dvi libc.info* dir-add.info $(common-objpfx)stub-manual
147 -rm -f $(foreach o,$(object-suffixes),$(objpfx)stamp$o)
148 clean: mostlyclean
149 distclean: clean
150 indices = cp fn pg tp vr ky
151 realclean: distclean
152 -rm -f chapters chapters-incl* summary.texi stamp-summary *.c.texi
153 -rm -f $(foreach index,$(indices),libc.$(index) libc.$(index)s)
154 -rm -f libc.log libc.aux libc.toc dir-add.texi
156 .PHONY: install subdir_install installdirs install-data
157 install-data subdir_install: install
158 ifneq ($(strip $(MAKEINFO)),)
159 install: $(inst_infodir)/libc.info dir-add.info
160 @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
161 test -f $(inst_infodir)/dir || cp dir $(inst_infodir);\
162 $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\
163 $(INSTALL_INFO) --info-dir=$(inst_infodir) dir-add.info;\
164 else : ; fi
165 endif
166 # Catchall implicit rule for other installation targets from the parent.
167 install-%: ;
169 $(inst_infodir)/libc.info: libc.info installdirs
170 for file in $<*; do \
171 name=`basename $$file`; \
172 $(INSTALL_DATA) $$file \
173 `echo $@ | sed "s,$<\$$,$$name,"`; \
174 done
176 installdirs: $(firstword $(wildcard mkinstalldirs ../mkinstalldirs))
177 $(dir $<)$(notdir $<) $(inst_infodir)
179 .PHONY: dist
180 dist: # glibc-doc-$(edition).tar.gz
182 ifneq (,$(wildcard ../Make-dist))
183 dist: ../Make-dist
184 $(MAKE) -f $< $(Make-dist-args)
185 endif
187 ifndef ETAGS
188 ETAGS = etags -T
189 endif
190 TAGS: $(minimal-dist)
191 $(ETAGS) -o $@ $^
193 # The parent makefile sometimes invokes us with targets `subdir_REAL-TARGET'.
194 subdir_%: % ;
195 # For targets we don't define, do nothing.
196 subdir_%: ;
198 # These are targets that each glibc subdirectory is expected to understand.
199 # ../Rules defines them for code subdirectories; for us, they are no-ops.
200 # None of these should be `subdir_TARGET'; those targets are transformed
201 # by the implicit rule above into `TARGET' deps.
202 glibc-targets := lib objects objs others tests lint.out \
203 echo-headers echo-distinfo stubs
204 .PHONY: $(glibc-targets)
205 $(glibc-targets):
207 # Create stamp files if they don't exist, so the parent makefile's rules for
208 # updating the library archives are happy with us, and never think we have
209 # changed the library.
210 lib: $(foreach o,$(object-suffixes),$(objpfx)stamp$o)
211 stubs: $(common-objpfx)stub-manual
212 $(common-objpfx)stub-manual ../po/manual.pot $(objpfx)stamp%:
213 $(make-target-directory)
214 cp /dev/null $@
217 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
218 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
219 define make-target-directory
220 $(addprefix $(..)./mkinstalldirs ,\
221 $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
222 endef
224 # The top-level glibc Makefile expects subdir_install to update the stubs file.
225 subdir_install: stubs
227 # Get rid of these variables if they came from the parent.
228 routines =
229 aux =
230 sources =
231 objects =
232 headers =