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 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
|
#!/bin/sh
# configure -- prepare to compile/install hmake
# author: Malcolm.Wallace@cs.york.ac.uk
# (nhc13config - March 1998)
# (nhc98config - May 1999)
# (configure - Oct 1999)
# (hacked for just hmake - December 1999)
# (updated - January 2002)
# When incrementing this version number, don't forget to change the
# corresponding definition in Makefile.inc!
HMAKEVERSION="3.13 (2006-11-01)" export HMAKEVERSION
if uname >/dev/null 2>&1
then OS=`uname -s`
else OS=unknown
fi
# Note for people building binary packages of hmake:
# The variable INSTALLDIR, default /usr/local, changed with --prefix=
# gives the final destination of everything. The configure script
# hard-wires this path into scripts when you give the --install flag.
# However, if you set the environment variable DESTDIR, the installation
# process will still hardwire your INSTALLDIR into scripts, but actually
# install the files in $DESTDIR$INSTALLDIR. In this way, you can build
# a complete installation tree in a temporary directory, then tar it up
# as a package with all the scripts pointing to the correct final location.
INSTALLDIR=/usr/local
USER=${USER-`whoami 2>/dev/null`}
MACHINE=`script/harch`
PWD=`pwd`
case $OS in
CYGWIN*) PWD=`cygpath -w "$PWD" | tr '\\\\' '/'`
case $PWD in # further path mangling required for CYGWIN
file://?/*) PWD=`echo $PWD | sed -e "s|^file://||" |\
sed -e "s|^[^/]|&:|"` ;;
//?/*) PWD=`echo $PWD | sed -e "s|^//||" |\
sed -e "s|^[^/]|&:|"` ;;
esac
READLINE=""
EXE=.exe ;;
*) EXE="" ;;
esac
case "$PWD" in
*' '*)
echo "Error: hmake will not build in a directory with spaces anywhere"
echo " in the full pathname."
echo "Suggestion: move the build tree somewhere else."
exit 1 ;;
esac
# We need a working `echo' command: at least Solaris2.6 may not have it.
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
BUILDWITH=
GHCSYM=
BUILDLIBDIR=$PWD/lib
BUILDBINDIR=$PWD/script
BUILDDIR=$PWD/targets
INSTALL=no
LIB=yes
BIN=yes
MAN=yes
if [ -f targets/$MACHINE/config.cache ]
then # cached settings override defaults above
. targets/$MACHINE/config.cache
else
if [ ! -d targets/$MACHINE ]
then mkdir -p targets/$MACHINE
fi
fi
while [ "$1" != "" ]
do
case $1 in
+lib) LIB=yes ;;
-lib) LIB=no ;;
+bin) BIN=yes ;;
-bin) BIN=no ;;
+man) MAN=yes ;;
-man) MAN=no ;;
--buildwith=*) BUILDWITH=`echo "$1" | cut -c13-` ;;
--buildopts=*) BUILDOPTS=$BUILDOPTS" "`echo "$1" | cut -c13-` ;;
--builddir=*) BUILDDIR=`echo "$1" | cut -c12-` ;;
--prefix=*) INSTALLDIR=`echo "$1" | cut -c10-` ;;
--installdir=*) INSTALLDIR=`echo "$1" | cut -c14-` ;;
--bindir=*) BINDIR=`echo "$1" | cut -c10-` ;;
--libdir=*) LIBDIR=`echo "$1" | cut -c10-` ;;
--confdir=*) CONFDIR=`echo "$1" | cut -c11-` ;;
--mandir=*) MANDIR=`echo "$1" | cut -c10-` ;;
--hbcdir=*) HBCDIR=`echo "$1" | cut -c10-` ;;
--ghcdir=*) GHCDIR=`echo "$1" | cut -c10-` ;;
--install) INSTALL=yes ;;
--config) INSTALL=no ;;
--help|-h)
echo "`basename $0` options: [default in brackets]"
echo " --config Configure only (do not install) [default]"
echo " --install Configure AND install now"
echo " --help / -h Display these options and quit"
echo " --version / -v Display version of hmake"
echo
echo " --buildwith=comp Build hmake with given compiler [detected]"
echo " --buildopts=flags Give extra flags to build-compiler [none]"
#echo
#echo " --hbcdir=dir Tell hmake about hbc/LML installation in dir [detected]"
#echo " --ghcdir=dir Tell hmake about ghc installation in dir [detected]"
echo
echo " --builddir=dir Build intermediate object files under dir [./targets]"
echo " --prefix=rootdir |"
echo " --installdir=rootdir | Use rootdir as base for installation [/usr/local]"
echo " --bindir=dir Install scripts in dir [\$rootdir/bin]"
echo " --libdir=dir Install libraries in dir [\$rootdir/lib/hmake]"
echo " --confdir=dir Install configuration data in dir [\$libdir]"
echo " --mandir=dir Install man pages in dir [\$rootdir/man/man1]"
echo
echo " [+/-]bin Do/don't (re-)install scripts [+bin]"
echo " [+/-]lib Do/don't (re-)install executables [+lib]"
echo " [+/-]man Do/don't (re-)install man pages [+man]"
exit 0 ;;
--version|-v) echo "hmake: $HMAKEVERSION"
echo ' [' $INSTALLINFO ']'
exit 0 ;;
*) echo "`basename $0`: unrecognised option $1"
echo ' (use --help for option information)'
exit 1 ;;
esac
shift
done
echo Configuring for hmake... '[' $HMAKEVERSION ']'
if [ -f targets/$MACHINE/config.cache ]
then
echo "Starting with earlier config in targets/$MACHINE/config.cache"
echo '[' $INSTALLINFO ']'
echo ' (but cmdline options have precedence)'
fi
INSTALLINFO="config: $MACHINE/$BUILDWITH by $USER@`uname -n` on `date`"
LIBDIR=${LIBDIR-$INSTALLDIR/lib/hmake}
CONFDIR=${CONFDIR-$LIBDIR}
BINDIR=${BINDIR-$INSTALLDIR/bin}
MANDIR=${MANDIR-$INSTALLDIR/man/man1}
#HBCDIR=${HBCDIR}
#GHCDIR=${GHCDIR}
case $OS in
CYGWIN*) INSTALLDIR=`cygpath -w "$INSTALLDIR" | tr '\\\\' '/'`
BUILDDIR=`cygpath -w "$BUILDDIR" | tr '\\\\' '/'`
LIBDIR=`cygpath -w "$LIBDIR" | tr '\\\\' '/'`
CONFDIR=`cygpath -w "$CONFDIR" | tr '\\\\' '/'`
BINDIR=`cygpath -w "$BINDIR" | tr '\\\\' '/'`
;;
*) ;;
esac
case $MACHINE in
*Darwin[56]) CCC=${CC-cc};;
*) CCC=${CC-gcc};;
esac
#case $OS in
# SunOS) LIBCOMPAT=" -lsocket" ;;
# NetBSD) LIBCOMPAT=" -lcompat" ;;
# *) LIBCOMPAT= ;;
#esac
# Detect Haskell compilers and choose one for building with.
# (Also generates a little script for configuring hmake later.)
if [ -d src ] # Delay this step if it is a binary (src-less) distribution.
then
echo "--------"
CCC=$CCC script/confhc $BUILDWITH
echo "--------"
fi
echo " Configuration report for hmake."
if [ "$INSTALL" = "no" ]
then
echo " (You can re-run `basename $0` to change settings before proceeding.)"
echo "You wish (eventually) to install the following components in these locations:"
echo " (Installation directories are not created/checked at this stage.)"
echo "Final install root: $INSTALLDIR"
if [ "$LIB" = "yes" ]
then
echo "hmake binaries: $LIBDIR/$MACHINE"
echo "hmakerc: $CONFDIR/$MACHINE"
else
echo "Executables and libs: (none)"
fi
if [ "$BIN" = "yes" ]
then
echo "Scripts: $BINDIR"
else
echo "Scripts: (none)"
fi
if [ "$MAN" = "yes" ]
then
echo "Man pages: $MANDIR"
else
echo "Man pages: (none)"
fi
if [ -d src ] # Don't bother with these if unpacking a binary distribution
then
echo
echo "Now we check/create your build directories:"
echo "Config directory: targets/$MACHINE"
echo "Build directory root:"
echo -n " $BUILDDIR"
if [ ! -d $BUILDDIR ]
then mkdir -p $BUILDDIR; echo ' (created)'
else echo ' (exists)'
fi
echo "Object files build in:"
echo -n " $BUILDDIR/$MACHINE"
if [ ! -d $BUILDDIR/$MACHINE ]
then mkdir -p $BUILDDIR/$MACHINE; echo ' (created)'
else echo ' (exists)'
fi
echo "Executables and libs:"
echo -n " $BUILDLIBDIR/$MACHINE"
if [ ! -d $BUILDLIBDIR/$MACHINE ]
then mkdir -p $BUILDLIBDIR/$MACHINE; echo ' (created)'
else echo ' (exists)'
fi
else
echo
echo "Checking your binary distribution for integrity:"
echo -n "Config directory: targets/$MACHINE"
if [ ! -d targets/$MACHINE ]
then mkdir -p targets/$MACHINE; echo ' (created ok)'
else echo ' (exists)'
fi
echo -n "Executables and libs: $BUILDLIBDIR/$MACHINE"
if [ ! -d $BUILDLIBDIR/$MACHINE ]
then echo ' (***MISSING!)'
echo 'Help! Have you got the right executables for your machine?'
exit 1
else echo ' (ok)'
fi
fi
fi
echo
# The following tests are unnecessary in a binary (src-less) distribution.
if [ -d src ]
then
if [ "$BUILDWITH" = "" ]
then
BUILDWITH=`cat targets/$MACHINE/buildwith`
echo "I have guessed you will build hmake with: $BUILDWITH"
else
echo "You are going to build hmake with: $BUILDWITH"
fi
GHCSYM=`cat targets/$MACHINE/ghcsym || true`
if [ "$BUILDOPTS" != "" ]
then echo "You gave the following extra build options: $BUILDOPTS"
fi
if [ "$EXE" = "" ]
then
echo -n "Testing for the curses library: "
if [ "$CURSES" = "" ]
then
cat >curses.c <<!!!
#include <curses.h>
void test (void) { mvaddstr(1,2,"hello world"); }
int main (void) { test(); }
!!!
if ${CCC} -o curses curses.c >/dev/null 2>/dev/null
then CURSES=""
else
if ${CCC} -o curses curses.c -lncurses >/dev/null 2>/dev/null
then CURSES="-lncurses"
else
if ${CCC} -o curses curses.c -lcurses >/dev/null 2>/dev/null
then CURSES="-lcurses"
else
if ${CCC} -o curses curses.c -lcurses -ltermcap \
>/dev/null 2>/dev/null
then CURSES="-lcurses -ltermcap"
else CURSES="-ltermcap -lcurses" # don't know a good default?
fi
fi
fi
fi
rm -f curses curses.o curses.c
echo -n "$CURSES "
echo '(detected) '
else
echo -n "$CURSES "
echo '(cached) '
fi
echo -n "Testing for the readline library: "
if [ "$READLINE" = "" ]
then
echo 'main(){readline();}' >rd.c
if ${CCC} -o rd.out rd.c -lreadline >/dev/null 2>&1
then echo '-lreadline (detected)'
READLINE="-DUSE_READLINE=1 -lreadline"
else if ${CCC} -o rd.out rd.c -lreadline $CURSES >/dev/null 2>&1
then echo "-lreadline $CURSES (detected)"
READLINE="-DUSE_READLINE=1 -lreadline $CURSES"
else echo "no (detected)"
READLINE=""
fi
fi
else
echo -n "$READLINE "
echo '(cached) '
fi
rm -f rd.c rd.out
fi
if [ "$EXE" = "" ]
then echo "Executables need .exe suffix? no (detected)"
else echo "Executables need .exe suffix? yes (detected)"
fi
TRUE=/bin/true
if [ ! -x $TRUE ]
then TRUE=/usr/bin/true
echo "Found /usr/bin/true not /bin/true"
fi
else # do the following only in binary distributions
if [ -f lib/$MACHINE/config ]
then
. lib/$MACHINE/config
echo "Your binary distribution of hmake was built by $BUILDWITH."
else
echo "ERROR: Your distribution of hmake has no sources and no executables!"
exit 1
fi
# compiler detection deferred from earlier because of BUILDWITH variable
echo "--------"
script/confhc $BUILDWITH
echo "--------"
sh targets/$MACHINE/hmake3.config # ...and setup an hmakerc file
fi
echo
if [ "$INSTALL" = "no" ]
then
if [ -d src ] # Don't overwrite config if unpacking binary distribution!
then
echo "Adding Makefile config script to"
echo " $BUILDLIBDIR/$MACHINE..."
( echo "BUILDWITH=$BUILDWITH";
echo "BUILDOPTS=\"$BUILDOPTS\"";
echo "INSTALLVER=\"$HMAKEVERSION\"";
echo "INSTALLINFO=\"$INSTALLINFO\"";
echo "BUILDBASEDIR=$BUILDDIR";
echo "READLINE=\"$READLINE\"";
echo "EXE=$EXE";
echo "GHCSYM=`cat targets/$MACHINE/ghcsym || true`";
echo "TRUE=$TRUE";
) >$BUILDLIBDIR/$MACHINE/config
echo "Adding build scripts for hmake, hmake-config, and hi to"
echo " $BUILDBINDIR..."
sed -e "s|ExecutableDir|$BUILDLIBDIR|" script/hmake.inst |\
sed -e "s|ConfDir|$BUILDLIBDIR|" |\
sed -e "s|InstallVer|$HMAKEVERSION|" |\
sed -e "s|^BUILTBY=$|BUILTBY=${BUILDWITH}|" |\
sed -e "s|ScriptDir|$BUILDBINDIR|" >$BUILDBINDIR/hmake
sed -e "s|ExecutableDir|$BUILDLIBDIR|" script/hmake-config.inst |\
sed -e "s|ConfDir|$BUILDLIBDIR|" |\
sed -e "s|ScriptDir|$BUILDBINDIR|" >$BUILDBINDIR/hmake-config
sed -e "s|ExecutableDir|$BUILDLIBDIR|" script/hi.inst |\
sed -e "s|ConfDir|$BUILDLIBDIR|" |\
sed -e "s|InstallVer|$HMAKEVERSION|" |\
sed -e "s|ScriptDir|$BUILDBINDIR|" >$BUILDBINDIR/hi
chmod +x $BUILDBINDIR/hmake $BUILDBINDIR/hmake-config $BUILDBINDIR/hi
# For Debian we do this at install time
# echo "Updating targets/$MACHINE/hmake3.config..."
# echo "$BUILDBINDIR/hmake-config $BUILDLIBDIR/$MACHINE/hmakerc \
# default $BUILDWITH" >>targets/$MACHINE/hmake3.config
fi
else # [ "$INSTALL" = "yes" ]
echo "Installation directories are now created/checked."
echo "Install directory root is:"
echo " $DESTDIR$INSTALLDIR"
if [ "$BIN" = "yes" ]
then
echo "Scripts go into:"
echo -n " $DESTDIR$BINDIR"
if [ ! -d $DESTDIR$BINDIR ]
then mkdir -p $DESTDIR$BINDIR; echo ' (created)'
else echo ' (exists)'
fi
echo -n " harch "
cp script/harch $DESTDIR$BINDIR
echo -n "hmake "
sed -e "s|ExecutableDir|$LIBDIR|" script/hmake.inst |\
sed -e "s|ConfDir|$CONFDIR|" |\
sed -e "s|InstallVer|$HMAKEVERSION|" |\
sed -e "s|^BUILTBY=$|BUILTBY=${BUILDWITH}|" |\
sed -e "s|ScriptDir|$BINDIR|" >$DESTDIR$BINDIR/hmake
echo -n "hmake-config "
sed -e "s|ExecutableDir|$LIBDIR|" script/hmake-config.inst |\
sed -e "s|ConfDir|$CONFDIR|" |\
sed -e "s|ScriptDir|$BINDIR|" >$DESTDIR$BINDIR/hmake-config
echo -n "hi "
sed -e "s|ExecutableDir|$LIBDIR|" script/hi.inst |\
sed -e "s|ConfDir|$CONFDIR|" |\
sed -e "s|InstallVer|$HMAKEVERSION|" |\
sed -e "s|ScriptDir|$BINDIR|" >$DESTDIR$BINDIR/hi
echo
chmod a+rx $DESTDIR$BINDIR/hmake $DESTDIR$BINDIR/harch $DESTDIR$BINDIR/hi
chmod a+rx $DESTDIR$BINDIR/hmake-config
else
echo 'Not (re-)installing scripts'
fi
if [ "$LIB" = "yes" ]
then
echo "Executables and object lib files go into:"
echo -n " $DESTDIR$LIBDIR/$MACHINE"
if [ ! -d $DESTDIR$LIBDIR/$MACHINE ]
then mkdir -p $DESTDIR$LIBDIR/$MACHINE; echo ' (created)'
else echo ' (exists)'
fi
echo -n " "
for file in $BUILDLIBDIR/$MACHINE/*
do
echo -n "`basename $file` "
if [ -f $file ]; then cp -p $file $DESTDIR$LIBDIR/$MACHINE; fi
done
echo
echo "Conf files go into:"
echo -n " $DESTDIR$CONFDIR/$MACHINE"
if [ ! -d $DESTDIR$CONFDIR/$MACHINE ]
then mkdir -p $DESTDIR$CONFDIR/$MACHINE; echo ' (created)'
else echo ' (exists)'
fi
cp $DESTDIR$LIBDIR/$MACHINE/runhs $DESTDIR$BINDIR
mv $DESTDIR$LIBDIR/$MACHINE/hmakerc $DESTDIR$CONFDIR/$MACHINE || true
echo
else
echo 'Not (re-)installing executables and library files'
fi
if [ "$MAN" = "yes" ]
then
echo "Man pages go into:"
echo -n " $DESTDIR$MANDIR"
if [ ! -d $DESTDIR$MANDIR ]
then mkdir -p $DESTDIR$MANDIR; echo ' (created)'
else echo ' (exists)'
fi
for file in man/*
do
echo -n " `basename $file` "
cp $file $DESTDIR$MANDIR
done
echo
else
echo 'Not (re-)installing man pages'
fi
fi
echo "Saving current configuration in targets/$MACHINE/config.cache"
( echo "INSTALLDIR=$INSTALLDIR" ;
if [ "$LIBDIR" != "$INSTALLDIR/lib/hmake" ]; then echo "LIBDIR=$LIBDIR" ; fi;
if [ "$CONFDIR" != "$LIBDIR" ]; then echo "CONFDIR=$CONFDIR" ; fi;
if [ "$MANDIR" != "$INSTALLDIR/man/man1" ]; then echo "MANDIR=$MANDIR" ; fi;
if [ "$BINDIR" != "$INSTALLDIR/bin" ]; then echo "BINDIR=$BINDIR" ; fi;
if [ "$HBCDIR" != "" ]; then echo "HBCDIR=$HBCDIR" ; fi;
if [ "$GHCDIR" != "" ]; then echo "GHCDIR=$GHCDIR" ; fi;
echo "BUILDWITH=$BUILDWITH" ;
echo "BUILDOPTS=\"$BUILDOPTS\"" ;
echo "BUILDDIR=$BUILDDIR" ;
echo "LIB=$LIB" ;
echo "BIN=$BIN" ;
echo "MAN=$MAN" ;
echo "EXE=$EXE" ;
echo "READLINE=\"$READLINE\"" ;
echo "INSTALLVER=\"$HMAKEVERSION\"" ;
echo "INSTALLINFO=\"$INSTALLINFO\"" ;
) >targets/$MACHINE/config.cache
echo "Done."
if [ "$INSTALL" = "yes" ]
then
echo
echo " Please ensure $BINDIR is in your PATH variable."
fi
echo
exit 0
|