| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # User configuration |
|---|
| 4 | DOCBOOK_XSL_VERSION=1.67.2 |
|---|
| 5 | DOCBOOK_DTD_VERSION=4.2 |
|---|
| 6 | FOP_VERSION=0.20.5 |
|---|
| 7 | FOP_MIRROR=http://mirrors.ibiblio.org/pub/mirrors/apache/xml/fop/ |
|---|
| 8 | SOURCEFORGE_MIRROR=http://dl.sourceforge.net |
|---|
| 9 | HTTP_GET_CMD="curl -O" |
|---|
| 10 | |
|---|
| 11 | # No user configuration below this point------------------------------------- |
|---|
| 12 | |
|---|
| 13 | # Get the DocBook XSLT Stylesheets |
|---|
| 14 | DOCBOOK_XSL_TARBALL=docbook-xsl-$DOCBOOK_XSL_VERSION.tar.gz |
|---|
| 15 | DOCBOOK_XSL_URL=$SOURCEFORGE_MIRROR/sourceforge/docbook/$DOCBOOK_XSL_TARBALL |
|---|
| 16 | if test -f $DOCBOOK_XSL_TARBALL; then |
|---|
| 17 | echo "Using existing DocBook XSLT Stylesheets (version $DOCBOOK_XSL_VERSION)." |
|---|
| 18 | else |
|---|
| 19 | echo "Downloading DocBook XSLT Stylesheets version $DOCBOOK_XSL_VERSION..." |
|---|
| 20 | $HTTP_GET_CMD $DOCBOOK_XSL_URL |
|---|
| 21 | fi |
|---|
| 22 | |
|---|
| 23 | DOCBOOK_XSL_DIR="$PWD/docbook-xsl-$DOCBOOK_XSL_VERSION" |
|---|
| 24 | if test ! -d docbook-xsl-$DOCBOOK_XSL_VERSION; then |
|---|
| 25 | echo -n "Expanding DocBook XSLT Stylesheets into $DOCBOOK_XSL_DIR..." |
|---|
| 26 | gunzip -cd $DOCBOOK_XSL_TARBALL | tar xf - |
|---|
| 27 | echo "done." |
|---|
| 28 | fi |
|---|
| 29 | |
|---|
| 30 | # Get the DocBook DTD |
|---|
| 31 | DOCBOOK_DTD_ZIP=docbook-xml-$DOCBOOK_DTD_VERSION.zip |
|---|
| 32 | DOCBOOK_DTD_URL=http://www.oasis-open.org/docbook/xml/$DOCBOOK_DTD_VERSION/$DOCBOOK_DTD_ZIP |
|---|
| 33 | if test -f $DOCBOOK_DTD_ZIP; then |
|---|
| 34 | echo "Using existing DocBook XML DTD (version $DOCBOOK_DTD_VERSION)." |
|---|
| 35 | else |
|---|
| 36 | echo "Downloading DocBook XML DTD version $DOCBOOK_DTD_VERSION..." |
|---|
| 37 | $HTTP_GET_CMD $DOCBOOK_DTD_URL |
|---|
| 38 | fi |
|---|
| 39 | |
|---|
| 40 | DOCBOOK_DTD_DIR="$PWD/docbook-dtd-$DOCBOOK_DTD_VERSION" |
|---|
| 41 | if test ! -d docbook-dtd-$DOCBOOK_DTD_VERSION; then |
|---|
| 42 | echo -n "Expanding DocBook XML DTD into $DOCBOOK_DTD_DIR... " |
|---|
| 43 | unzip -q $DOCBOOK_DTD_ZIP -d $DOCBOOK_DTD_DIR |
|---|
| 44 | echo "done." |
|---|
| 45 | fi |
|---|
| 46 | |
|---|
| 47 | # Find xsltproc, doxygen, and java |
|---|
| 48 | OLD_IFS=$IFS |
|---|
| 49 | IFS=: |
|---|
| 50 | for dir in $PATH; do |
|---|
| 51 | if test -f $dir/xsltproc && test -x $dir/xsltproc; then |
|---|
| 52 | XSLTPROC="$dir/xsltproc" |
|---|
| 53 | fi |
|---|
| 54 | if test -f $dir/doxygen && test -x $dir/doxygen; then |
|---|
| 55 | DOXYGEN="$dir/doxygen" |
|---|
| 56 | fi |
|---|
| 57 | if test -f $dir/java && test -x $dir/java; then |
|---|
| 58 | JAVA="$dir/java" |
|---|
| 59 | fi |
|---|
| 60 | done |
|---|
| 61 | IFS=$OLD_IFS |
|---|
| 62 | |
|---|
| 63 | # Make sure we have xsltproc |
|---|
| 64 | if test ! -f "$XSLTPROC" && test ! -x "$XSLTPROC"; then |
|---|
| 65 | echo "Searching for xsltproc... NOT FOUND."; |
|---|
| 66 | echo "ERROR: Unable to find xsltproc executable." |
|---|
| 67 | echo "If you have already installed xsltproc, please set the environment" |
|---|
| 68 | echo "variable XSLTPROC to the xsltproc executable. If you do not have" |
|---|
| 69 | echo "xsltproc, you may download it from http://xmlsoft.org/XSLT/." |
|---|
| 70 | exit 0; |
|---|
| 71 | else |
|---|
| 72 | echo "Searching for xsltproc... $XSLTPROC."; |
|---|
| 73 | fi |
|---|
| 74 | |
|---|
| 75 | # Just notify the user if we haven't found doxygen. |
|---|
| 76 | if test ! -f "$DOXYGEN" && test ! -x "$DOXYGEN"; then |
|---|
| 77 | echo "Searching for Doxygen... not found."; |
|---|
| 78 | echo "Warning: unable to find Doxygen executable. You will not be able to" |
|---|
| 79 | echo " use Doxygen to generate BoostBook documentation. If you have Doxygen," |
|---|
| 80 | echo " please set the DOXYGEN environment variable to the path of the doxygen" |
|---|
| 81 | echo " executable." |
|---|
| 82 | HAVE_DOXYGEN="no" |
|---|
| 83 | else |
|---|
| 84 | echo "Searching for Doxygen... $DOXYGEN."; |
|---|
| 85 | HAVE_DOXYGEN="yes" |
|---|
| 86 | fi |
|---|
| 87 | |
|---|
| 88 | # Just notify the user if we haven't found Java. Otherwise, go get FOP. |
|---|
| 89 | if test ! -f "$JAVA" && test ! -x "$JAVA"; then |
|---|
| 90 | echo "Searching for Java... not found."; |
|---|
| 91 | echo "Warning: unable to find Java executable. You will not be able to" |
|---|
| 92 | echo " generate PDF documentation. If you have Java, please set the JAVA" |
|---|
| 93 | echo " environment variable to the path of the java executable." |
|---|
| 94 | HAVE_FOP="no" |
|---|
| 95 | else |
|---|
| 96 | echo "Searching for Java... $JAVA."; |
|---|
| 97 | FOP_TARBALL="fop-$FOP_VERSION-bin.tar.gz" |
|---|
| 98 | FOP_URL="$FOP_MIRROR/$FOP_TARBALL" |
|---|
| 99 | FOP_DIR="$PWD/fop-$FOP_VERSION" |
|---|
| 100 | FOP="$FOP_DIR/fop.sh" |
|---|
| 101 | if test -f $FOP_TARBALL; then |
|---|
| 102 | echo "Using existing FOP distribution (version $FOP_VERSION)." |
|---|
| 103 | else |
|---|
| 104 | echo "Downloading FOP distribution version $FOP_VERSION..." |
|---|
| 105 | $HTTP_GET_CMD $FOP_URL |
|---|
| 106 | fi |
|---|
| 107 | |
|---|
| 108 | if test ! -d $FOP_DIR; then |
|---|
| 109 | echo -n "Expanding FOP distribution into $FOP_DIR... "; |
|---|
| 110 | gunzip -cd $FOP_TARBALL | tar xf - |
|---|
| 111 | echo "done."; |
|---|
| 112 | fi |
|---|
| 113 | HAVE_FOP="yes" |
|---|
| 114 | fi |
|---|
| 115 | |
|---|
| 116 | # Find the input jamfile to configure |
|---|
| 117 | JAM_CONFIG_OUT="$HOME/user-config.jam" |
|---|
| 118 | if test -r "$HOME/user-config.jam"; then |
|---|
| 119 | JAM_CONFIG_IN="user-config-backup.jam" |
|---|
| 120 | cp $JAM_CONFIG_OUT user-config-backup.jam |
|---|
| 121 | JAM_CONFIG_IN_TEMP="yes" |
|---|
| 122 | echo -n "Updating Boost.Jam configuration in $JAM_CONFIG_OUT... " |
|---|
| 123 | |
|---|
| 124 | elif test -r "$BOOST_ROOT/tools/build/v2/user-config.jam"; then |
|---|
| 125 | JAM_CONFIG_IN="$BOOST_ROOT/tools/build/v2/user-config.jam"; |
|---|
| 126 | JAM_CONFIG_IN_TEMP="no" |
|---|
| 127 | echo -n "Writing Boost.Jam configuration to $JAM_CONFIG_OUT... " |
|---|
| 128 | else |
|---|
| 129 | echo "ERROR: Please set the BOOST_ROOT environment variable to refer to your" |
|---|
| 130 | echo "Boost installation or copy user-config.jam into your home directory." |
|---|
| 131 | exit 0 |
|---|
| 132 | fi |
|---|
| 133 | |
|---|
| 134 | cat > setup_boostbook.awk <<EOF |
|---|
| 135 | BEGIN { using_boostbook = 0; eaten=0 } |
|---|
| 136 | |
|---|
| 137 | /^\s*using boostbook/ { |
|---|
| 138 | using_boostbook = 1; |
|---|
| 139 | print "using boostbook"; |
|---|
| 140 | print " : $DOCBOOK_XSL_DIR"; |
|---|
| 141 | print " : $DOCBOOK_DTD_DIR"; |
|---|
| 142 | eaten=1 |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | using_boostbook==1 && /;/ { using_boostbook = 2 } |
|---|
| 146 | using_boostbook==1 { eaten=1 } |
|---|
| 147 | |
|---|
| 148 | /^\s*using xsltproc.*$/ { eaten=1 } |
|---|
| 149 | /^\s*using doxygen.*$/ { eaten=1 } |
|---|
| 150 | /^\s*using fop.*$/ { eaten=1 } |
|---|
| 151 | |
|---|
| 152 | /^.*$/ { if (eaten == 0) print; eaten=0 } |
|---|
| 153 | |
|---|
| 154 | END { |
|---|
| 155 | if (using_boostbook==0) { |
|---|
| 156 | print "using boostbook"; |
|---|
| 157 | print " : $DOCBOOK_XSL_DIR"; |
|---|
| 158 | print " : $DOCBOOK_DTD_DIR"; |
|---|
| 159 | print " ;" |
|---|
| 160 | } |
|---|
| 161 | print "using xsltproc : $XSLTPROC ;" |
|---|
| 162 | if ("$HAVE_DOXYGEN" == "yes") print "using doxygen : $DOXYGEN ;"; |
|---|
| 163 | if ("$HAVE_FOP" == "yes") print "using fop : $FOP : : $JAVA ;"; |
|---|
| 164 | } |
|---|
| 165 | EOF |
|---|
| 166 | |
|---|
| 167 | awk -f setup_boostbook.awk $JAM_CONFIG_IN > $JAM_CONFIG_OUT |
|---|
| 168 | rm -f setup_boostbook.awk |
|---|
| 169 | echo "done." |
|---|
| 170 | |
|---|
| 171 | if test x"$JAM_CONFIG_IN_TEMP" = "xyes"; then |
|---|
| 172 | rm -f $JAM_CONFIG_IN |
|---|
| 173 | fi |
|---|
| 174 | |
|---|
| 175 | echo "Done! Execute \"bjam --v2\" in a documentation directory to generate" |
|---|
| 176 | echo "documentation with BoostBook. If you have not already, you will need" |
|---|
| 177 | echo "to compile Boost.Jam." |
|---|