Makefile 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. # Copyright (C) 1992-2026 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3. # The GNU C Library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Lesser General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2.1 of the License, or (at your option) any later version.
  7. # The GNU C Library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. # You should have received a copy of the GNU Lesser General Public
  12. # License along with the GNU C Library; if not, see
  13. # <https://www.gnu.org/licenses/>.
  14. # Makefile for the GNU C Library manual.
  15. subdir := manual
  16. include ../Makeconfig
  17. .PHONY: dvi pdf info html
  18. dvi: $(objpfx)libc.dvi
  19. pdf: $(objpfx)libc.pdf
  20. TEXI2DVI = texi2dvi
  21. TEXI2PDF = texi2dvi --pdf
  22. ifneq ($(strip $(MAKEINFO)),:)
  23. info: $(objpfx)libc.info
  24. endif
  25. chapters = $(addsuffix .texi, \
  26. intro errno memory ctype string charset locale \
  27. message search pattern io stdio llio filesys \
  28. pipe socket terminal syslog math arith stdbit time \
  29. resource setjmp signal startup process ipc job \
  30. nss users sysinfo conf crypt debug threads \
  31. dynlink probes tunables)
  32. appendices = lang.texi header.texi install.texi maint.texi platform.texi \
  33. contrib.texi
  34. licenses = freemanuals.texi lgpl-2.1.texi fdl-1.3.texi
  35. -include $(objpfx)texis
  36. $(objpfx)texis: texis.awk $(chapters) $(appendices) $(licenses)
  37. $(make-target-directory)
  38. $(AWK) -f $^ > $@.T
  39. mv -f $@.T $@
  40. nonexamples = $(filter-out %.c.texi, $(texis))
  41. examples = $(filter %.c.texi, $(texis))
  42. # Generated files directly included from libc.texinfo.
  43. libc-texi-generated = chapters.texi top-menu.texi dir-add.texi \
  44. version.texi pkgvers.texi
  45. # Add path to build dir for generated files
  46. texis-path := $(filter-out $(libc-texi-generated) summary.texi $(examples), \
  47. $(texis)) \
  48. $(addprefix $(objpfx),$(filter $(libc-texi-generated) summary.texi \
  49. $(examples), $(texis)))
  50. # Kludge: implicit rule so Make knows the one command does it all.
  51. chapters.% top-menu.%: libc-texinfo.sh $(texis-path) Makefile
  52. AWK=$(AWK) $(SHELL) $< $(objpfx) \
  53. '$(chapters)' \
  54. '$(appendices) $(licenses)'
  55. # Verify validity of texinfo sources against project rules.
  56. tests-special += \
  57. $(objpfx)check-deftype.out \
  58. $(objpfx)check-safety.out \
  59. # tests-special
  60. $(objpfx)libc.dvi $(objpfx)libc.pdf $(objpfx)libc.info: \
  61. $(addprefix $(objpfx),$(libc-texi-generated))
  62. $(objpfx)libc.dvi $(objpfx)libc.pdf: texinfo.tex
  63. html: $(objpfx)libc/index.html
  64. $(objpfx)libc/index.html: $(addprefix $(objpfx),$(libc-texi-generated))
  65. $(MAKEINFO) -P $(objpfx) -o $(objpfx)libc --html libc.texinfo
  66. # Generate the summary from the Texinfo source files for each chapter.
  67. $(objpfx)summary.texi: $(objpfx)stamp-summary ;
  68. $(objpfx)stamp-summary: summary.pl $(filter-out $(objpfx)summary.texi, \
  69. $(texis-path))
  70. $(SHELL) ./check-safety.sh $(filter-out $(objpfx)%, $(texis-path))
  71. $(SHELL) ./check-deftype.sh $(filter-out $(objpfx)%, $(texis-path))
  72. LC_ALL=C $(PERL) $^ > $(objpfx)summary-tmp
  73. $(move-if-change) $(objpfx)summary-tmp $(objpfx)summary.texi
  74. touch $@
  75. $(objpfx)check-safety.out: check-safety.sh
  76. $(SHELL) $< > $@ ; \
  77. $(evaluate-test)
  78. $(objpfx)check-deftype.out: check-deftype.sh
  79. $(SHELL) $< > $@ ; \
  80. $(evaluate-test)
  81. # Generate a file which can be added to the `dir' content to provide direct
  82. # access to the documentation of the function, variables, and other
  83. # definitions.
  84. $(objpfx)dir-add.texi: xtract-typefun.awk $(texis-path)
  85. (echo "@dircategory GNU C library functions and macros"; \
  86. echo "@direntry"; \
  87. $(AWK) -f $^ | sort; \
  88. echo "@end direntry") > $@.new
  89. mv -f $@.new $@
  90. # Package version and bug reporting URL.
  91. $(objpfx)pkgvers.texi: $(objpfx)stamp-pkgvers ;
  92. $(objpfx)stamp-pkgvers: $(common-objpfx)config.make
  93. echo "@ifclear PKGVERS" > $(objpfx)pkgvers-tmp
  94. echo "@set PKGVERS" >> $(objpfx)pkgvers-tmp
  95. echo "@set PKGVERSION $(PKGVERSION_TEXI)" >> $(objpfx)pkgvers-tmp
  96. if [ "$(PKGVERSION_TEXI)" = "(GNU libc) " ]; then \
  97. echo "@set PKGVERSION_DEFAULT" >> $(objpfx)pkgvers-tmp; \
  98. fi
  99. echo "@set REPORT_BUGS_TO $(REPORT_BUGS_TEXI)" >> $(objpfx)pkgvers-tmp
  100. echo "@set man_pages_version $(man-pages-version)" >> $(objpfx)pkgvers-tmp; \
  101. echo "@end ifclear" >> $(objpfx)pkgvers-tmp
  102. $(move-if-change) $(objpfx)pkgvers-tmp $(objpfx)pkgvers.texi
  103. touch $@
  104. # Generate a file with the version number.
  105. $(objpfx)version.texi: $(objpfx)stamp-version ;
  106. $(objpfx)stamp-version: $(common-objpfx)config.make
  107. echo "@set VERSION $(version)" > $(objpfx)version-tmp
  108. $(move-if-change) $(objpfx)version-tmp $(objpfx)version.texi
  109. touch $@
  110. # Generate Texinfo files from the C source for the example programs.
  111. $(objpfx)%.c.texi: examples/%.c
  112. sed -e '1,/^\*\/$$/d' \
  113. -e 's,[{}],@&,g' \
  114. -e 's,/\*\(@.*\)\*/,\1,g' \
  115. -e 's,/\* *,/* @r{,g' -e 's, *\*/,} */,' \
  116. -e 's/\(@[a-z][a-z]*\)@{\([^}]*\)@}/\1{\2}/g'\
  117. $< | expand > $@.new
  118. mv -f $@.new $@
  119. $(objpfx)%.info: %.texinfo
  120. LANGUAGE=C LC_ALL=C $(MAKEINFO) -P $(objpfx) --output=$@ $<
  121. $(objpfx)%.dvi: %.texinfo
  122. cd $(objpfx);$(TEXI2DVI) -I $(shell cd $(<D) && pwd) --output=$@ \
  123. $(shell cd $(<D) && pwd)/$<
  124. $(objpfx)%.pdf: %.texinfo
  125. cd $(objpfx);$(TEXI2PDF) -I $(shell cd $(<D) && pwd) --output=$@ \
  126. $(shell cd $(<D) && pwd)/$<
  127. # Distribution.
  128. minimal-dist = \
  129. $(filter-out summary.texi, $(nonexamples)) \
  130. $(patsubst %.c.texi,examples/%.c, $(examples)) \
  131. check-deftype.sh \
  132. check-safety.sh \
  133. libc-texinfo.sh \
  134. libc.texinfo \
  135. libm-err.texi \
  136. stamp-libm-err \
  137. summary.pl \
  138. texis.awk \
  139. tsort.awk \
  140. # minimal-dist
  141. indices = cp fn pg tp vr ky
  142. generated-dirs += libc
  143. generated += libc.dvi libc.pdf libc.tmp libc.info* \
  144. stubs \
  145. texis summary.texi stamp-summary *.c.texi \
  146. $(foreach index,$(indices),libc.$(index) libc.$(index)s) \
  147. libc.log libc.aux libc.toc \
  148. $(libc-texi-generated) \
  149. stamp-libm-err stamp-version
  150. include ../Rules
  151. .PHONY: install subdir_install install-data
  152. install-data subdir_install: install
  153. # Generated files requiring python: libm-err.texi
  154. # Generated files requiring perl: summary.texi
  155. ifneq ($(PERL),no)
  156. ifneq ($(strip $(MAKEINFO)),:)
  157. install: $(inst_infodir)/libc.info
  158. @if $(SHELL) -c '$(INSTALL_INFO) --version' >/dev/null 2>&1; then \
  159. test -f $(inst_infodir)/dir || $(INSTALL_DATA) dir $(inst_infodir);\
  160. $(INSTALL_INFO) --info-dir=$(inst_infodir) $(inst_infodir)/libc.info;\
  161. else : ; fi
  162. endif
  163. endif
  164. # Catchall implicit rule for other installation targets from the parent.
  165. install-%: ;
  166. $(inst_infodir)/libc.info: $(objpfx)libc.info
  167. $(make-target-directory)
  168. for file in $<*; do \
  169. $(INSTALL_DATA) $$file $(@D)/; \
  170. done
  171. TAGS: $(minimal-dist)
  172. $(ETAGS) -o $@ $^