summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap.sh13
-rwxr-xr-xdocs/naturaldocs/run_docs.sh51
2 files changed, 51 insertions, 13 deletions
diff --git a/bootstrap.sh b/bootstrap.sh
index f6c732d..45279ff 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -2,24 +2,19 @@
# $Id$
# Small shell script to build gd from source
+v() { echo "$@"; "$@"; }
+
# Generate the manual (unless naturaldocs isn't installed). Source
# dists should include the docs so that end users don't need to
# install naturaldocs. At the same time, we tolerate it being missing
# so that random hackers don't need it just to build the code.
-if which naturaldocs >/dev/null 2>&1 ; then
- echo "Generation user docs:"
- (cd docs/naturaldocs; bash run_docs.sh)
-else
- echo "Can't find naturaldocs; not generating user manual."
-fi
-
+v docs/naturaldocs/run_docs.sh --nonfatal
if echo "${OSTYPE:-$(uname)}" | grep -q '^darwin' ; then
echo "Having trouble on OS X? Try: brew install autoconf libtool automake gettext apple-gcc42 pkg-config cmake"
fi
-echo "autoreconf -f -i"
-if ! autoreconf -f -i ; then
+if ! v autoreconf -f -i ; then
exit 1
fi
diff --git a/docs/naturaldocs/run_docs.sh b/docs/naturaldocs/run_docs.sh
index dfe1e62..40fec77 100755
--- a/docs/naturaldocs/run_docs.sh
+++ b/docs/naturaldocs/run_docs.sh
@@ -1,18 +1,61 @@
-#!/bin/bash
+#!/bin/sh
set -e
+usage() {
+ echo "Usage: run_docs.sh [--nonfatal]"
+ echo "Generate the manual for gd!"
+ if [ $# -ne 0 ] ; then
+ printf 'ERROR: %b\n' "$*"
+ exit 1
+ else
+ exit 0
+ fi
+}
+
+nd() {
+ # Figure out the name of this tool.
+ if which naturaldocs 2>/dev/null ; then
+ return
+ elif which NaturalDocs 2>/dev/null ; then
+ return
+ else
+ return 1
+ fi
+}
+
+cd "$(dirname "$0")"
+
+if [ $# -eq 1 ] ; then
+ case $1 in
+ --nonfatal)
+ if ! nd >/dev/null ; then
+ echo "skipping doc generation -- please install naturaldoc!"
+ exit 0
+ fi
+ ;;
+ -h|--help)
+ usage
+ ;;
+ *)
+ usage "unknown option: $1"
+ ;;
+ esac
+elif [ $# -ne 0 ] ; then
+ usage "unknown options: $*"
+fi
+
# Version number
VERSION=`(cd ../../; perl config/getver.pl)`
# Clear away old docs and ensure the doc dir. is present.
-[ -d html ] && rm -rf html
+rm -rf html
mkdir html
# Create a lightly-processed copy of the source to use as input. This
# file skips all non-C code in src/ and removes the BGD_DECLARE()
# macro from definitions so they don't show up in the docs.
-[ -d tmp ] && rm -rf tmp
+rm -rf tmp
mkdir tmp
perl nobgd.pl ../../src/ tmp/
@@ -22,7 +65,7 @@ sed -e "s/@VERSION@/$VERSION/g" preamble.txt > tmp/preamble.txt
# ^^^ hack to get the version number in the docs.
# Run naturaldocs to create the manual.
-naturaldocs --rebuild --rebuild-output --documented-only \
+$(nd) --rebuild --rebuild-output --documented-only \
-i tmp/ \
-o html html \
--project project/