Fix another sed problem on Solaris
[ghc-hetmet.git] / libraries / gen_contents_index
1 #!/bin/sh
2
3 set -e
4
5 HADDOCK_ARGS=
6
7 case $* in
8 --inplace)
9     HADDOCK=../inplace/bin/haddock
10     HADDOCK_FILES1=`ls -1     */dist-install/doc/html/*/*.haddock | sort`
11     HADDOCK_FILES2=`ls -1 dph/*/dist-install/doc/html/*/*.haddock | sort`
12     HADDOCK_FILES="$HADDOCK_FILES1 $HADDOCK_FILES2"
13     for HADDOCK_FILE in $HADDOCK_FILES
14     do
15         LIBPATH=`echo "$HADDOCK_FILE" | sed 's#/dist-install.*##'`
16         NAME=`echo "$HADDOCK_FILE" | sed 's#.*/##' | sed 's#\.haddock$##'`
17         # It's easier to portably remove tabs with tr and to try to get
18         # sed to do what we want
19         VERSION=`grep -i '^version:' $LIBPATH/$NAME.cabal | sed 's/.*://'` | tr -d ' \t'
20         HADDOCK_ARG="--read-interface=${NAME}-${VERSION},$HADDOCK_FILE"
21         HADDOCK_ARGS="$HADDOCK_ARGS $HADDOCK_ARG"
22     done
23     ;;
24 *)
25     HADDOCK=../../../../../bin/haddock
26     # We don't want the GHC API to swamp the index
27     HADDOCK_FILES=`ls -1 */*.haddock | grep -v '/ghc\.haddock' | sort`
28     for HADDOCK_FILE in $HADDOCK_FILES
29     do
30         NAME_VERSION=`echo "$HADDOCK_FILE" | sed 's#/.*##'`
31         HADDOCK_ARG="--read-interface=${NAME_VERSION},$HADDOCK_FILE"
32         HADDOCK_ARGS="$HADDOCK_ARGS $HADDOCK_ARG"
33     done
34     ;;
35 esac
36
37 # Now create the combined contents and index pages
38 $HADDOCK --gen-index --gen-contents -o . \
39          -t "Haskell Hierarchical Libraries" \
40          -p "prologue.txt" \
41          $HADDOCK_ARGS
42
43 # Unhandled Windows help stuff?:
44
45 #libraries.HxS : libraries.txt
46 #        haddock ...
47 #               -k libraries
48 #               --html-help=mshelp2
49 #       ( cd $(HTML_DIR) && if Hxcomp -p libraries.HxC -o ../$@ ; then false ; else true ; fi ) || true
50 #
51 #libraries.chm : libraries.txt
52 #       haddock ...
53 #               -k libraries \
54 #               --html-help=mshelp \
55 #       ( cd $(HTML_DIR) && if hhc libraries.hhp ; then false ; else true ; fi && mv libraries.chm .. ) || true
56