File: confhat

package info (click to toggle)
hat 2.05%2Brerolled-7
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,316 kB
  • ctags: 1,077
  • sloc: haskell: 74,306; ansic: 9,588; sh: 1,770; makefile: 597
file content (95 lines) | stat: -rwxr-xr-x 2,945 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
#	confhat -- install the Hat system for ghc or nhc98
#	author:   Malcolm.Wallace@cs.york.ac.uk, Mar 2002

MACHINE=${MACHINE-`script/harch`}
PWD=`pwd`
COMP=$1
PREFIX=$2
HC=`echo $COMP | cut -c1-3`	# e.g. ghc
VER=`echo $COMP | cut -c4-`	# e.g. -5.04.1

TRUE=/bin/true
if [ ! -x $TRUE ]
then TRUE=/usr/bin/true
fi

DIRS="Data Control Control/Monad Debug Foreign Foreign/Marshal System \
	System/Console System/IO Test Text Text/ParserCombinators \
	Text/ParserCombinators/Parsec Text/PrettyPrint"
HATDIRS="Hat `for dir in $DIRS; do echo Hat/$dir; done`"

if [ "$HC" = "ghc" -a -d lib/$MACHINE/hatlib/$COMP ]
then
  # discover ghc version (technique courtesy of Simon Marlow)
  echo __GLASGOW_HASKELL__ >ghcsym.hs;
  $COMP -E -cpp -optP-P ghcsym.hs -o ghcsym.out;
  GHCSYM=`grep -v '^#' ghcsym.out | grep -v '^$'`
  rm -f ghcsym.hs ghcsym.out;

#  # discover ghc location
#  libdir=`$COMP -v 2>&1 | head -n 2 | tail -1 | cut -c28- | head -n 1`
#  libdir=`dirname $libdir`
#  libdir=$DESTDIR$libdir
#  incdir=$libdir/imports/hat
  libdir=$DESTDIR$PREFIX/lib/hat-$HATVERSION/$MACHINE/ghc-$GHCSYM
  incdir=$DESTDIR$PREFIX/imports/hat-$HATVERSION/ghc-$GHCSYM
  echo >&2 "Installing hat package for ghc under $libdir"
  mkdir -p $libdir
  mkdir -p $incdir

  # install ghc package components
  echo -P$incdir >lib/$MACHINE/hatlib/$COMP/ghcincdir
  cp -p lib/$MACHINE/hatlib/$COMP/libHShat.a $libdir  && \
  ranlib $libdir/libHShat.a && \
  if [ -d $incdir ]
  then
    rm -rf $incdir/Hat && \
    { ghc-pkg$VER --remove-package=hat || $TRUE; }
  else
    mkdir $incdir
  fi && \
  for dir in $HATDIRS; \
      do mkdir $incdir/$dir; \
      done  && \
  for dir in $HATDIRS; \
      do cp lib/$MACHINE/hatlib/$COMP/$dir/*.hi $incdir/$dir; \
      done  && \
  if [ $GHCSYM -ge 604 ]
  then
      { cat  lib/$MACHINE/hatlib/$COMP/hat-package.conf ;
        echo "import-dirs:	$incdir";
        echo "library-dirs:	$libdir";
      } | ghc-pkg$VER --user register -
  else
    cat lib/$MACHINE/hatlib/$COMP/hat-package.conf | ghc-pkg$VER --add-package
  fi 
fi
if [ -d lib/$MACHINE/hatlib/nhc98 ]
then
  # discover nhc98 location
  nhc98=`which nhc98`
  libdir=`grep '^NHC98LIBDIR' $nhc98 | cut -c27- | cut -d'}' -f1 | head -n 1`
  incdir=`grep '^NHC98INCDIR' $nhc98 | cut -c27- | cut -d'}' -f1 | head -n 1`
  libdir=$DESTDIR$libdir
  incdir=$DESTDIR$incdir
  echo >&2 "Installing hat package for nhc98 under $libdir"
  mkdir -p $libdir/$MACHINE
  mkdir -p $incdir

  # install nhc98 package components
  cp -p lib/$MACHINE/hatlib/nhc98/libHShat.a $libdir/$MACHINE  && \
  if [ -d $incdir/hat ]
  then rm -rf $incdir/hat
  fi
  if [ -d $incdir/packages/hat ]
  then rm -rf $incdir/packages/hat/Hat
  else mkdir -p $incdir/packages/hat
  fi && \
  for dir in $HATDIRS; \
      do mkdir $incdir/packages/hat/$dir; \
      done  && \
  for dir in $HATDIRS; \
      do cp lib/$MACHINE/hatlib/$COMP/$dir/*.hi $incdir/packages/hat/$dir; \
      done
fi