Adding TcGadt.lhs
[ghc-hetmet.git] / distrib / cvs-build
1 #!/bin/sh
2 # *** Does this actually work with sh, or does it have to be bash? ***
3
4 # Purpose: Builds rpm binaries out of CVS
5 # Author : Manuel M. T. Chakravarty <chak@acm.org>
6 # Created: 26 April 2000
7 #
8 # This file is subject to the same free software license as GHC.
9
10 # Usage
11 # -----
12 #
13 # This script checks the given version of an fptools component out of CVS and
14 # builds a binary rpm package from it.  By default it builds the CVS head from
15 # anonymous CVS.  In the case of anonymous CVS, this script requires that `cvs 
16 # login' was already executed.
17 #
18 # The current version of this script handles ghc only, but in fact it is 
19 # planned to extend it to cover the other components in fptools.
20 #
21 # Options:
22 #
23 # -d REPOSITORY -- Value passed to CVS's -d option
24 # -r TAG        -- build the revision identified by the given CVS tag
25 # -D DATE       -- build the revision identified by the given CVS date
26 #
27 # (if there is more than one of the options -r and -D, the last one takes 
28 # effect)
29
30 # Requires: autoconf, cvs, GNU tar, gnuopt
31
32 # TODO
33 # ----
34 #
35 # * cover other fptools
36 # * it would be convenient to be able to specify an alternative .spec file 
37 #   (instead of using that in the repository)
38
39 # Default values
40 # --------------
41
42 # Use anonymous CVS by default
43 #
44 CVS_REPOSITORY=:pserver:anoncvs@glass.cse.ogi.edu:/cvs
45
46 # We build the CVS head by default (a date of `tomorrow' guarantees to catch
47 # the most recent check ins in the presence of clock skews - `now' wouldn't do
48 # that)
49 #
50 CVS_TAG="-D tomorrow"
51
52 # This is where we let rpm do the actual build
53 #
54 BUILD_DIR=/tmp/cvs-build-$$
55
56 # Works only for i386 for the moment...
57 # !!!IMPROVE THIS
58 ARCH=i386
59
60 START_DIR=`pwd`
61
62 # Command line option processing
63 #
64 GETOPT_OUTOUT=`getopt -o d:r:D: -n $0 -- "$@"`
65 if [ $? != 0 ]; then 
66   echo "Terminating..." >&2
67   exit 1
68 fi
69
70 eval set -- "$GETOPT_OUTPUT"
71 while [ $# -gt 0 ]; do
72   case "$1" in
73     -d) CVS_REPOSITORY=$2; shift 2;;
74     -r) CVS_TAG="-r $2"; shift 2;;
75     -D) CVS_TAG="-D $2"; shift 2;;
76     --) shift; break;;
77      *) echo "Internal error!" ; exit 1 ;;
78   esac
79 done
80
81 if [ $# != 0 ]; then
82   echo "Too many arguments..." >&2
83   exit 1
84 fi
85
86 # Check the sources out of CVS
87 #
88 echo "*** Exporting sources from CVS... (will build in $BUILD_DIR)"
89 mkdir -p $BUILD_DIR || exit 1
90 cd $BUILD_DIR
91 cvs -d $CVS_REPOSITORY export $CVS_TAG fpconfig || exit 1
92 cd fptools
93 cvs -d $CVS_REPOSITORY export $CVS_TAG ghc    || exit 1
94 cvs -d $CVS_REPOSITORY export $CVS_TAG hslibs || exit 1
95
96 VERSION=`sed -e 's/.*\([0-9]\)\.\([0-9]*\).*/\1.\2/' ghc/VERSION`
97 echo "*** ...got ghc $VERSION"
98
99
100 # Configure the tree (will produce the .spec file)
101 #
102 echo "*** Configuring sources..."
103 autoconf
104 cd ghc; autoconf; cd ..
105 ./configure || exit 1
106
107 # Populate the rpm build tree
108 #
109 echo "*** Setting up the rpm build tree..."
110 mkdir $BUILD_DIR/SPEC
111 mkdir $BUILD_DIR/SOURCES
112 mkdir $BUILD_DIR/BUILD
113 mkdir $BUILD_DIR/RPMS
114 mkdir $BUILD_DIR/RPMS/$ARCH
115 mkdir $BUILD_DIR/SRPMS
116
117 cp ghc/ghc.spec $BUILD_DIR/SPEC/ghc-${VERSION}.spec
118 cd $BUILD_DIR
119 tar -cz -f $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz fptools || exit 1
120 rm -rf $BUILD_DIR/fptools
121
122 # Build packages with rpm
123 #
124 echo "*** Building packages..."
125 rpm --define "_topdir $BUILD_DIR" -ba SPEC/ghc-${VERSION}.spec || exit 1
126 echo "*** ...made the packages"
127
128 # Cleaning up
129 #
130 echo "*** Cleaning up..."
131 cd $START_DIR
132 cp $BUILD_DIR/SOURCES/ghc-$VERSION-src.tar.gz .
133 cp $BUILD_DIR/RPMS/$ARCH/ghc* .
134 cp $BUILD_DIR/SRPMS/ghc* .
135 rm -rf $BUILD_DIR
136
137 echo "*** ...done."