Makefile 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. SHELL = /bin/bash
  2. MIRROR = "http://mi.mirror.garr.it/mirrors/debian/"
  3. DIST = "testing"
  4. ARCH = "amd64"
  5. # Download the list of files in Debian
  6. deb_indexes :
  7. mkdir -p "${DIST}/${ARCH}"
  8. wget --directory-prefix "${DIST}/${ARCH}" "${MIRROR}dists/${DIST}/main/Contents-amd64.gz"
  9. wget --directory-prefix "${DIST}/${ARCH}" "${MIRROR}dists/${DIST}/main/binary-amd64/Packages.gz"
  10. gunzip "${DIST}/${ARCH}/"*.gz
  11. # Find the list of (binary) packages that contain manpages
  12. find_packages :
  13. ./find_packages.py
  14. # Download all the binaries containing the manpages
  15. download_binaries :
  16. mkdir -p binaries
  17. wget --mirror --no-host --no-parent --no-directories \
  18. --directory-prefix binaries --execute robots=off \
  19. --input-file packages.url
  20. # Find all the manpages within the binaries and extract them
  21. extract_pages :
  22. for deb in binaries/*.deb ; do
  23. 7z x -so "$${deb}" \
  24. | tar --extract --strip-components 3 --file - ./usr/share/man/
  25. done
  26. # Decompress all pages into .roff files
  27. manpages2roff : $(subst :,\:,$(patsubst %.gz,%.roff,$(shell find ./man -type f -name "*.gz")))
  28. %.roff : %.gz
  29. @gunzip --stdout "$<" > "$@"
  30. # Convert pages to TEXT
  31. # Mandoc doesn't look for include manpages ".so" outside of the current working directory
  32. # or /usr/share/man for security reasons, so we need to cd into ./man in order to set
  33. # it as the working directory.
  34. manpages2txt : $(subst :,\:,$(patsubst %.roff,%.txt,$(shell find ./man -type f -name "*.roff")))
  35. %.txt : %.roff
  36. @ROFF="$<"
  37. @TEXT="$@"
  38. @ROFF="$${ROFF:4}" # Remove "man/" prefix
  39. @TEXT="$${TEXT:4}" # Remove "man/" prefix
  40. @cd ./man
  41. @mandoc -T utf8 -O width=80 "$$ROFF" | col -b > "$$TEXT"
  42. # Convert pages to HTML
  43. # Mandoc doesn't look for include manpages ".so" outside of the current working directory
  44. # or /usr/share/man for security reasons, so we need to cd into ./man in order to set
  45. # it as the working directory.
  46. manpages2html : $(subst :,\:,$(patsubst %.roff,%.html,$(shell find ./man -type f -name "*.roff")))
  47. %.html : %.roff
  48. @ROFF="$<"
  49. @HTML="$@"
  50. @ROFF="$${ROFF:4}" # Remove "man/" prefix
  51. @HTML="$${HTML:4}" # Remove "man/" prefix
  52. @cd ./man
  53. @mandoc -T html -O fragment "$$ROFF" > "$$HTML"
  54. @tidy --clean yes --vertical-space auto --wrap 0 --indent 0 --hide-comments yes \
  55. --drop-empty-elements no --doctype html5 --logical-emphasis yes \
  56. --show-body-only yes --quiet yes --write-back yes "$$HTML"
  57. # make page links to other manpages.
  58. # mandoc has the option "-O man="%N.%S"" to convert .Xr macros to links across manpages.
  59. # Unfortunately this seems to work only for .Xr and not for free text such as ls(1).
  60. # So, we try to create the links ourselves.
  61. manpages2html_postprocessing :
  62. ./html_postprocess.py
  63. # Convert pages to pdf
  64. manpages2pdf : $(subst :,\:,$(patsubst %.roff,%.pdf,$(shell find ./man -type f -name "*.roff")))
  65. %.pdf : %.roff
  66. # Make PDF
  67. # There is also roff2pdf but DVI seems to produce a nicer output
  68. @roff2dvi "$${filename}" > "$${manpage}.dvi"
  69. dvipdf "$${manpage}.dvi" "$${manpage}.pdf"
  70. # Convert pages to docbook
  71. manpages2docbook : $(subst :,\:,$(patsubst %.roff,%.docbook,$(shell find ./man -type f -name "*.roff")))
  72. %.docbook : %.roff
  73. @timeout 60s doclifter -I "$$PWD/man" < "$<" > "$@"
  74. # Build RDF graph
  75. manpages2rdf:
  76. ./rdf_dump.py
  77. .ONESHELL:
  78. .SUFFIXES:
  79. .PHONY:
  80. .DELETE_ON_ERROR: