lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | # Copyright (C) 1992-2015 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, see |
| 16 | # <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | # Makefile for the GNU C Library manual. |
| 19 | |
| 20 | subdir := manual |
| 21 | |
| 22 | include ../Makeconfig |
| 23 | |
| 24 | .PHONY: dvi pdf info html |
| 25 | |
| 26 | dvi: $(objpfx)libc.dvi |
| 27 | pdf: $(objpfx)libc.pdf |
| 28 | |
| 29 | TEXI2DVI = texi2dvi |
| 30 | TEXI2PDF = texi2dvi --pdf |
| 31 | |
| 32 | ifneq ($(strip $(MAKEINFO)),:) |
| 33 | info: $(objpfx)libc.info |
| 34 | endif |
| 35 | |
| 36 | chapters = $(addsuffix .texi, \ |
| 37 | intro errno memory ctype string charset locale \ |
| 38 | message search pattern io stdio llio filesys \ |
| 39 | pipe socket terminal syslog math arith time \ |
| 40 | resource setjmp signal startup process ipc job \ |
| 41 | nss users sysinfo conf crypt debug threads probes) |
| 42 | add-chapters = $(wildcard $(foreach d, $(add-ons), ../$d/$d.texi)) |
| 43 | appendices = lang.texi header.texi install.texi maint.texi platform.texi \ |
| 44 | contrib.texi |
| 45 | licenses = freemanuals.texi lgpl-2.1.texi fdl-1.3.texi |
| 46 | |
| 47 | -include $(objpfx)texis |
| 48 | $(objpfx)texis: texis.awk $(chapters) $(add-chapters) $(appendices) $(licenses) |
| 49 | $(make-target-directory) |
| 50 | $(AWK) -f $^ > $@.T |
| 51 | mv -f $@.T $@ |
| 52 | |
| 53 | nonexamples = $(filter-out $(add-chapters) %.c.texi, $(texis)) |
| 54 | examples = $(filter-out $(foreach d, $(add-ons), ../$d/%.c.texi), \ |
| 55 | $(filter %.c.texi, $(texis))) |
| 56 | |
| 57 | # Generated files directly included from libc.texinfo. |
| 58 | libc-texi-generated = chapters.texi top-menu.texi dir-add.texi \ |
| 59 | libm-err.texi version.texi pkgvers.texi |
| 60 | |
| 61 | # Add path to build dir for generated files |
| 62 | texis-path := $(filter-out $(libc-texi-generated) summary.texi $(examples), \ |
| 63 | $(texis)) \ |
| 64 | $(addprefix $(objpfx),$(filter $(libc-texi-generated) summary.texi \ |
| 65 | $(examples), $(texis))) |
| 66 | |
| 67 | # Kludge: implicit rule so Make knows the one command does it all. |
| 68 | chapters.% top-menu.%: libc-texinfo.sh $(texis-path) Makefile |
| 69 | AWK=$(AWK) $(SHELL) $< $(objpfx) \ |
| 70 | '$(chapters)' \ |
| 71 | '$(add-chapters)' \ |
| 72 | '$(appendices) $(licenses)' |
| 73 | |
| 74 | |
| 75 | $(objpfx)libc.dvi $(objpfx)libc.pdf $(objpfx)libc.info: \ |
| 76 | $(addprefix $(objpfx),$(libc-texi-generated)) |
| 77 | $(objpfx)libc.dvi $(objpfx)libc.pdf: texinfo.tex |
| 78 | |
| 79 | html: $(objpfx)libc/index.html |
| 80 | $(objpfx)libc/index.html: $(addprefix $(objpfx),$(libc-texi-generated)) |
| 81 | $(MAKEINFO) -P $(objpfx) -o $(objpfx)libc --html libc.texinfo |
| 82 | |
| 83 | # Generate the summary from the Texinfo source files for each chapter. |
| 84 | $(objpfx)summary.texi: $(objpfx)stamp-summary ; |
| 85 | $(objpfx)stamp-summary: summary.awk $(filter-out $(objpfx)summary.texi, \ |
| 86 | $(texis-path)) |
| 87 | $(SHELL) ./check-safety.sh $(filter-out $(objpfx)%, $(texis-path)) |
| 88 | $(AWK) -f $^ | sort -t'' -df -k 1,1 | tr '\014' '\012' \ |
| 89 | > $(objpfx)summary-tmp |
| 90 | $(move-if-change) $(objpfx)summary-tmp $(objpfx)summary.texi |
| 91 | touch $@ |
| 92 | |
| 93 | # Generate a file which can be added to the `dir' content to provide direct |
| 94 | # access to the documentation of the function, variables, and other |
| 95 | # definitions. |
| 96 | $(objpfx)dir-add.texi: xtract-typefun.awk $(texis-path) |
| 97 | (echo "@dircategory GNU C library functions and macros"; \ |
| 98 | echo "@direntry"; \ |
| 99 | $(AWK) -f $^ | sort; \ |
| 100 | echo "@end direntry") > $@.new |
| 101 | mv -f $@.new $@ |
| 102 | |
| 103 | # The table with the math errors is generated. |
| 104 | $(objpfx)libm-err.texi: $(objpfx)stamp-libm-err |
| 105 | $(objpfx)stamp-libm-err: libm-err-tab.pl $(wildcard $(foreach dir,$(sysdirs),\ |
| 106 | $(dir)/libm-test-ulps)) |
| 107 | pwd=`pwd`; \ |
| 108 | $(PERL) $< $$pwd/.. > $(objpfx)libm-err-tmp |
| 109 | $(move-if-change) $(objpfx)libm-err-tmp $(objpfx)libm-err.texi |
| 110 | touch $@ |
| 111 | |
| 112 | # Package version and bug reporting URL. |
| 113 | $(objpfx)pkgvers.texi: $(objpfx)stamp-pkgvers ; |
| 114 | $(objpfx)stamp-pkgvers: $(common-objpfx)config.make |
| 115 | echo "@ifclear PKGVERS" > $(objpfx)pkgvers-tmp |
| 116 | echo "@set PKGVERS" >> $(objpfx)pkgvers-tmp |
| 117 | echo "@set PKGVERSION $(PKGVERSION_TEXI)" >> $(objpfx)pkgvers-tmp |
| 118 | if [ "$(PKGVERSION_TEXI)" = "(GNU libc) " ]; then \ |
| 119 | echo "@set PKGVERSION_DEFAULT" >> $(objpfx)pkgvers-tmp; \ |
| 120 | fi |
| 121 | echo "@set REPORT_BUGS_TO $(REPORT_BUGS_TEXI)" >> $(objpfx)pkgvers-tmp |
| 122 | echo "@end ifclear" >> $(objpfx)pkgvers-tmp |
| 123 | $(move-if-change) $(objpfx)pkgvers-tmp $(objpfx)pkgvers.texi |
| 124 | touch $@ |
| 125 | |
| 126 | # Generate a file with the version number. |
| 127 | $(objpfx)version.texi: $(objpfx)stamp-version ; |
| 128 | $(objpfx)stamp-version: $(common-objpfx)config.make |
| 129 | echo "@set VERSION $(version)" > $(objpfx)version-tmp |
| 130 | $(move-if-change) $(objpfx)version-tmp $(objpfx)version.texi |
| 131 | touch $@ |
| 132 | |
| 133 | # Generate Texinfo files from the C source for the example programs. |
| 134 | $(objpfx)%.c.texi: examples/%.c |
| 135 | sed -e '1,/^\*\/$$/d' \ |
| 136 | -e 's,[{}],@&,g' \ |
| 137 | -e 's,/\*\(@.*\)\*/,\1,g' \ |
| 138 | -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \ |
| 139 | -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\ |
| 140 | $< | expand > $@.new |
| 141 | mv -f $@.new $@ |
| 142 | |
| 143 | $(objpfx)%.info: %.texinfo |
| 144 | LANGUAGE=C LC_ALL=C $(MAKEINFO) -P $(objpfx) --output=$@ $< |
| 145 | |
| 146 | $(objpfx)%.dvi: %.texinfo |
| 147 | cd $(objpfx);$(TEXI2DVI) -I $(shell cd $(<D) && pwd) --output=$@ \ |
| 148 | $(shell cd $(<D) && pwd)/$< |
| 149 | |
| 150 | $(objpfx)%.pdf: %.texinfo |
| 151 | cd $(objpfx);$(TEXI2PDF) -I $(shell cd $(<D) && pwd) --output=$@ \ |
| 152 | $(shell cd $(<D) && pwd)/$< |
| 153 | |
| 154 | |
| 155 | # Distribution. |
| 156 | minimal-dist = summary.awk texis.awk tsort.awk libc-texinfo.sh libc.texinfo \ |
| 157 | libm-err.texi stamp-libm-err check-safety.sh \ |
| 158 | $(filter-out summary.texi, $(nonexamples)) \ |
| 159 | $(patsubst %.c.texi,examples/%.c, $(examples)) |
| 160 | |
| 161 | indices = cp fn pg tp vr ky |
| 162 | generated-dirs += libc |
| 163 | generated += libc.dvi libc.pdf libc.tmp libc.info* \ |
| 164 | stubs \ |
| 165 | texis summary.texi stamp-summary *.c.texi \ |
| 166 | $(foreach index,$(indices),libc.$(index) libc.$(index)s) \ |
| 167 | libc.log libc.aux libc.toc \ |
| 168 | $(libc-texi-generated) \ |
| 169 | stamp-libm-err stamp-version |
| 170 | |
| 171 | include ../Rules |
| 172 | |
| 173 | .PHONY: install subdir_install install-data |
| 174 | install-data subdir_install: install |
| 175 | ifneq ($(strip $(MAKEINFO)),:) |
| 176 | install: $(inst_infodir)/libc.info |
| 177 | @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \ |
| 178 | test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\ |
| 179 | $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\ |
| 180 | else : ; fi |
| 181 | endif |
| 182 | # Catchall implicit rule for other installation targets from the parent. |
| 183 | install-%: ; |
| 184 | |
| 185 | $(inst_infodir)/libc.info: $(objpfx)libc.info |
| 186 | $(make-target-directory) |
| 187 | for file in $<*; do \ |
| 188 | $(INSTALL_DATA) $$file $(@D)/; \ |
| 189 | done |
| 190 | |
| 191 | TAGS: $(minimal-dist) |
| 192 | $(ETAGS) -o $@ $^ |