-#
-# Customize the file here
-#
-FROMDIR="$HOME/lilypond"
-DOCDIR="$HOME/lilypond/tempdocs"
-TODIR=$DOCDIR/$NAME
-LILYPONDBOOK="lilypond-book"
+usage () {
+ cat <<EOF >&2
+
+Usage: $0 MANUAL SECTION
+e.g. $0 notation rhythms
+
+EOF
+ exit "$1"
+}
+
+if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
+ usage 0
+fi
+
+[ $# = 2 ] || usage 1
+
+if [ -n "$LILYPOND_GIT" ]; then
+ echo "Using source tree from value of \$LILYPOND_GIT: $LILYPOND_GIT"
+else
+ cd "`dirname $0`"
+ cd ../..
+ LILYPOND_GIT="`pwd`"
+ echo "\$LILYPOND_GIT was not set; auto-detected source tree at $LILYPOND_GIT"
+fi
+
+if [ -n "$BROWSER" ]; then
+ echo "Using browser from \$BROWSER: $BROWSER"
+else
+ echo "\$BROWSER not set; using firefox as default"
+ BROWSER="firefox"
+fi
+
+if test ! -e "$LILYPOND_GIT/DEDICATION"; then
+ echo "Error: $LILYPOND_GIT did not look like a LilyPond source tree; aborting." >&2
+ exit 1
+fi
+
+: "${LILYPOND_BUILD_DIR:=$LILYPOND_GIT/build}"
+DOC_DIR="${LILYPOND_TEMPDOCS:-$LILYPOND_BUILD_DIR/tempdocs}"
+LILYPOND_BOOK="$LILYPOND_BUILD_DIR/out/bin/lilypond-book"