asciidoc-helper.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 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
  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