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