asciidoc-helper.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. # Copyright (c) The Tor Project, Inc.
  3. # See LICENSE for licensing information
  4. # Run this to generate .html.in or .1.in files from asciidoc files.
  5. # Arguments:
  6. # html|man asciidocpath outputfile
  7. set -e
  8. if [ $# != 3 ]; then
  9. exit 1
  10. fi
  11. SOURCE_DATE_EPOCH="$(git -C "$(dirname "$0")" show --no-patch --format='%ct')"
  12. export SOURCE_DATE_EPOCH
  13. output=$3
  14. if [ "$1" = "html" ]; then
  15. input=${output%%.html.in}.1.txt
  16. base=${output%%.html.in}
  17. if [ "$2" != none ]; then
  18. TZ=UTC "$2" -f "$(dirname "$0")/nofooter.conf" -d manpage -o "$output" "$input";
  19. else
  20. echo "=================================="
  21. echo
  22. echo "You need asciidoc installed to be able to build the manpage."
  23. echo "To build without manpages, use the --disable-asciidoc argument"
  24. echo "when calling configure."
  25. echo
  26. echo "=================================="
  27. exit 1
  28. fi
  29. elif [ "$1" = "man" ]; then
  30. input=${output%%.1.in}.1.txt
  31. base=${output%%.1.in}
  32. if test "$2" = none; then
  33. echo "=================================="
  34. echo
  35. echo "You need asciidoc installed to be able to build the manpage."
  36. echo "To build without manpages, use the --disable-asciidoc argument"
  37. echo "when calling configure."
  38. echo
  39. echo "=================================="
  40. exit 1
  41. fi
  42. if "$2" -f manpage "$input"; then
  43. mv "$base.1" "$output"
  44. else
  45. cat<<EOF
  46. ==================================
  47. You need a working asciidoc installed to be able to build the manpage.
  48. a2x is installed, but for some reason it isn't working. Sometimes
  49. this happens because required docbook support files are missing.
  50. Please install docbook-xsl, docbook-xml, and xmlto (Debian) or
  51. similar. If you use homebrew on Mac OS X, install the docbook formula
  52. and add "export XML_CATALOG_FILES=/usr/local/etc/xml/catalog" to your
  53. .bashrc file.
  54. Alternatively, to build without manpages, use the --disable-asciidoc
  55. argument when calling configure.
  56. ==================================
  57. EOF
  58. exit 1
  59. fi
  60. fi