I didn't have much time to look into the problem, but I did run the last command (the one that fails) and it outputs this when run with 'sh -x':
sh -x gen_contents_index --verbose
+ set -e
+ USAGE='Usage: gen_contents_index [--intree] [--verbose] [--help]'
+ INTREE=
+ VERBOSE=
+ HADDOCK_ARGS=
+ '[' 1 -ne 0 ']'
+ case "$1" in
+ VERBOSE=yes
+ shift
+ '[' 0 -ne 0 ']'
+ '[' -n '' ']'
+ HADDOCK=../../../../../bin/haddock
++ grep -v '/ghc\.haddock'
++ sort
++ ls -1 '*/*.haddock'
ls: */*.haddock: No such file or directory
+ HADDOCK_FILES=
+ HADDOCK_ARGS='-p prologue.txt'
+ '[' -n yes ']'
+ echo -p prologue.txt
-p prologue.txt
+ ../../../../../bin/haddock --gen-index --gen-contents -o . -t 'Haskell Hierarchical Libraries' -p prologue.txt
gen_contents_index: line 80: ../../../../../bin/haddock: No such file or directory
So the problem seems to be that the path to haddock in that script is bad for my setup. I haven't yet tracked down why line 80 in libraries/gen_contents_index occurs that way. It seems strange to have that path hardcoded in that way. I guess it might be generated by some earlier build scripts.