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