Generate the haddock contents/index pages in a dist-haddock subdirectory
authorIan Lynagh <igloo@earth.li>
Sun, 8 Jan 2012 14:43:46 +0000 (14:43 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 8 Jan 2012 14:43:46 +0000 (14:43 +0000)
This is tidier, and makes it easier to clean and install them correctly

ghc.mk
libraries/gen_contents_index

diff --git a/ghc.mk b/ghc.mk
index 3805bbe..0bd3d8d 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -666,17 +666,12 @@ $(foreach p,$(PACKAGES_STAGE0),$(eval libraries/$p_dist-boot_DO_HADDOCK = NO))
 
 # Build the Haddock contents and index
 ifeq "$(HADDOCK_DOCS)" "YES"
-libraries/index.html: inplace/bin/haddock$(exeext) $(ALL_HADDOCK_FILES)
+libraries/dist-haddock/index.html: inplace/bin/haddock$(exeext) $(ALL_HADDOCK_FILES)
        cd libraries && sh gen_contents_index --inplace
 ifeq "$(phase)" "final"
-$(eval $(call all-target,library_doc_index,libraries/index.html))
+$(eval $(call all-target,library_doc_index,libraries/dist-haddock/index.html))
 endif
-INSTALL_LIBRARY_DOCS += libraries/*.html libraries/*.gif libraries/*.css libraries/*.js
-CLEAN_FILES += $(wildcard libraries/doc-index*   \
-                          libraries/haddock*.css \
-                          libraries/haddock*.js  \
-                          libraries/index*.html  \
-                          libraries/*.gif)
+INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
 endif
 
 # -----------------------------------------------------------------------------
@@ -1165,6 +1160,11 @@ $(foreach lib,$(PACKAGES_STAGE1) $(PACKAGES_STAGE2),\
   $(eval $(call clean-target,libraries/$(lib),dist-install,libraries/$(lib)/dist-install)))
 endif
 
+clean : clean_haddock_index
+.PHONY: clean_haddock_index
+clean_haddock_index:
+       $(call removeTrees,libraries/dist-haddock)
+
 clean : clean_bindistprep
 .PHONY: clean_bindistprep
 clean_bindistprep:
index c8d82c8..b9aaa93 100644 (file)
@@ -4,18 +4,21 @@ set -e
 
 HADDOCK_ARGS=
 
+[ -d dist-haddock ] || mkdir dist-haddock
+cd dist-haddock
+
 case $* in
 --inplace)
-    HADDOCK=../inplace/bin/haddock
-    for REPO in `grep '^libraries/[^ ]*  *- ' ../packages | sed -e 's#libraries/##' -e 's/ .*//'`
+    HADDOCK=../../inplace/bin/haddock
+    for REPO in `grep '^libraries/[^ ]*  *- ' ../../packages | sed -e 's#libraries/##' -e 's/ .*//'`
     do
-        if [ -f "$REPO/ghc-packages" ]
+        if [ -f "../$REPO/ghc-packages" ]
         then
-            LIBS="`cat $REPO/ghc-packages`"
-            LIBROOT="$REPO"
+            LIBS="`cat ../$REPO/ghc-packages`"
+            LIBROOT="../$REPO"
         else
             LIBS="$REPO"
-            LIBROOT="."
+            LIBROOT=".."
         fi
         for LIB in $LIBS
         do
@@ -34,9 +37,9 @@ case $* in
     done
     ;;
 *)
-    HADDOCK=../../../../../bin/haddock
+    HADDOCK=../../../../../../bin/haddock
     # We don't want the GHC API to swamp the index
-    HADDOCK_FILES=`ls -1 */*.haddock | grep -v '/ghc\.haddock' | sort`
+    HADDOCK_FILES=`ls -1 ../*/*.haddock | grep -v '/ghc\.haddock' | sort`
     for HADDOCK_FILE in $HADDOCK_FILES
     do
         NAME_VERSION=`echo "$HADDOCK_FILE" | sed 's#/.*##'`
@@ -50,7 +53,7 @@ esac
 echo $HADDOCK_ARGS
 $HADDOCK --gen-index --gen-contents -o . \
          -t "Haskell Hierarchical Libraries" \
-         -p "prologue.txt" \
+         -p "../prologue.txt" \
          $HADDOCK_ARGS
 
 # Unhandled Windows help stuff?: