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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
|
#!/bin/sh
# configure -- prepare to compile/install the HaXml package
# author: Malcolm.Wallace@cs.york.ac.uk, August 2002
VERSION="1.13.2"
if [ -f obj/prefix ]
then INSTALLDIR=`cat obj/prefix`
else INSTALLDIR=/usr/local/bin
fi
# We need a working `echo' command: at least Solaris2.6 may not have it.
CCC=${CC-gcc}
case `echo -n hello | wc -c | ( read n ; echo $n )` in
5) ;;
*) echo "The builtin 'echo' command doesn't do '-n' - emulating it."
$CCC -o script/echo script/echo.c
echo () { $PWD/script/echo "$@"; } ;;
esac
# We need a working `which' command: CYGWIN at least doesn't have it,
# and some installed 'which's behave badly, e.g. Solaris, OSF/1.
which () {
( for path in `echo \"$PATH\" | sed -e 's/:/\" \"/g'`
do
thefile=`echo $path | tr -d "\""`/$1
if [ -f "$thefile" -a -x "$thefile" ]
then echo $thefile
exit 0
fi
done; exit 1 )
}
DARWIN=false
CYGWIN=false
MINGW=false
SUNOS=false
case `uname -s` in
CYGWIN*) CYGWIN=true;;
MINGW*) MINGW=true ;;
Darwin*) DARWIN=true ;;
SunOS*) SUNOS=true ;;
esac
# Process command-line arguments
while [ "$1" != "" ]
do
case $1 in
--buildwith=*) BUILDWITH=`echo "$1" | cut -c13-` ;;
--buildopts=*) BUILDOPTS=$BUILDOPTS" "`echo "$1" | cut -c13-` ;;
--prefix=*) INSTALLDIR=`echo "$1" | cut -c10-` ;;
--help|-h)
echo "`basename $0` options: [default in brackets]"
echo " --buildwith=(ghc|hugs|nhc98) Build HaXml for the given compiler [detected]"
echo " --buildopts=flags Give extra flags needed by your build compiler [none]"
echo " --prefix=bindir Installed executables go in bindir [/usr/local/bin]"
exit 0 ;;
--version|-v) echo "HaXml: $VERSION"
exit 0 ;;
*) echo "`basename $0`: unrecognised option $1"
echo ' (use --help for option information)'
exit 1 ;;
esac
shift
done
echo "Looking for Haskell compilers:"
# Assume that we start out with a blank config.
HMAKEKNOWN=
GHCKNOWN=
NHCKNOWN=
HUGSKNOWN=
HMAKENUM=0
GHCNUM=0
NHCNUM=0
HUGSNUM=0
echo -n " Looking for hmake... "
if which hmake >/dev/null 2>&1
then
HMAKEKNOWN=`which hmake`
HMAKEVERSION=`${HMAKEKNOWN} --version | head -1 | cut -d' ' -f2`
HMAKENUM=`echo $HMAKEVERSION | tr "v." " " | ( read x y z; echo $x$y )`
fi
if [ "$HMAKEKNOWN" != "" ]
then echo "found ${HMAKEVERSION}"
else echo "(not found)"
fi
echo -n " Looking for ghc... "
if which ghc >/dev/null 2>&1
then
GHCKNOWN=`which ghc`
GHCVERSION=`${GHCKNOWN} --version 2>&1 | sed 's/^.*version[ ]*\([0-9.]*\).*/\1/'`
GHCNUM=`echo $GHCVERSION | tr "v." " " | ( read x y z; echo $x$y; )`
if [ "$GHCNUM" -lt "100" ]
then GHCNUM=${GHCNUM}0
fi
fi
if [ "$GHCKNOWN" = "" ]
then echo "(not found)"
else echo "found ${GHCVERSION}"
if [ "$GHCNUM" -lt "502" ]
then echo " Warning: HaXml needs ghc-5.02 or later. Ignoring ghc."
GHCKNOWN=
else GHCLIBDIR=`${GHCKNOWN} -v 2>&1 | grep ' package config file: ' | head -1 | sed 's/.* package config file: //'`
if $CYGWIN; then GHCLIBDIR=`cygpath -u $GHCLIBDIR`; fi
if $MINGW; then GHCLIBDIR=`echo $GHCLIBDIR | tr '\\\\' '/'`; fi
GHCLIBDIR=`dirname $GHCLIBDIR`
GHCINCDIR=$GHCLIBDIR/imports
fi
fi
# There may be another version of ghc to look for.
if [ -n "$BUILDWITH" ]
then
if [ "`basename $BUILDWITH | cut -c1-3`" = "ghc" ]
then
VER=`basename $BUILDWITH | cut -c5-`
if [ -n "$VER" -a "$VER" != "$GHCVERSION" ]
then
echo -n " Looking for $BUILDWITH... "
if which $BUILDWITH >/dev/null 2>&1
then
GHC2KNOWN=`which $BUILDWITH`
GHC2VERSION=`${GHC2KNOWN} --version 2>&1 | sed 's/^.*version[ ]*\([0-9.]*\).*/\1/'`
GHC2NUM=`echo $GHC2VERSION | tr "." " " | ( read x y z; echo $x$y; )`
if [ "$GHC2NUM" -lt "100" ]
then GHC2NUM=${GHC2NUM}0
fi
fi
if [ "$GHC2KNOWN" = "" ]
then echo "(not found)"
else echo "found ${GHC2VERSION}"
if [ "$GHC2NUM" -lt "502" ]
then echo " Warning: HaXml needs ghc-5.02 or later. Ignoring."
GHC2KNOWN=
else GHCKNOWN="$GHC2KNOWN"
GHCVERSION="$GHC2VERSION"
GHCNUM="$GHC2NUM"
GHCLIBDIR=`${GHCKNOWN} -v 2>&1 | grep ' package config file: ' | head -1 | sed 's/.* package config file: //'`
if $CYGWIN; then GHCLIBDIR=`cygpath -u $GHCLIBDIR`; fi
if $MINGW; then GHCLIBDIR=`echo $GHCLIBDIR | tr '\\\\' '/'`; fi
GHCLIBDIR=`dirname $GHCLIBDIR`
GHCINCDIR=$GHCLIBDIR/imports
fi
fi
fi
fi
fi
echo -n " Looking for nhc98... "
if which nhc98 >/dev/null 2>&1
then
NHCKNOWN=`which nhc98`
NHCVERSION=`${NHCKNOWN} --version | head -1 | cut -d' ' -f2`
NHCNUM=`echo $NHCVERSION | tr "v." " " | ( read x y z; echo $x$y )`
fi
if [ "$NHCKNOWN" = "" ]
then echo "(not found)"
else echo "found ${NHCVERSION}"
if [ "$HMAKENUM" -lt "306" ]
then echo " Warning: building with nhc98 needs hmake-3.06 or later."
echo " Available from: http://www.haskell.org/hmake/"
fi
if [ "$NHCNUM" -lt "114" ]
then echo " Warning: HaXml needs nhc98-1.14 or later. Ignoring nhc98."
NHCKNOWN=
else NHCLIBDIR=`grep '^NHC98LIBDIR' $NHCKNOWN | cut -c27- | cut -d'}' -f1 | head -1`
NHCINCDIR=`grep '^NHC98INCDIR' $NHCKNOWN | cut -c27- | cut -d'}' -f1 | head -1`
fi
fi
month() {
read mon yr;
case $mon in
Jan*) echo 01;;
Feb*) echo 02;;
Mar*) echo 03;;
Apr*) echo 04;;
May) echo 05;;
Jun*) echo 06;;
Jul*) echo 07;;
Aug*) echo 08;;
Sep*) echo 09;;
Oct*) echo 10;;
Nov*) echo 11;;
Dec*) echo 12;;
*) echo 00;;
esac;
}
echo -n " Looking for hugs... "
if which hugs >/dev/null 2>&1
then
HUGSKNOWN=`which hugs`
HUGSVERSION=`echo :q | $HUGSKNOWN 2>/dev/null | grep Version | cut -c18-32`
HUGSNUM=`echo $HUGSVERSION | cut -d' ' -f2`
HUGSNUM=$HUGSNUM`echo $HUGSVERSION | month`
fi
if [ "$HUGSKNOWN" = "" ]
then echo "(not found)"
else echo "found ${HUGSVERSION}"
if [ "$HUGSNUM" -lt "200309" ]
then echo " Warning: HaXml configuration only supports Hugs >= Sept 2003."
HUGSKNOWN=
fi
fi
if [ ! -z "$BUILDWITH" ]
then
echo " You want to build for only... $BUILDWITH"
if [ "`echo $BUILDWITH | cut -c1-3`" = "ghc" ]
then
if [ -z "$GHCKNOWN" ]
then echo ' *** Did not find ghc - cannot continue.'
exit 1
else NHCKNOWN=
HUGSKNOWN=
fi
else if [ "$BUILDWITH" = "nhc98" ]
then
if [ -z "$NHCKNOWN" ]
then echo ' *** Did not find nhc98 - cannot continue.'
exit 1
else GHCKNOWN=
HUGSKNOWN=
fi
else if [ "`echo $BUILDWITH | cut -c1-4`" = "hugs" ]
then
if [ -z "$HUGSKNOWN" ]
then echo ' *** Did not find hugs - cannot continue.'
exit 1
else GHCKNOWN=
NHCKNOWN=
fi
else echo ' *** I do not recognise this compiler:' $BUILDWITH
exit 1
fi;fi;fi;
fi
echo " Executables install into... $INSTALLDIR"
echo " (note: no extra /bin will be added to the end of that location)"
echo " ( re-run ./configure --prefix=... if this wasn't your intention)"
# Prepare to build.
if [ ! -d obj ]
then mkdir obj
fi
if [ -f obj/compilers ]
then rm obj/compilers
fi
if [ "$HUGSKNOWN" != "" ]
then
echo hugs >>obj/compilers
if [ ! -d obj/hugs ]
then mkdir obj/hugs
fi
cp -Rp src/tools src/Makefile obj/hugs
fi
if [ "$GHCKNOWN" != "" ]
then
echo ghc >>obj/compilers
if [ ! -d obj/ghc ]
then mkdir obj/ghc
fi
echo $GHCLIBDIR >obj/ghc/ghclibdir
echo $GHCINCDIR >obj/ghc/ghcincdir
if $CYGWIN || $MINGW
then cygpath -w ${GHCLIBDIR} >obj/ghc/ghclibdirraw
cygpath -w ${GHCINCDIR}/ >obj/ghc/ghcincdirraw
else echo ${GHCLIBDIR} >obj/ghc/ghclibdirraw
echo ${GHCINCDIR}/ >obj/ghc/ghcincdirraw
fi
if ghc-pkg-$GHCVERSION -l >/dev/null
then echo ghc-pkg-$GHCVERSION >obj/ghc/ghcpkgcmd
else echo ghc-pkg >obj/ghc/ghcpkgcmd
fi
echo ${BUILDWITH-ghc} >obj/ghccmd
cp -Rp src/Text src/tools src/Makefile src/pkg.conf obj/ghc
if [ "$GHCNUM" -ge "504" ]
then rm -rf obj/ghc/Text/PrettyPrint
echo "-package base" >obj/ghc/ghcpkgs
else echo "-package lang -package data" >obj/ghc/ghcpkgs
fi
fi
if [ "$NHCKNOWN" != "" ]
then
echo nhc98 >>obj/compilers
if [ ! -d obj/nhc98 ]
then mkdir obj/nhc98
fi
echo $NHCLIBDIR >obj/nhc98/nhc98libdir
echo $NHCINCDIR >obj/nhc98/nhc98incdir
cp -Rp src/Text src/tools src/Makefile obj/nhc98
if [ "$NHCNUM" -ge "116" ]
then rm -rf obj/ghc/Text/PrettyPrint
echo "-package base" >obj/nhc98/nhc98pkgs
else echo "" >obj/nhc98/nhc98pkgs
fi
fi
echo $INSTALLDIR >obj/prefix
if $CYGWIN || $MINGW ; then echo .exe >obj/exe; else touch obj/exe; fi
if $CYGWIN || $MINGW ; then echo main.exe >obj/out; else echo a.out >obj/out; fi
if $DARWIN ; then echo -all_load; else echo --whole-archive; fi >obj/ldopt
if $SUNOS ; then echo -z allextract; fi >obj/ldopt
echo "Ready to build. Type 'make' then (as root) 'make install'."
exit 0
|