Fix non-portable regexp
[ghc.git] / boot-pkgs
1 #! /bin/sh
2 set -e
3
4 libraries=
5
6 tarred=`ls -1 libraries/tarballs | sed "s/-[0-9.]*\(-snapshot\)\{0,1\}.tar.gz//"`
7
8 for p in $tarred
9 do
10     libraries="$libraries libraries/$p"
11     if [ -d "libraries/$p/_darcs" ]
12     then
13         echo Ignoring libraries/$p as it looks like a darcs checkout
14     else
15         tarball=libraries/tarballs/$p-*.tar.gz
16         stamp="libraries/stamp/$p"
17         if [ ! -d "libraries/$p" ] ||
18            [ ! -f "$stamp" ] ||
19            [ "libraries/stamp/$p" -ot $tarball ]
20         then
21             rm -rf "libraries/$p"
22             mkdir "libraries/$p"
23             (
24                 cd "libraries/$p"
25                 tar -zxf ../../$tarball
26                 mv */* .
27             )
28             touch "$stamp"
29         fi
30     fi
31 done
32
33 for f in libraries/*; do
34   pkgs=$f/ghc-packages
35   if test -f $pkgs; then
36     for p in `cat $pkgs`; do
37       libraries="$libraries $f/$p"
38     done
39   else
40     libraries="$libraries $f"
41   fi
42 done
43
44 for f in $libraries; do
45    dir=`basename $f`
46    cabals=`echo $f/*.cabal`
47    if test -f $cabals; then
48        echo "Creating $f/ghc.mk"
49        rm -f $f/ghc.mk
50        pkg=`echo "$cabals" | sed -e 's#.*/##' -e 's#\.cabal$##'`
51        if test -f $f/ghc-stage; then
52            stage=`cat $f/ghc-stage`
53        else
54            stage=1
55        fi
56        top=`echo $f | sed 's#[^/][^/]*#..#g'`
57        echo "${f}_PACKAGE = ${pkg}" >> $f/ghc.mk
58        echo "${f}_dist-install_GROUP = libraries" >> $f/ghc.mk
59        echo "\$(eval \$(call build-package,${f},dist-install,${stage}))" >> $f/ghc.mk
60        rm -f $f/GNUmakefile
61        echo "Creating $f/GNUmakefile"
62        echo "dir = ${f}" >> $f/GNUmakefile
63        echo "TOP = ${top}" >> $f/GNUmakefile
64        echo "include \$(TOP)/mk/sub-makefile.mk" >> $f/GNUmakefile
65    fi
66 done