#! /bin/sh

# $Id: configure,v 1.380 2006/05/02 12:53:17 mdw Exp $

# This builds a configuration for CCP4 installation based on the value
# of an argument which is meant to describe a supported system.  On
# the basis of it we have to establish the necessary directories and
# build makefiles in the appropriate places from the skeletons in the
# master source area.  It's (obviously!) inspired by the GNU
# configuration scripts.

# The default values of the makefile variables (CC etc.) decided
# according to the system type, can be overridden by values defined in
# the environment or, in the case of the binary, library and master
# source directories, by optional arguments.  These variables are:
#   RANLIB, FC, XFFLAGS, CC, XCFLAGS, FOPTIM, COPTIM, LNS, M4,
#   SETFLAGS, MAKE, XLDFLAGS, CXX, XCXXFLAGS, CXXOPTIM
# See below for an explanation of unconventional ones.

# We also check the supplied values of the environment variables which
# must be defined to run ccp4 (for path names etc.) and create the
# necessary directories if they don't already exist.  The following
# environment variables seem to be essential for *running* the code
# (as deduced from calls to `getenv' and `UGTENV'): BINSORT_SCR,
# CINCL, HOME, CCP4_OPEN, CLIBD, CCP4_SCR, CCP4_HELPDIR (used by
# mosflm), PUBLIC_FONT84

# A design aim is to be able to support different configurations
# painlessly by allowing building and subsequent installation to occur
# independently and in random directories.  The source is maintained
# in a master directory, probably shared over NFS.  For each system
# one can start with a clean directory in which this script is run
# with the system name and source directroy as arguments after setting
# the appropriate environment variables e.g.,
# configure irix --src=/nfs/dlpx1/home/xtal/ccp4 --bin=/priv9/pxbin
# This will make appropriate sub-directories in which everything can
# be built (with a simple `make' at the top level) and from which the
# programs can be run for test purposes.  `make install' will copy the
# results to the production directories for the appropriate system
# once it checks out OK.

# Fixme: check compiler and OS versions somehow against ones we're
# sure about...  (We should allow qualification of the system e.g.,
# sun-sunos4.1, and can arrange regexp matching in the cases.)  Can
# the OS be checked reliably? (uname?  not on alliant -- uv there?)

set -e 2>/dev/null    # not sure whether this still gives an
                                # error message with old sh... 

###
###   CCP4 licensing and conditions.
###
### Removing or attempting to bypass this section in the configure script 
### is deemed as agreeing to the conditions outlined in $CCP4/conditions.txt
### unless the --onlylibs flag is passed.


agreed=no
ans=n

# changed this just in case the system does not have whoami. 
# Now defaults to $USER
user=${USER}
if test ! "$user" ; then
    user=`whoami`
fi


# if --onlylibs has been specified, then set agreed to yes
# (a bit of a kludge, but it does the job).
for arg in $*
do 

    case $arg in
      -onlylibs | --onlylibs | --onlylib)
	agreed=yes
    ;;
    esac
done

### has someone else (we know about) agreed to the ccp4 conditions before?
### and if so make sure the the home dir has agreement file
if test -f .agree2ccp4v6; then
   eval touch ${HOME}/.agree2ccp4v6;
   if test -w .agree2ccp4v6; then 
     echo $user `date` "V6.0" >> .agree2ccp4v6;   
     agreed=yes
   fi
   if test -w ${HOME}/.agree2ccp4v6; then
     echo $user `date` "V6.0" >> ${HOME}/.agree2ccp4v6;
   fi
fi

### has the user agreed to the ccp4 condition's before?
if test $agreed = "no"; then
   if test -f ${HOME}/.agree2ccp4v6; then
     eval touch .agree2ccp4v6
     if test -w ${HOME}/.agree2ccp4v6; then
       echo $user `date` "V6.0" >> ${HOME}/.agree2ccp4v6;
     fi
     if test -w .agree2ccp4v6; then 
       echo $user `date` "V6.0" >> .agree2ccp4v6;   
     fi
     agreed=yes
   fi 
fi

### so if this site, as far as we know has never agreed to ccp4 
### conditions then they must!

if test $agreed = "no"; then

  echo ; echo ;

  if test -r conditions.txt; then
     echo ; echo ; echo "Please read the following"; echo ;
     more conditions.txt ;
     echo ;
     echo -n "          y/n [n] ?:";

     read ans ;
     if test x$ans = x; then 
       ans="n"
     fi

     if test $ans = "y"; then 
       eval touch ${HOME}/.agree2ccp4v6;
       if test -w ${HOME}/.agree2ccp4v6; then
         echo $user `date` "V6.0" > ${HOME}/.agree2ccp4v6;
       else
         echo "  No record of you agreeing to the CCP4 license conditions";
         echo "  has been kept in your home area.";
       fi
       echo $user `date` "V6.0" > .agree2ccp4v6;
       chmod ugo+rw .agree2ccp4v6 ;   
       agreed=yes ;
       echo ; echo ; echo " Thank you. The CCP4 configure will now run as normal.";
# remove old .agree2ccp4 files
       if test -f .agree2ccp4; then
         rm -f .agree2ccp4
       fi
       if test -f ${HOME}/agree2ccp4; then
         rm -f ${HOME}/.agree2ccp4
       fi
     fi
  else
    echo " The file conditions.txt in the $CCP4 directory could not be found" 
    echo " Please download or contact ccp4@ccp4.ac.uk" ; echo ; echo;
    exit 1
  fi
fi

if test $agreed = "no"; then
    echo ; echo ; echo " You have indicated that you do not agree to the conditions";
    echo " of use for the CCP4 package. Please delete all CCP4 software";
    echo " from your system. If you have any further queries please refer ";
    echo " to the CCP4 web pages on http://www.ccp4.ac.uk/ or contact" ;
    echo " ccp4@ccp4.ac.uk";
    exit 1
fi

### End of licensing section.

usage='echo "Usage: configure [--help] [--srcdir=DIR] [--bindir=DIR]
       [--libdir=DIR] [--onlylibs] [--tmpdir=DIR] [--with-f2c] [--disable-x]
       [--with-shared-libs] [--non_shared] [--with-rxdispencer] [--disable-ccif] 
       [--disable-lapack] [--with-netlib-lapack] [--with-warnings] 
       [--disable-mapslicer] [--disable-fftw] [--with-fftw=DIR] 
       [--disable-clipper] [--disable-ssm][--disable-pdb_extract] 
       [--disable-cctbx] [--disable-phaser] SYSTEM";
  echo "where SYSTEM is one of:";
  echo "  irix irix64 sunos sunos64 aix hpux osf1 linux freebsd";
  echo "  linux_compaq_compilers linux_intel_compilers generic Darwin";
  echo "  ia64_linux_intel Darwin_ibm_compilers linux_ibm_compilers";
  echo "Use uname -a to determine system type if you are unsure which to use.";
  exit 1'

### parse the arguments; `--' flags can be abbreviated and `=' can be
### replaced by whitespace

# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'      
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits

# these made null if not interested in building the src directory:
src=src ; dotsrc=./src ;
if test -d unsupported/src; then
  unsupp=unsupported/src; dotunsupp=./unsupported;
  dotunsuppsrc=./unsupported/src
else true
fi
if test -d x-windows; then
  xwindir=x-windows ; dotxwindir=./x-windows ;
else true
fi
if test -d x-windows/Rotgen; then
  rotgendir=x-windows/Rotgen ;
else true
fi
if test -d x-windows/Mosflm; then
  mosflmdir=x-windows/Mosflm ;
else true
fi

for arg
do
  # Handle --bindir (etc.) with a space before the argument.
  if test x$next_bindir = xyes; then bindir=$arg; next_bindir=
  elif test x$next_libdir = xyes; then libdir=$arg; next_libdir=
  elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
  elif test x$next_tmpdir = xyes; then TMPDIR=$arg 
  else

    case $arg in
    -help | --help | -h | help)
      eval $usage;;

    -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=* | --b=*)
      bindir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
    -bindir | --bindir | --bindi | --bind | --bin | --bi | --b)
      next_bindir=yes ;;

    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
      srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
      next_srcdir=yes ;;

    -libdir=* | --libdir=* | --libdi=* | --libd=* | --lib=* | --li=* | --l=*)
      libdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
    -libdir | --libdir | --libdi | --libd | --lib | --li | --l)
      next_libdir=yes ;;

    -onlylibs | --onlylibs | --onlylib | --onlyli | --onlyl | --onlyl | --only | \
      --onl | --on | --o)
      src= ; dotsrc= ; unsupp= ; dotunsupp= ; dotunsuppsrc= ; 
      disable_mapslicer=yes ; disable_pdb_extract=yes ; disable_x=yes
      disable_phaser=yes
      onlylibs=yes ;;

    -tmpdir=* | --tmpdir=* | --tmpdi=* | --tmpd=* | --tmp=* | --tm=* | t=*)
      tmpdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;

    -with-f2c | --with-f2c  | --with-f2  | --with-f)
      FC=fort77; XFFLAGS=${XFFLAGS:-'-Nx400'}; FOPTIM=${FOPTIM:-"-O"}; with_f2c=1;
      SETFLAGS=${SETFLAGS:-""}
      ;;

    -with-shared-libs | -with-shared-lib | \
      --with-shared-libs | --with-shared-lib | --with-shared-li | \
      --with-shared-l | --with-shared- | --with-share | --with-sha | \
      --with-sh | --with-s)
      shared_lib=yes
      ;;

    -ww | -w-w | -with-warnings | -with-w | -w-warnings | \
      --ww | --w-w | --with-warnings | --with-w | --w-warnings)
      warnings=yes
      ;;

    -with-rxdispencer | --with-rxdispencer)
      with_rxdispencer=yes
      ;;

    -disable-ccif | --disable-ccif)
      disable_ccif=yes
      ;;

    -disable-cctbx | --disable-cctbx)
      disable_cctbx=yes
      ;;
 
    -disable-phaser | --disable-phaser)
      disable_phaser=yes
      ;;

    -disable-lapack | --disable-lapack)
      disable_lapack=yes
      ;;

    -with-netlib-lapack | --with-netlib-lapack)
      with_netlib_lapack=yes
      ;;

    -disable-mapslicer | --disable-mapslicer)
      disable_mapslicer=yes
      ;;

    -disable-pdb_extract | --disable-pdb_extract)
      disable_pdb_extract=yes
      ;;
 
    -disable-x | --disable-x)
      disable_x=yes
      ;;
 
    -non_shared | --non_shared)
      non_shared=yes
      ;;

    -hush)      # only for use by config.status
      hush=1 ;;

  -with-* | --with-*)
    ac_package=`expr "x$arg" : 'x-*with-\([^=]*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid package name: $ac_package" >&2
   { (exit 1); exit 1; }; }
    ac_package=`echo $ac_package| sed 's/-/_/g'`
    case $arg in
      *=*) 
        ac_optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'`
        ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
      *) ac_optarg=yes ;;
    esac
    echo "with_$ac_package='$ac_optarg'"
    eval "with_$ac_package='$ac_optarg'" ;;

  -without-* | --without-*) 
    ac_package=`expr "x$arg" : 'x-*without-\(.*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid package name: $ac_package" >&2
   { (exit 1); exit 1; }; }
    ac_package=`echo $ac_package | sed 's/-/_/g'`
    eval "with_$ac_package=no" ;;

  -disable-* | --disable-*)
    ac_feature=`expr "x$arg" : 'x-*disable-\(.*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
   { (exit 1); exit 1; }; }
    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
    eval "enable_$ac_feature=no" ;;

  -enable-* | --enable-*)
    ac_feature=`expr "x$arg" : 'x-*enable-\([^=]*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
   { (exit 1); exit 1; }; }
    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
    case $arg in
      *=*) 
        ac_optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'`
        ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
      *) ac_optarg=yes ;;
    esac
    eval "enable_$ac_feature='$ac_optarg'" ;;

    -*)
      echo "Unrecognised option: $arg"
      eval $usage ;;

    *)
      if test -z "$system" ; then system=$arg
      else eval $usage ; fi ;;  # bad flag
    esac
  fi
done

# Check whether --enable-x or --disable-x was given.
if test "${enable_x+set}" = set; then
  enableval="$enable_shared"
    case $enableval in
    yes) enable_x=yes ;;
    no) enable_x=no ;;
    *) enable_x=yes ;;
    esac
else
  if test "${disable_x+set}" = set ; then
     enable_x=no
  else 
     enable_x=yes
  fi
fi;

#do some checking for system type
UNAME_ARCH=`(uname -m) 2>/dev/null` || UNAME_ARCH=unknown
UNAME_VERS=`(uname -r) 2>/dev/null` || UNAME_VERS=unknown
UNAME_OS=`(uname -s) 2>/dev/null`  || UNAME_OS=unknown

if test -z "$system" ; then
  case $UNAME_OS in
    IRIX ) system=irix ;;
    IRIX64 ) system=irix64 ;;
    HP-UX ) system=hpux ;;
    Linux ) system=linux ;;
    SunOS ) system=sunos ;;
    AIX ) system=aix ;;
    FreeBSD) system=freebsd ;;
    OSF1) system=osf1 ;;
    *) system=$UNAME_OS ;;
  esac
fi

test -z "$system" && eval $usage || true # system must be defined

case $system in
  Darwin | Darwin_ibm_compilers)
	;;
  *)
PWD=`pwd`     # not always defined
	;;
esac

srcdir=${srcdir:-$PWD}
bindir=${bindir:-$PWD/bin}
libdir=${libdir:-$PWD/lib}
configdir=${PWD}
test "$tmpdir"  && TMPDIR=${tmpdir}

echo srcdir bindir libdir $srcdir $bindir $libdir 

export libdir RANLIB FC F77 FOPTIM COPTIM XFFLAGS XCFLAGS CC LNS M4 M4FLAGS
export CXX XCXXFLAGS CXXOPTIM
export SETFLAGS MAKE F INSTALL_PROGRAM INSTALL_DATA XLDFLAGS TMPDIR

case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
  *c*,-n*) ECHO_N= ECHO_C='
' ECHO_T='      ' ;;
  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
esac

### First let's check that we know about the system.

# Any new system must be added in the following case block and in
# the big one later which handles each possibility.  These try to be
# generic operating system names rather than names of hardware.

case $system in
  hpux | irix | irix64 | aix | sunos | sunos64 | \
    osf1 | linux | linux64 | freebsd | gnu_win32 | \
    linux_ibm_compilers | linux64_ibm_compilers | \
    linux_compaq_compilers | linux_intel_compilers | generic | \
    Darwin | ia64_linux_intel | Darwin_ibm_compilers )
    echo "OK, setting up for a system type of \`$system'..."
    echo    ;;
  * )
    echo "! System type \`$system' isn't supported -- sorry."
    echo
    echo "If one of the following alternatives doesn't seem to be suitable,"
    echo "you'll have to modify \`configure' and the library files mentioned"
    echo "in the installation guide.  Please let ccp4@dl.ac.uk know of any"
    echo "changes you have to make:"
    echo "  irix irix64 sunos sunos64 aix hpux osf1 linux linux_ibm_compilers "
    echo "  linux_compaq_compilers linux_intel_compilers freebsd generic Darwin"
    echo "  ia64_linux_intel Darwin_ibm_compilers"
    exit 1    ;;
esac


# check for onlylibs
if test ! -z "$onlylibs" ; then
  echo "! onlylibs build requested"
  echo "!"
  echo "! Only the libraries will be configured and built."
  echo "! Configuration of x-windows programs, phaser and mapslicer"
  echo "! command library have been implicitly disabled."
  echo "! (Some messages below regarding re-enabling these options"
  echo "! are likely to be misleading.)"
fi
# check for f2c
if test -n "$with_f2c"; then
  echo
  echo "! Using f2c compiler.  (Needs the \`fort77' perl script and f2c later than 19940920.)"
  echo "! Make sure there is no symbolic link from fort77 to g77"
  echo "! \`fort77' comes from, e.g. ftp://sunsite.unc.edu/pub/Linux/devel/lang/fortran"
  echo ""
elif test "$system" = linux; then
  echo
  echo "! Using gnu fortran compiler.  If you have an old fortran compiler, you may be better"
  echo "! off using f2c, see --with-f2c option."
else true
fi
# check for xwin stuff
if test x"$enable_x" = xno; then
  echo
  echo "! The x-windows programs will not be installed."
  echo "! If you want the x-windows programs to be installed re-run"
  echo "! configure with the --enable-x flag."
else
  echo 
  echo " Will attempt to install the xwindows programs from \`$xwindir'."
  echo " This is not supported for all systems."
  echo "         ******** please note ************"
  echo " the xwindows programs will be compiled with an option"
  echo " that means errors are ignored. This could result in some"
  echo " xwindows programs not being compiled." 
  echo " If you want to disable the xwindows programs use --disable-x"
fi
# check for disabling of ccif
if test -n "$disable_ccif"; then
  echo 
  echo " Installation of the CCIF library has been suppressed."
  echo " Some functionality will be lost."
else
  echo 
  echo " The CCIF library will be built and installed."
  echo " This has been tested on the most common systems, but if "
  echo " you have problems, use the --disable-ccif flag."
fi
# check for disabling of cctbx
if test -n "$disable_cctbx"; then
  echo 
  echo " Installation of the CCTBX library has been suppressed."
  echo " Some functionality will be lost."
else
  echo 
  echo " The CCTBX library will be built and installed."
  echo " If you have problems, use the --disable-cctbx flag."
fi
# check for disabling of phaser
if test -n "$disable_phaser"; then
  echo 
  echo " Installation of Phaser has been suppressed."
else
  if test -n "$disable_cctbx"; then
    echo 
    echo " Phaser cannot be built without the CCTBX library."
    echo " Installation of Phaser has been suppressed."
    disable_phaser=yes
  else
    echo 
    echo " Phaser will be built and installed."
    echo " If you have problems, use the --disable-phaser flag."
  fi
fi
# check for disabling of lapack
if test -n "$disable_lapack"; then
  echo
  echo " Inclusion of the LAPACK linear algebra package has been suppressed."
  echo " Some programs may not build and the installation may fail."
else
  echo
  echo " The LAPACK linear algebra package will be included in the installation."
  if test ! "$with_netlib_lapack"; then
    echo " Configure will search for existing LAPACK and BLAS libraries on"
    echo " on your system - if a version of LAPACK is not found then the NetLib"
    echo " version will be built for you automatically."
    echo " If you want NetLib LAPACK and BLAS to be used regardless of"
    echo " system libraries then rerun configure using --with-netlib-lapack"
  else
    echo " Netlib LAPACK and BLAS will be built automatically, regardless of"
    echo " other versions which might be available on your system."
    echo " Using Netlib BLAS may result in poorer performance of the LAPACK"
    echo " functions - to search for system-specific versions rerun configure"
    echo " without the --with-netlib-lapack flag."
  fi
  echo
  echo " To disable inclusion of LAPACK, use the --disable-lapack flag"
  echo " (This is not recommended as some programs will fail to build)"
fi
# Check for disabling of mapslicer command library
if test -n "$disable_mapslicer"; then
  echo
  echo " Building of the CCP4i MapSlicer command library has been suppressed."
  echo " As a result you will not be able to use the MapSlicer viewer."
else
  echo
  echo " Configure will try to set up and build the CCP4i MapSlicer command"
  echo " library, which is required to use the MapSlicer viewer."
  echo " ***** This may not be possible for some systems! *****"
  echo " To disable inclusion of the MapSlicer command library, use the"
  echo " --disable-mapslicer flag"
fi
# Check for non_shared option (OSF1/Linux/sunos)
if test -n "$non_shared"; then
  echo
  echo " You have requested a non-shared build (--non_shared)."
  # Only available for OSF1 or Linux or sunos
  case $system in
    osf1 | linux | sunos )
    if test "$shared_lib" = yes; then
      echo " ***** This option isn't compatible with --with-shared-libs ***** "
      echo " Rerun configure using only one of these options."
      exit 1
    fi
    echo " Executables will be built using the -non_shared or -static or -Bstatic"
    echo " compiler flag. This will result in more portable (but much larger)"
    echo " executables."
    echo "                  ****** WARNING ******"
    echo " Some system libraries may only be available as shared libraries"
    echo " for example X window libraries."
    echo " Using --non_shared on these systems may cause the build to fail"
    echo    ;;
  * )
    echo "***** --non_shared isn't supported for sytem type \`$system' *****"
    exit 1    ;;
  esac
fi
### Check the values of the necessary environment variables

badvar=0      # set true if any of the checks fail

# fixme: do we need to check BINSORT_MEM?
# Yes you do.
if test -z "$onlylibs" ; then 
for i in BINSORT_SCR CCP4_SCR CINCL CLIBD CCP4_OPEN PUBLIC_FONT84 \
  # BINSORT_MEM
do
  if ( eval test -z \"\$$i\" ) ; then
    echo "! Please set environment variable $i (see installation instructions)."
    badvar=1
  else true
  fi
done
fi

test $badvar -eq 1 && exit 1 || true

### establish the necessary directories for building and installing
### and check that a scratch directory can be created

# shorthand for a warning needed in some cases:
# syswarn() {
#     echo
#     echo "! Beware -- the $system installation isn't properly tested." ; }
syswarn='echo; echo "! Beware -- the $system installation is not properly tested."'

if test -z "$onlylibs" ; then 
   for i in CCP4_SCR BINSORT_SCR; do
     if ( eval test -d \$$i || eval mkdir -p \$$i ) ; then :
     else
       eval echo "! No directory \$$i and can\'t create it."
       echo "  Check the value of $i."
       badvar=1
     fi
   done

   for i in libdir bindir; do
     if ( eval test -d \$$i || eval mkdir -p \$$i ) ; then :
     else
       eval echo "! No directory \$$i and can\'t create it."
       echo "  Check the argument of --$i."
       badvar=1
     fi
   done

   for i in $dotsrc $dotunsupp $dotunsuppsrc ./lib ./lib/src ./lib/data ./ccp4i/etc/unix $mosflmdir/lib $mosflmdir/bin $mosflmdir/cbf/lib ; do
     if test -d $i || mkdir $i; then :
     else
       eval echo "! No directory $i and can\'t create it."
       badvar=1
     fi
   done
else
   # Kludge to fool the "Makefile" target in the top-level CCP4
   # Makefile into not trying to remake src/Makefile.in
   for i in $srcdir/src $srcdir/lib/src ; do
     if test -d $i || mkdir $i; then
       if ! test -f $i/Makefile.in ; then
         echo
         echo "onlylibs: making dummy file $i/Makefile.in"
	 touch $i/Makefile.in
       fi
     fi
   done
fi

### sanity checks

badvar=0
if test ! -f $srcdir/lib/src/ccplib.f ; then
  echo "! $srcdir/lib/src/ccplib.f doesn't exist."
  echo "  Check the value of the --srcdir flag."
  badvar=1
else true
fi

if test -z "$onlylibs" ; then 
    if touch $BINSORT_SCR/binsort$$ ; then
       rm $BINSORT_SCR/binsort$$
    else
       echo "! Can't create $BINSORT_SCR/binsort$$."
       echo "  Check the value of BINSORT_SCR."
       badvar=1
    fi
    test $badvar -eq 1 && exit 1 || true
fi

### Do specific things for each possible system.  Note we preserve any
### supplied values of the variables with the ${...:-...} mechanism.

if test ! "$hush" ; then
  if test "${FC}" && test -z "$with_f2c"; then
    echo "! You have specified a non-default Fortran compiler ($FC)."
    echo "  This probably only makes sense if you have made the appropriate"
    echo "  changes to the Fortran-C interface routines."
  else true
  fi
else true
fi

# if configure run by config.status dont adding warning flags again.
test "$hush" = 1 && warnings=yes || true

LDFLAG='-L$(LIB_DIR)'   # overridden only for alliant

### To add a new system, see the explanation of variables below

case $system in
irix)     # tested in 4.0.{1,5}, probably ok in 3.3
  RANLIB=${RANLIB:-:}
  test "$with_f2c" && M4=${M4-"m4 -D_f2c=1"}
  # fixme: this ought to test the *compiler* version (using `versions')
  case `uname -rs` in
  IRIX\ 4.0*)
  # more nested loops (?), optimise larger routines, use shared
  # libraries -- no provision for parallelisation, try to trap
  # undefined variables, don't want to waste time with cpp
# fixme: -trapuv causing havoc due to undefined variables -- should be
# put back after fixing as many as poss.
#    XFFLAGS=${XFFLAGS:-"-Nc45 -Olimit 1500 -share_all -trapuv -nocpp"}
    XFFLAGS=${XFFLAGS:-"-Olimit 1500 -nocpp"}
#    XLDFLAGS=${XLDFLAGS:-"-lfpe"} # to enable floating point traps
    # -Nq for `too many equivalences' (??)
    SETFLAGS=${SETFLAGS:-"amore_FLAGS='-O1 -Nq2500 -nocpp'"}
#   Xwindows variables set if wanted or not!
    XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
    XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
    XTYPE=${XTYPE:-"IRIX_4"}
  ;;
  IRIX\ 5.*)
    # apparently this is OK for the new SysVile.4-based OS (but don't
    # try to share irix4 libraries, at least)
    XFFLAGS=${XFFLAGS:-"-Olimit 1500 -nocpp -w -Wf,-I${srcdir}/lib/src"}
    XCFLAGS=${XCFLAGS:-"-DPROTOTYPE -w"}
    FOPTIM=${FOPTIM:-"-O2"}
    F_LIBS=${F_LIBS:-"-lftn"}
    CXX_LIBS=${CXX_LIBS:-"-lC"}
    XLDFLAGS=${XLDFLAGS:-"-lm"} 
    # Xwindows variables set if wanted or not!
    XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
    XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
    XTYPE=${XTYPE:-"IRIX_5"}
    # -Nq for `too many equivalences' (??)
    # sopt was broken in v4.  You might think it would help here, but it's
    # a loss, for some reason
    SETFLAGS=${SETFLAGS:-"amore_FLAGS='-O1 -Nq2500 -nocpp' \
                sftools_FLAGS='$XFFLAGS $FOPTIM -Nq3000' \
                 detwin_FLAGS='$XFFLAGS $FOPTIM -static' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' "}
    # we need to worry about rewinding scratch files with 5.1 fortran
    # (and apparently also with 5.2):
    M4=${M4:-"m4 -D_sgi=1 -D_irix51=1"}
    if test "$shared_lib" = yes; then
      SHARE_LIB=${SHARE_LIB:-'ld -shared -all libmmdb.a -o libmmdb.so; ld -shared -all libccp4c.a -o libccp4c.so; ld -shared -all libccp4f.a -o libccp4f.so'}
      SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so'
      XCFLAGS="$XCFLAGS -rpath $CLIB"
      XFFLAGS="$XFFLAGS -rpath $CLIB"
    fi
    case `uname -sr` in
    IRIX\ 5.1*)
      echo "! Beware -- f77 in Irix5.1 is supposed to be badly broken"
      ;;
    esac
    ;;
  IRIX64\ 6.*|IRIX\ 6.*)
    echo "* SGI machines with IRIX6.* can run either 32 or"
    echo "* 64-bit compiled programs."
    echo "* With the system option irix the code will compile under "
    echo "* the 32-bit option."
    echo "* NB for pre-6.5 systems this will be -(o)32 (old API)"
    echo "*    for IRIX6.5 it will be -n32 (new API)."
    echo "*    Please note that the two APIs are not compatible."
    echo "* For R2000/R3000 you may need to add -mips1."
    echo "* If you have IRIX 6.3 or above and want to try the 64 bit"
    echo "* compilation run configure again with the system choice irix64."
    echo "* This is not tested on systems running irix6.2 or below."
    echo 
#
    case `uname -sr` in
    IRIX64\ 6.0*|IRIX\ 6.0*)
      # This is said to work on unknown Irix6 minor version by
      # george@tusk.med.harvard.edu (George Planansky)
      XFFLAGS=${XFFLAGS:-"-32 -nocpp"}
      XCFLAGS=${XCFLAGS:-"-32 -DPROTOTYPE"}
      XCXXFLAGS=${XCXXFLAGS:-"-32"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"} 
      FOPTIM=${FOPTIM:-"-O2"}
      # -Nq still needed in 6.01, apparently, but not later versions.
      SETFLAGS=${SETFLAGS:-"amore_FLAGS='$XFFLAGS -Nq2500' \
                sftools_FLAGS='$XFFLAGS $FOPTIM -Olimit 1250 -Nq3000' \
                 detwin_FLAGS='$XFFLAGS $FOPTIM -static' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' "}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.1*|IRIX\ 6.1*)
      # -lfpe no longer exists - replacement sought.
      # tnearnest@LBL.Gov (Thomas Earnest) following SGI rep. says for 6.1:
      # Heaven knows how you're supposed to trap FPEs...
      XFFLAGS=${XFFLAGS:-"-32 -nocpp "}
      XCFLAGS=${XCFLAGS:-"-32 -DPROTOTYPE"}
      XCXXFLAGS=${XCXXFLAGS:-"-32"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      # Or use -O3 for agressive optimisation.
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.2*|IRIX\ 6.2*)
      XFFLAGS=${XFFLAGS:-"-32 -w -nocpp"}
      XCFLAGS=${XCFLAGS:-"-32 -w -DPROTOTYPE"}
      XCXXFLAGS=${XCXXFLAGS:-"-32"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      # Or use -O3 for agressive optimisation.
      FOPTIM=${FOPTIM:-"-O2 -Olimit 3000"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.3*|IRIX\ 6.3*)
      # e.g. O2's
      XFFLAGS=${XFFLAGS:-"-32 -w -nocpp"}
      XCFLAGS=${XCFLAGS:-"-32 -w -DPROTOTYPE"}
      XCXXFLAGS=${XCXXFLAGS:-"-32"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.4*|IRIX\ 6.4*)
      # e.g. Origin200
      XFFLAGS=${XFFLAGS:-"-32 -w -nocpp"}
      XCFLAGS=${XCFLAGS:-"-32 -w -DPROTOTYPE"}
      XCXXFLAGS=${XCXXFLAGS:-"-32"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6_4"}
      ;;
    IRIX64\ 6.5*|IRIX\ 6.5*)
      XFFLAGS=${XFFLAGS:-" -nocpp"}
      XCFLAGS=${XCFLAGS:-" -DPROTOTYPE"}
      CXXOPTIM=${CXXOPTIM:-"-O"}
      XCXXFLAGS=${XCXXFLAGS:-"-LANG:std "}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Shared libraries only if requested
      if test "$shared_lib" = yes; then
        SHARED_LIB_FFLAGS=${SHARED_LIB_FFLAGS-' '}
        SHARED_LIB_CFLAGS=${SHARED_LIB_CFLAGS-' '}
        SHARE_LIB=${SHARE_LIB-'ld  -shared -all libmmdb.a -o libmmdb.so; ld -n32  -shared -all libccp4c.a -o libccp4c.so; ld -n32  -shared -all libccp4f.a -o libccp4f.so'}
      fi
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6_5"}
      if test ! "$warnings" = yes; then
	  XFFLAGS="-w $XFFLAGS" 
	  XCFLAGS="-w $XCFLAGS"
          XCXXFLAGS="-w $XCXXFLAGS"
      fi
      SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM ' \
               detwin_FLAGS='$XFFLAGS $FOPTIM -static' \
               sfcheck_FLAGS='$XFFLAGS $FOPTIM' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' \
               molrep_FLAGS='$XFFLAGS $FOPTIM -static' \
               npo_FLAGS='$XFFLAGS -O1' "}
      # Set Mapslicer command library flags
      # These are the flags appropriate for Irix 6.5 (n32)
      MAPSLICER_SHARE=${MAPSLICER_SHARE:-"ld  -shared -all libccp4map.a -o libccp4map.so"}
      ;;
    IRIX64\ 7.*|IRIX\ 7.*)
      XFFLAGS=${XFFLAGS:-"-n32  -nocpp"}
      XCFLAGS=${XCFLAGS:-"-n32  -DPROTOTYPE"}
      CXXOPTIM=${CXXOPTIM:-"-O"}
      XCXXFLAGS=${XCXXFLAGS:-"-LANG:std -LANG:libc_in_namespace_std=off -n32 "}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}
      FOPTIM=${FOPTIM:-"-O2"}
      # Shared libraries only if requested
      if test "$shared_lib" = yes; then
        SHARED_LIB_FFLAGS=${SHARED_LIB_FFLAGS-'-n32 '}
        SHARED_LIB_CFLAGS=${SHARED_LIB_CFLAGS-'-n32 '}
        SHARE_LIB=${SHARE_LIB-'ld -n32  -shared -all libmmdb.a -o libmmdb.so; ld -n32  -shared -all libccp4c.a -o libccp4c.so; ld -n32  -shared -all libccp4f.a -o libccp4f.so'}
      fi
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_7"}
      if test ! "$warnings" = yes; then
          XFFLAGS="-w $XFFLAGS"
          XCFLAGS="-w $XCFLAGS"
          XCXXFLAGS="-w $XCXXFLAGS"
      fi
      SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM' \
               detwin_FLAGS='$XFFLAGS $FOPTIM -static' \
               sfcheck_FLAGS='$XFFLAGS $FOPTIM' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' \
               molrep_FLAGS='$XFFLAGS $FOPTIM -static' \
               npo_FLAGS='$XFFLAGS -O1' "}
      # Set Mapslicer command library flags
      # These are the flags appropriate for Irix 6.5 (n32)
      MAPSLICER_SHARE=${MAPSLICER_SHARE:-"ld -n32  -shared -all libccp4map.a -o libccp4map.so"}
      ;;
    *)
      XFFLAGS=${XFFLAGS:-"-32 -w -nocpp"}
      XCFLAGS=${XCFLAGS:-"-32 -w -DPROTOTYPE"}
      XCXXFLAGS=${XCXXFLAGS:-"-32 -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_5"}
      ;;
    esac
    SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM -Olimit 1250 -Nq3000' \
                 detwin_FLAGS='$XFFLAGS $FOPTIM -static' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' "}
    M4=${M4:-"m4 -D_sgi=1 -D_irix51=1"}
    if test "$shared_lib" = yes; then
      SHARED_LIB_FFLAGS=${SHARED_LIB_FFLAGS:-'-32'}
      SHARED_LIB_CFLAGS=${SHARED_LIB_CFLAGS:-'-32'}
      SHARE_LIB=${SHARE_LIB:-'ld -32 -shared -all libmmdb.a -o libmmdb.so; ld -32 -shared -all libccp4c.a -o libccp4c.so; ld -32 -shared -all libccp4f.a -o libccp4f.so'}
      SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so'
      XCFLAGS="$XCFLAGS -rpath $CLIB"
      XFFLAGS="$XFFLAGS -rpath $CLIB"
      XCXXFLAGS="$XCXXFLAGS -rpath $CLIB"
    fi
    # Set Mapslicer command library flags
    # These flags are appropriate for o32 Irixes
    MAPSLICER_SHARE=${MAPSLICER_SHARE:-"ld -32 -shared -all libccp4map.a -o libccp4map.so"}
    ;; 
  IRIX*)
    XFFLAGS=${XFFLAGS:-"-32 -Olimit 1500  -nocpp"}
 #   XLDFLAGS=${XLDFLAGS:-"-lfpe"} # to enable floating point traps
    # Xwindows variables set if wanted or not!
    XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
    XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
    XTYPE=${XTYPE:-"IRIX_6_5"}
    echo "! Beware -- this is a substantially different OS version to those tested"
    ### Mapslicer flags for Irix can go here - this section is
    ### for an older version of Irix so no shared build
    MAPSLICER_SHARE=${MAPSLICER_SHARE:-""}
    ;;
  *)
     echo "! This doesn't appear to be an IRIX system.
  you should run configure on a machine of the correct type."
     exit 1 ;;
  esac
  # Each version of the irix compiler seems to bring a different set
  # of optimisation problems, some of which we probably never find out
  # about.  The default optimisation seems to be the best thing to go
  # with.  Maybe you can win in some cases by using -O2, caveat emptor...
  FOPTIM=${FOPTIM:-""}
  M4=${M4:-"m4 -D_sgi=1"}
  CXX=${CXX:-"CC"}
  XCXXFLAGS=${XCXXFLAGS:-" "}
  # compiler specific options
  case `$CXX -dumpversion` in
    MIPSpro\ Compilers\ 7.4* ) XCXXFLAGS="$XCXXFLAGS -LANG:libc_in_namespace_std=off" ;;
    * ) 
  esac
  ;;
irix64)     
# new option added to allow users to have 64bit compilatioins.
  RANLIB=${RANLIB:-:}
  test "$with_f2c" && M4=${M4:-"m4 -D_f2c=1"}
  # fixme: this ought to test the *compiler* version (using `versions')
  case `uname -rs` in  IRIX64\ 6.*|IRIX\ 6.*)
    echo "* IRIX6.* can run on 32 or 64-bit machines."
    echo "* You have chosen to compile the suite as 64 bit code. "
    echo "* 32 bit SGI machines will not be able to run 64 bit programs."
    echo "* The 64 bit compilation is relativley untested especially on "
    echo "* irix6.2 and below."
    echo "* Please report problems or changes to ccp4@dl.ac.uk."
# 02-02-00: replacing mips4 with mips3 ... this might mean some loss of
# performance for some systems, but will result in more portable executable code.
    case `uname -sr` in
    IRIX64\ 6.0*|IRIX\ 6.0*)
      # This is said to work on unknown Irix6 minor version by
      # george@tusk.med.harvard.edu (George Planansky)
      echo "\n* Warning this option is not tested *\n"
      XFFLAGS=${XFFLAGS:-"-64  -nocpp-w"}
      XCFLAGS=${XCFLAGS:-"-64  -DPROTOTYPE -w"}
      XCXXFLAGS=${XCXXFLAGS:-"-64  -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # -Nq still needed in 6.01, apparently, but not later versions.
      SETFLAGS=${SETFLAGS:-"amore_FLAGS='$XFFLAGS' \
                sftools_FLAGS='$XFFLAGS $FOPTIM' \
                 detwin_FLAGS='$XFFLAGS $FOPTIM -static' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static'"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.1*|IRIX\ 6.1*)
      # -lfpe no longer exists - replacement sought.
      # tnearnest@LBL.Gov (Thomas Earnest) following SGI rep. says for 6.1:
      # Heaven knows how you're supposed to trap FPEs...
      echo "\n* Warning this option is not tested *\n"
      XFFLAGS=${XFFLAGS:-"-64  -nocpp-w"}
      XCFLAGS=${XCFLAGS:-"-64  -DPROTOTYPE -w"}
      XCXXFLAGS=${XCXXFLAGS:-"-64  -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.2*|IRIX\ 6.2*)
      XFFLAGS=${XFFLAGS:-"-64  -nocpp -w"}
      XCFLAGS=${XCFLAGS:-"-64  -DPROTOTYPE -w"}
      XCXXFLAGS=${XCXXFLAGS:-"-64  -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      # Or use -O3 for agressive optimisation.
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.3*|IRIX\ 6.3*)
      # e.g. O2's
      XFFLAGS=${XFFLAGS:-"-64  -nocpp -w"}
      XCFLAGS=${XCFLAGS:-"-64  -DPROTOTYPE -w"}
      XCXXFLAGS=${XCXXFLAGS:-"-64  -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.4*|IRIX\ 6.4*)
      # e.g. Origin200
      XFFLAGS=${XFFLAGS:-"-64  -nocpp -w"}
      XCFLAGS=${XCFLAGS:-"-64  -DPROTOTYPE -w"}
      XCXXFLAGS=${XCXXFLAGS:-"-64  -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    IRIX64\ 6.5*|IRIX\ 6.5*)
      XFFLAGS=${XFFLAGS:-"-64  -nocpp -w"}
      XCFLAGS=${XCFLAGS:-"-64  -DPROTOTYPE -w"}
      CXXOPTIM=${CXXOPTIM:-"-O"}
      XCXXFLAGS=${XCXXFLAGS:-"-LANG:std -64  -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6_5"}
      ;;
    IRIX64\ 7.*|IRIX\ 7.*)
      XFFLAGS=${XFFLAGS:-"-64  -nocpp -w"}
      XCFLAGS=${XCFLAGS:-"-64  -DPROTOTYPE -w"}
      CXXOPTIM=${CXXOPTIM:-"-O"}
      XCXXFLAGS=${XCXXFLAGS:-"-LANG:std -LANG:libc_in_namespace_std=off -64  -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"} 
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_7"}
      ;;
    *)
      XFFLAGS=${XFFLAGS:-"-64  -nocpp -w"}
      XCFLAGS=${XCFLAGS:-"-64  -DPROTOTYPE -w"}
      XCXXFLAGS=${XCXXFLAGS:-"-64  -w"}
      F_LIBS=${F_LIBS:-"-lftn"}
      CXX_LIBS=${CXX_LIBS:-"-lC"}
      XLDFLAGS=${XLDFLAGS:-"-lm"}   
      FOPTIM=${FOPTIM:-"-O2"}
      # Xwindows variables set if wanted or not!
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
      XTYPE=${XTYPE:-"IRIX_6"}
      ;;
    esac
    SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM -Nq3000' \
                 detwin_FLAGS='$XFFLAGS $FOPTIM -static' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' "}
    M4=${M4:-"m4 -D_sgi=1 -D_irix51=1"}
    SHARED_LIB_FFLAGS=${SHARED_LIB_FFLAGS:-'-64'}
    SHARED_LIB_CFLAGS=${SHARED_LIB_CFLAGS:-'-64'}
    if test "$shared_lib" = yes; then
      SHARE_LIB=${SHARE_LIB:-'ld -64  -shared -all libmmdb.a -o libmmdb.so; ld -64  -shared -all libccp4c.a -o libccp4c.so; ld -64  -shared -all libccp4f.a -o libccp4f.so'}
      SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so; '
      XCFLAGS="$XCFLAGS -rpath $CLIB"
      XCXXFLAGS="$XCXXFLAGS -rpath $CLIB"
      XFFLAGS="$XFFLAGS -rpath $CLIB"
    fi
    ;; 
  IRIX64*)
    XFFLAGS=${XFFLAGS:-" -nocpp"}
    F_LIBS=${F_LIBS:-"-lftn"}
    CXX_LIBS=${CXX_LIBS:-"-lC"}
    XLDFLAGS=${XLDFLAGS:-"-lm"}   
    # Xwindows variables set if wanted or not!
    XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
    XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
    XTYPE=${XTYPE:-"IRIX_6_5"}
    echo "! Beware -- this is a substantially different OS version to those tested"
    ;;
  *)
     echo "! This doesn't appear to be an IRIX64 system."
     echo "! you should run configure on a machine of the correct type."
     exit 1 ;;
  esac
  # Each version of the irix compiler seems to bring a different set
  # of optimisation problems, some of which we probably never find out
  # about.  The default optimisation seems to be the best thing to go
  # with.  Maybe you can win in some cases by using -O2, caveat emptor...
  FOPTIM=${FOPTIM:-""}
  M4=${M4:-"m4 -D_sgi=1"}
  CXX=${CXX:-"CC"}
  XCXXFLAGS=${XCXXFLAGS:-" "} 
  # compiler specific options
  case `$CXX -dumpversion` in
    MIPSpro\ Compilers\ 7.4* ) XCXXFLAGS="$XCXXFLAGS -LANG:libc_in_namespace_std=off" ;;
    * )
  esac
  ;;
aix)      
# CCP4 5.0.2 tested on AIX 5.2 Sept 2004 - MDW
# Automated x-install for AIX from Sandra McLaughlin (March 2000)
  FC=${FC:-xlf}
  CC=${CC:-xlc}
  CXX=${CXX:-xlC}
  case `uname -vrs` in
  "AIX 2 5") ;;         # 5.2, not 2.5
  AIX*)
    echo "! Beware -- this is a substantially different OS version to those tested";;
  *)
     echo "! This doesn't appear to be an AIX system.
  You should run configure on a machine of the correct type."
    exit 1 ;;
  esac
  # avoid truncation to character*500 and ensure that the default
  # handling of external names is in force (no postfixed `_') and use
  # larger internal table sizes
  XFFLAGS=${XFFLAGS:-"-qcharlen=4000 -qnoextname -NQ20000 -NT40000"}
  XCFLAGS=${XCFLAGS:-""}
  XCXXFLAGS=${XCXXFLAGS-""}
  FOPTIM=${FOPTIM:-"-O3 -qmaxmem=-1 -qstrict"}
  COPTIM=${COPTIM:-"-O"}
  CXXOPTIM=${CXXOPTIM:-"-O"}
  F_LIBS=${F_LIBS:-"-lftn"}
  CXX_LIBS=${CXX_LIBS:-"-lC"}
  XLDFLAGS=${XLDFLAGS:-"-lm"}   
  test "$with_f2c" && M4=${M4:-"m4 -D_f2c=1"}
  M4=${M4:-"m4 -D_AIX=1"}
  SETFLAGS=${SETFLAGS:-"amore_FLAGS='$XFFLAGS $LDFLAGS' tracer_FLAGS='$XFFLAGS' \
                       fft_FLAGS='$XFFLAGS $FOPTIM -qintlog' \
                       xdlmapman_FLAGS='$XFFLAGS -qfixed=80'"}
  # this seems not to be exactly BSD install, but looks OK to use:
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"/usr/ucb/install -c"}
  INSTALL_DATA=${INSTALL_DATA:-"/usr/ucb/install -m 644 -c"}
  # Xwindows variables set if wanted or not!
  # But I don't know what to set XTYPE to (or what it is used for) ! 
  XDL_LIB=${XDL_LIB:-"${CCP4_LIB}/libxdl_view.a"}
  XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt -lXext"}
  XTYPE=${XTYPE:-"AIX"}
  if test "$shared_lib" = yes; then
    SHARE_LIB=${SHARE_LIB:-'ld -G -bnoentry -bexpall -bnogc libmmdb.a -o libmmdb.so; ld -G -bnoentry -bexpall -bnogc libccp4c.a -o libccp4c.so; ld -G -bnoentry -bexpall -bnogc libccp4f.a -o libccp4f.so'}
    SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so; '
  fi
  # echo; echo "! Beware -- the $system installation is not fully tested."
  ;;
linux_ibm_compilers | linux64_ibm_compilers )       # (tested in Linux PPC SLES9 and 
                # find a way to get the compiler version)
#  if test x"$enable_x" = xyes; then
#    echo "! Xwindows installation has not been tested    !"
#    echo "! for this system and so will not be attempted.!"
#    enable_x=no
#  fi
  case `uname -sm` in
  "Linux ppc64") ;;
  *)
     echo "! This doesn't appear to be an linux ppc system.
  You should run configure on a machine of the correct type."
    exit 1 ;;
  esac
  case $system in
    linux64* )
      FC=${FC:-"xlf -q64"}
      CC=${CC:-"xlc -q64"}
      CXX=${CXX:-"xlC -q64"}
      F_LIBS=${F_LIBS:-"-L`which xlf | sed 's/bin\/xlf/lib64/'` -lxlf90"}
      CXX_LIBS=${CXX_LIBS:-"-L`which xlC | sed 's/bin\/xlC/lib64/'` -libmc++"}
      ;;
    *)
      FC=${FC:-xlf}
      CC=${CC:-xlc}
      CXX=${CXX:-xlC}
      F_LIBS=${F_LIBS:-"-L`which xlf | sed 's/bin\/xlf/lib64/'` -lxlf90"}
      CXX_LIBS=${CXX_LIBS:-"-L`which xlC | sed 's/bin\/xlC/lib64/'` -libmc++"}
    esac
  # avoid truncation to character*500 and ensure that the default
  # handling of external names is in force (no postfixed `_') and use
  # larger internal table sizes
  XFFLAGS=${XFFLAGS:-"-qcharlen=4000 -qextname -NQ20000 -NT40000"}
  XCFLAGS=${XCFLAGS:-""}
  XCXXFLAGS=${XCXXFLAGS-""}
  FOPTIM=${FOPTIM:-"-O3 -qmaxmem=-1 -qstrict"}
  COPTIM=${COPTIM:-"-O"}
  CXXOPTIM=${CXXOPTIM:-"-O"}
  test "$with_f2c" && M4=${M4:-"m4 -D_f2c=1"}
  M4=${M4:-"m4 -D_xlf=1"}
  SETFLAGS=${SETFLAGS:-"amore_FLAGS='$XFFLAGS $LDFLAGS' tracer_FLAGS='$XFFLAGS' \
                       fft_FLAGS='$XFFLAGS $FOPTIM -qintlog' \
                       xdlmapman_FLAGS='$XFFLAGS -qfixed=80' \
                       molrep_FLAGS='-qextname -qmaxmem=-1' \
                       crunch2_FLAGS='-qextname -qmaxmem=-1' \
                       pmf_FLAGS='-qextname -qmaxmem=-1' \
                       sapi_FLAGS='-qextname -qmaxmem=-1' "}
  # this seems not to be exactly BSD install, but looks OK to use:
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"/usr/bin/install -c"}
  INSTALL_DATA=${INSTALL_DATA:-"/usr/bin/install -m 644 -c"}
  # Xwindows variables set if wanted or not!
  # But I don't know what to set XTYPE to (or what it is used for) ! 
  XDL_LIB=${XDL_LIB:-"${CCP4_LIB}/libxdl_view.a"}
  XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt -lXext"}
  XTYPE=${XTYPE:-"AIX"}
  if test "$shared_lib" = yes; then
    SHARE_LIB=${SHARE_LIB:-'ld -G -bnoentry -bexpall libmmdb.a -o libmmdb.so; ld -G -bnoentry -bexpall libccp4c.a -o libccp4c.so; ld -G -bnoentry -bexpall libccp4f.a -o libccp4f.so'}
    SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so; '
  fi
  # echo; echo "! Beware -- the $system installation is not fully tested."
  ;;
sunos | sunos64)
  # for os4.1, f771.4, at least
  case `uname -rs` in
  SunOS\ 4.1*)
    test "$with_f2c" && M4=${M4:-"/usr/5bin/m4 -D_f2c=1"}
    M4=${M4:-"/usr/5bin/m4 -D_sun=1"} # SysVile version
    INSTALL_PROGRAM=${INSTALL_PROGRAM:-"/usr/bin/install -c"}
    INSTALL_DATA=${INSTALL_DATA:-"/usr/bin/install -m 644 -c"}
    XTYPE=${XTYPE:-"SUNOS_4"}
    if test -z "$CC"; then
      # Look for an ANSI C compiler
      case `type acc` in
        *acc)
          CC=acc;;
        *)
          case `type gcc` in
          *gcc)
            CC=gcc;;
          *)
            echo "! Can't find GCC or the SunPro compiler."
            echo "! The default \`cc' won't compile \`solomon' or the XCCPJIFFY stuff."
          esac;;
      esac
    fi
    if test x"$enable_x" = xyes; then
      echo "! Xwindows installation has not been tested    !"
      echo "! for this system and so will not be attempted.!"
      enable_x=no
    fi
    ;;
  SunOS\ 5*)
    test "$with_f2c" && M4=${M4:-"m4 -D_f2c=1"}
    M4=${M4:-"m4 -D_sun=1"} 
    RANLIB=${RANLIB:-:}    
    INSTALL_PROGRAM=${INSTALL_PROGRAM:-"/usr/ucb/install -c"}
    INSTALL_DATA=${INSTALL_DATA:-"/usr/ucb/install -m 644 -c"}
# We use specific paths here, as Sun distribute old cc as well.
    FC=${FC:-/opt/SUNWspro/bin/f90}
    CC=${CC:-/opt/SUNWspro/bin/cc}
    CXX=${CXX:-/opt/SUNWspro/bin/CC}
    if [ "$shared_lib" = yes ]; then
      XFFLAGS=${XFFLAGS:-"-KPIC -R $CLIB"}
      XCFLAGS=${XCFLAGS:-"-KPIC -R $CLIB"}
      XCXXFLAGS=${XCXXFLAGS:-"-KPIC -R $CLIB"}
      if test "$system" = sunos64; then
        SHARE_LIB=${SHARE_LIB-'ld -dy -G -64 -z allextract -z text libmmdb.a -o libmmdb.so -L/usr/lib/64 -L/usr/ucblib/sparcv9; ld -dy -G -64 -z allextract -z text libccp4c.a -o libccp4c.so -L/usr/lib/64 -L/usr/ucblib/sparcv9; ld -dy -G -64 -z allextract -z text libccp4f.a -o libccp4f.so -L/usr/lib/64 -L/usr/ucblib/sparcv9'}
      else
        SHARE_LIB=${SHARE_LIB-'ld -dy -G -z allextract -z text libmmdb.a -o libmmdb.so; ld -dy -G -z allextract -z text libccp4c.a -o libccp4c.so; ld -dy -G -z allextract -z text libccp4f.a -o libccp4f.so'}
      fi
      SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so'
    fi
    if test "$non_shared" = yes; then
      XFFLAGS=${XFFLAGS:-"-Bstatic"}
      XCFLAGS=${XCFLAGS:-"-Bstatic"}
      XCXXFLAGS=${XCXXFLAGS:-"-Bstatic"}
    fi
    FOPTIM=${FOPTIM:-"-O3"}  # -fast is a possibility
    XFFLAGS=${XFFLAGS:-""}  
    XCFLAGS=${XCFLAGS:-""}
    F_LIBS=${F_LIBS:-"-lfui -lfai -lfai2 -lfsumai -lfprodai -lfminlai -lfmaxlai -lfminvai -lfmaxvai -lfsu -lsunmath -lompstubs"}
    CXX_LIBS=${CXX_LIBS:-"-lCrun"}
    XLDFLAGS=${XLDFLAGS:-"-lm"}
# Test to see if warnings should not be suppressed
    if test ! "$warnings" = yes; then
	XFFLAGS="-w $XFFLAGS" 
	XCFLAGS="-w $XCFLAGS"
        XCXXFLAGS="-w $XCXXFLAGS"
    fi
    if test "$system" = sunos64; then
      XCFLAGS="$XCFLAGS -xarch=generic64"
      XCXXFLAGS="$XCXXFLAGS -xarch=generic64"
      XFFLAGS="$XFFLAGS -xarch=generic64"
      XLDFLAGS="$XLDFLAGS -L/usr/lib/64 -L/usr/ucblib/sparcv9"
      XTYPE=${XTYPE:-"SUNOS64_5"}
    fi
    XTYPE=${XTYPE:-"SUNOS_5"}
    SETFLAGS=${SETFLAGS:-"amore_FLAGS=' $XFFLAGS -O2' \
                          rantan_FLAGS=' $XFFLAGS -O2' \
                          refmac5_FLAGS=' $XFFLAGS -O2'"}
    # Set Mapslicer command library flags
      if test "$system" = sunos64; then
        MAPSLICER_SHARE=${MAPSLICER_SHARE:-"ld -dy -G -64 -z allextract -z text libccp4map.a -o libccp4map.so -L/opt/SUNWspro/lib/v9 -L/usr/lib/64 -L/usr/ucblib/sparcv9"}
      else
        MAPSLICER_SHARE=${MAPSLICER_SHARE:-"ld -dy -G -z allextract -z text libccp4map.a -o libccp4map.so -L/opt/SUNWspro/lib"}
      fi
    if test x"$enable_x" = xyes; then
      XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
      XWIN_LIB=${XWIN_LIB:-"-L/usr/openwin/lib -lXt -lSM -lX11 -lICE"}
    fi
    ;;
  SunOS*)
    test "$with_f2c" && M4=${M4:-"/usr/5bin/m4 -D_f2c=1"}
    M4=${M4:-"/usr/5bin/m4 -D_sun=1"} # SysVile version
    echo "! Beware -- this is a substantially different OS version to those tested";;
  *)
     echo "! This doesn't appear to be a SunOS system.
  You should run configure on a machine of the correct type."
    exit 1 ;;
  esac
  FOPTIM=${FOPTIM:-"-O3"}  # -fast is a possibility
  XFFLAGS=${XFFLAGS:-""} 
  SETFLAGS=${SETFLAGS:-"amore_FLAGS='$XCFLAGS\ $LDFLAGS\ -O1'"}
  ;;
hpux)
  if test x"$enable_x" = xyes; then
    echo "! Xwindows installation has not been tested    !"
    echo "! for this system and so will not be attempted.!"
    enable_x=no
  fi
  case `uname -sr` in
  HP-UX\ A.08.*)  # uname -a: HP-UX tcs-hp0 A.08.07 A 9000/750 2002285682
    XLDFLAGS=${XLDFLAGS:-"-lfsys -lm"} # access to routines f77<C name>
                                      # -lm for solomon
    XFFLAGS=${XFFLAGS:-"+T +E1"} # +T is trap signals, +E1 gets access to
                # IDATE etc
    M4=${M4:-"m4 -D_hpux=1"}
    SETFLAGS=${SETFLAGS:-"prepform_FLAGS='$XFFLAGS' \
                         arp_waters_FLAGS='$XFFLAGS $FOPTIM -C'"} # exclude optimisation
  ;;
  HP-UX\ A.09.*)  # uname -a: HP-UX tcs-hp0 A.09.01 A 9000/755 2002285682 two-user license
  # floating point traps and access to routines f77<C name>
    XLDFLAGS=${XLDFLAGS:-"+FPVZO -lfsys -lm"}
    # Note that this is the documented way to get IDATE, and gives you the
    # usual unix variant.  I think in HPUX8, +E1 was OK.  We need a new flag
    # to know whether to use SECNDS or not, at least, since we don't seem to
    # be able to get both E1 and U77.
    # -lm for solomon
    XFFLAGS=${XFFLAGS:-"+U77 -w"} # access to IDATE etc
    XCFLAGS=${XCFLAGS:-"-w"}
    M4=${M4:-"m4 -D_hpux=1 -D_hpux9=1"}
    SETFLAGS=${SETFLAGS:-"prepform_FLAGS='$XFFLAGS' \
                         arp_waters_FLAGS='$XFFLAGS $FOPTIM -C'"} # exclude optimisation
    if test "$shared_lib" = yes; then
      SHARE_LIB=${SHARE_LIB:-'ld -b +s libmmdb.a -o libmmdb.sl; ld -b +s libccp4c.a -o libccp4c.sl; ld -b +s libccp4f.a -o libccp4f.sl'}
      SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.sl $(libdir)/libmmdb.sl; $(INSTALL_DATA) `pwd`/libccp4c.sl $(libdir)/libccp4c.sl; $(INSTALL_DATA) `pwd`/libccp4f.sl $(libdir)/libccp4f.sl'
    fi
  ;;
  HP-UX\ B.10.*)
# Thanks to Morten Kjeldgaard <mok@beast.imsb.au.dk>
    XLDFLAGS=${XLDFLAGS:-"+FPVZO -lfsys -lm"}
    FOPTIM=${FOPTIM:-"-O2"}
    XFFLAGS=${XFFLAGS:-"+U77 -w"} # access to IDATE etc
    XCFLAGS=${XCFLAGS:-"-w"}
    XCXXFLAGS=${XCXXFLAGS:-"-w"}
    M4=${M4:-"m4 -D_hpux=1 -D_hpux10=1"}
    SETFLAGS=${SETFLAGS:-"prepform_FLAGS='$XFFLAGS' \
                         arp_waters_FLAGS='$XFFLAGS $FOPTIM -C'"} # exclude optimisation
    if test "$shared_lib" = yes; then
      SHARE_LIB=${SHARE_LIB:-'ld -b +s libmmdb.a -o libmmdb.sl; ld -b +s libccp4c.a -o libccp4c.sl; ld -b +s libccp4f.a -o libccp4f.sl'}
      SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.sl $(libdir)/libmmdb.sl; $(INSTALL_DATA) `pwd`/libccp4c.sl $(libdir)/libccp4c.sl; $(INSTALL_DATA) `pwd`/libccp4f.sl $(libdir)/libccp4f.sl'
    fi
  ;;
  "HP-UX U.09*")                # What you get from on Convex-rebadged HP-SUX
                                # (honestly!) <zhangj@cuhhca.hhmi.columbia.EDU>
    if test ! -x /usr/convex/bin/fc; then
      echo "! This is a strange version of HPUX -- apparently not the Convex one."
      echo "! Don't know how to deal with it; contact ccp4 with details."
      exit 1
    else true; fi
    FC=${FC:-fc}                 # convex compiler
    M4=${M4:-"m4 -D_convex=1"}
    XFFLAGS=${XFFLAGS:-"-or none"}
    XLDFLAGS=${XLDFLAGS:-"-lm"} 
    FOPTIM=${FOPTIM:-"-O2"}
    # ``On HP AMORE can give problems when compliled with -O, You need to
    # complile it with -N.'' quoth MATTEVI@IPVGEN.UNIPV.IT.  No reports of
    # this under HPUX8.
    SETFLAGS=${SETFLAGS:-"amore_FLAGS='$XCFLAGS\ $LDFLAGS\ -N' \
                         prepform_FLAGS='$XFFLAGS' \
                         arp_waters_FLAGS='$XFFLAGS $FOPTIM -C'"} # exclude optimisation
    ;;
  HP-UX*) echo "! Beware -- this is a substantially different OS version to those tested"
    XLDFLAGS=${XLDFLAGS:-"-lfsys -lm"} # access to routines f77<C name>
                                      # -lm for solomon
    XFFLAGS=${XFFLAGS:-"+U77 -w"}
    XCFLAGS=${XCFLAGS:-"-w"}
    M4=${M4:-"m4 -D_hpux=1"}
    SETFLAGS=${SETFLAGS:-"prepform_FLAGS='$XFFLAGS' \
                         arp_waters_FLAGS='$XFFLAGS $FOPTIM -C'"} # exclude optimisation
    ;;
  *) echo "! This doesn't appear to be a HP-UX system.
  You should run configure on a machine of the correct type."
    exit 1 ;;
  esac
  # what `which fort77`:          HP-UX Fortran/9000s700 09/19/91 B2408A.08.07
  # what `which cc'        HP92453-01 A.08.71 HP C (Bundled) Compiler
  FC=${FC:-fort77}
  COPTIM=${COPTIM:-""}   # doesn't have -O
  FOPTIM=${FOPTIM:-"-O"}
  RANLIB=${RANLIB:-:}
  test "$with_f2c" && M4=${M4:-"m4 -D_f2c=1"}
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
  INSTALL_DATA=${INSTALL_DATA:-"cp"}
 ;;
osf1)
  case `uname -sr` in
  # This may be changing in `DEC Unix' (?).
  # v3.2c is reported to have problems with GNU stuff related to
  # the loader, I think.
  OSF1\ V3*|OSF1\ V4*)
    # I don't know whether -assume dummy_aliases is supported/needed in 
    # earlier versions...
    XFFLAGS=${XFFLAGS:-"-fpe0 -assume dummy_aliases"}
    XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"}
    XCXXFLAGS=${XCXXFLAGS:-"-D__USE_STD_IOSTREAM -ieee"}
    FOPTIM=${FOPTIM:-"-O1"}
    # Xwindows variables set if wanted or not!
    XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
    XWIN_LIB=${XWIN_LIB:-"-lXt -lSM -lX11 -lICE -ldnet_stub"}
#   don't yet know if this is enough...
    if test "$shared_lib" = yes; then
      SHARE_LIB=${SHARE_LIB:-'ld -shared -o libmmdb.so -expect_unresolved \* -all libmmdb.a -lcxx; ld -shared -o libccp4c.so -expect_unresolved \* -all libccp4c.a; ld -shared -o libccp4f.so -expect_unresolved \* -all libccp4f.a'}
      SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so'
      XCFLAGS="$XCFLAGS -Wl,-rpath,$CLIB"
      XCXXFLAGS="$XCXXFLAGS -Wl,-rpath,$CLIB"
      XFFLAGS="$XFFLAGS -Wl,-rpath,$CLIB"
      # For shared libs we don't need -lcxx
      XLDFLAGS=${XLDFLAGS:-"-lm"}
    fi
    #Always disable PDB_EXTRACT build
    if test ! -n "$disable_pdb_extract"; then
      echo
      echo " ************************** WARNING **************************"
      echo " Building of the RCSB PDB_EXTRACT suite has been suppressed."
      echo " This is because it cannot be built on OSF1 V4.0"
      echo " As a result you will not be able to use the PDB_EXTRACT programs."
      echo " Please contact CCP4 for more information."
      echo " *************************************************************"
      PDB_EXTRACT_SUITE=
      disable_pdb_extract=yes
    fi
    ;;
  #
  OSF1\ V5*)
    # This is based on the V3/4 entry
    # I don't know whether -assume dummy_aliases is supported/needed in 
    # earlier versions...
    # -D__V40_OBJ_COMPAT -nointrinsics required for V5 executables to run
    # under 4.0, but this should be done locally via DEC_CC or comp.config
    # if required.  Note that the compiler (or dtk) for which these flags
    # are relevant, may also be used under 4.0 and 5.0.
    XFFLAGS=${XFFLAGS:-"-fpe0 -assume dummy_aliases"}
    XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"}
    XCXXFLAGS=${XCXXFLAGS:-"-D__USE_STD_IOSTREAM -ieee"}
    FOPTIM=${FOPTIM:-"-O1"}
    # Xwindows variables set if wanted or not!
    XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
    XWIN_LIB=${XWIN_LIB:-"-lXt -lSM -lX11 -lICE -ldnet_stub"}
    XLDFLAGS=${XLDFLAGS:-"-lm"}
    if test "$shared_lib" = yes; then
      SHARE_LIB=${SHARE_LIB:-'ld -shared -o libmmdb.so -expect_unresolved \* -all libmmdb.a -lcxx; ld -shared -o libccp4c.so -expect_unresolved \* -all libccp4c.a; ld -shared -o libccp4f.so -expect_unresolved \* -all libccp4f.a'}
      SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so'
      XCFLAGS="$XCFLAGS -Wl,-rpath,$CLIB"
      XCXXFLAGS="$XCXXFLAGS -Wl,-rpath,$CLIB"
      XFFLAGS="$XFFLAGS -Wl,-rpath,$CLIB"
    fi
    ;;
  OSF1*)
    ;;
  *)
     echo "! This doesn't appear to be an OSF/1 system.
  You should run configure on a machine of the correct type."
    exit 1 ;;
  esac
	test "$with_f2c" && M4=${M4:-"m4 -D_f2c=1"}
  M4=${M4:-"m4 -D_dec_fortran=1"} 
  FOPTIM=${FOPTIM:-"-O1"}
  XFFLAGS=${XFFLAGS:-"-fpe0"} # & core dump on overflow, /0 and invalid
  XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"}
  CXX=${CXX:-"cxx"}
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"/usr/bin/installbsd -c -o $user"}
  INSTALL_DATA=${INSTALL_DATA:-"/usr/bin/installbsd  -m 644 -c -o $user"}
# Test to see if warnings should not be suppressed
  if test ! "$warnings" = yes; then
      XFFLAGS="-nowarn $XFFLAGS" 
      XCFLAGS="-w $XCFLAGS"
      XCXXFLAGS="-w $XCXXFLAGS"
  fi
# Test to see if non_shared is specified
  if test "$non_shared" = yes; then
      XFFLAGS="-non_shared $XFFLAGS" 
      XCFLAGS="-non_shared $XCFLAGS"
      XCXXFLAGS="-non_shared $XCXXFLAGS"
      SETFLAGS=${SETFLAGS:-"amore_FLAGS='-non_shared -O0' \
                  rsps_FLAGS='-non_shared -O1 -Olimit 3000' \
                  arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' "}
  else
      SETFLAGS=${SETFLAGS:-"amore_FLAGS='-O0' \
                  rsps_FLAGS='-O1 -Olimit 3000' \
                  arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' "}
  fi
  F_LIBS=${F_LIBS:-"-lfor -lFutil"}
  CXX_LIBS=${CXX_LIBS:-"-lcxx"}
  # Xwindows variables set if wanted or not!
  XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
  XWIN_LIB=${XWIN_LIB:-"-lX11 -lXt"}
  XTYPE=${XTYPE:-"DECALPHAOSF"}
  # Set Mapslicer command library flags
  # Try using same flags for all OSF1 versions
  MAPSLICER_SHARE=${MAPSLICER_SHARE:-"ld -shared -o libccp4map.so -expect_unresolved \* -all libccp4map.a"}
  # echo; echo "! Beware -- the $system installation is not fully tested."
  ;;
linux_compaq_compilers)
# Thanks to Sanjoy Ray and David van der Spoel for this. 
# Apparently compaq now distribute a set of compilers for linux
# this conifure was hacked together by Sanjoy Ray from the 
# OSF1 option.
    echo "! This is a new option and is relativeley untested!"
    echo "! November 1999"
  case `uname -sr` in
    Linux*)

       ;;
    *)
       echo "! This doesn't appear to be a Linux system. You should run"
       echo "! configure on a machine of the correct type."
       exit 1 ;;
  esac
  case `grep Alpha /proc/cpuinfo` in
    *Alpha*)

       ;;
    *)
       echo "! This doesn't appear to be an Alpha system. You should run"
       echo "! configure on a machine of the correct type."
       exit 1 ;;
  esac
  case `which fort` in
    *fort)

       ;;
    *)
       echo "! You don't appear to have the Compaq Fortran compiler (fort). "
       echo "! Either configure for Linux, or install fort."
       echo "! See http://www.unix.digital.com/linux/software.htm"
       exit 1 ;;
  esac
  case `which ccc` in
    *ccc)

       ;;
    *)
       echo "! You don't appear to have the Compaq C compiler (ccc). "
       echo "! Either configure for Linux, or install ccc."
       echo "! See http://www.unix.digital.com/linux/software.htm"
       exit 1 ;;
  esac
  FC=${FC:-fort}
  CC=${CC:-ccc}
  M4=${M4:-"m4 -D_dec_fortran=1"}
  FOPTIM=${FOPTIM:-"-O1"}
  XFFLAGS=${XFFLAGS:-"-fpe0 -assume dummy_aliases -assume no2underscores -nowarn"}
  XCFLAGS=${XCFLAGS:-"-w -DPROTOTYPE -D__OSF1__"}
  XCXXFLAGS=${XCXXFLAGS:-"-w -D__OSF1__"}
  INSTALL_DATA=${INSTALL_DATA:-"cp"}
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
  SETFLAGS=${SETFLAGS:-"amore_FLAGS='-O0' rsps_FLAGS='-O2' \
                   sftools_FLAGS='$XFFLAGS $FOPTIM' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM -C -static' "}
  XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
  XWIN_LIB=${XWIN_LIB:-"-L/usr/X11R6/lib -lXt -lSM -lX11 -lICE"}
  XTYPE=${XTYPE:-"LINUX"}
  TIDY=${TIDY:-"rm -f sta*"}
  ;;
linux_intel_compilers)
  case `uname -sr` in
    Linux*)

       ;;
    *)
       echo "! This doesn't appear to be a Linux system. You should run"
       echo "! configure on a machine of the correct type."
       exit 1 ;;
  esac
  case `which ifort` in
    *ifort)
      FC=${FC:-"ifort -Vaxlib"}
      M4=${M4:-"m4 -D_ifc=8"}
      # this is for Intel 8. The -L is necessary because Fortran libraries
      # are in different directory from C libraries (cf. Intel 7)
      F_LIBS=${F_LIBS:-"-L`which ifort | sed 's/bin\/ifort/lib/'` -lifcore"}
      CXX_LIBS=${CXX_LIBS:-"-L`which icc | sed 's/bin\/icc/lib/'` -lcxa -lunwind"}
      IA32ROOT=${IA32ROOT:-"`which icc | sed 's/\/bin\/icc//'`"}
      ;;
    *)
      case `which ifc` in
        *ifc)
          FC=${FC:-"ifc -Vaxlib"}
          M4=${M4:-"m4 -D_ifc=1"}
          XLDFLAGS=${XLDFLAGS:-"-lIEPCF90 -lF90"}
          IA32ROOT=${IA32ROOT:-"`which icc | sed 's/\/bin\/icc//'`"}
       ;;
          *)
       echo "! You don't appear to have the Intel Fortran compiler (ifc). "
       echo "! You may need to source the corect file for them to be on your path."
            exit 1 ;;
       esac
    esac
  case `which icc` in
    *icc) CC=${CC:-icc} ;;
    *)
       echo "! You don't appear to have the Intel C compiler (icc). "
       echo "! You may need to source the corect file for them to be on your path."
     exit 1 ;;
  esac
  case `which icpc` in 
    *icpc ) CXX=${CXX:-icpc} ;;
    * ) CXX=${CXX:-icc}
        XCCXFLAGS="$XCXXFLAGS -Kc++" ;;
    esac
  case `$CXX --dumpversion` in
    icpc\ \(ICC\)\ 9.*) 
      case `gcc -dumpversion 2>&1` in
        4.* ) CXX="$CXX -cxxlib-icc" ;;
        esac
      ;;
    *) ;;
    esac

  FOPTIM=${FOPTIM:-"-O"}
#more to go here
  XFFLAGS=${XFFLAGS:-"-align -w90 -cm "}
  XCFLAGS=${XCFLAGS:-"-DPROTOTYPE -DIFC "}
  INSTALL_DATA=${INSTALL_DATA:-"cp"}
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
  case `$FC --version` in
    ifort\ \(IFORT\)\ 9.*)
        SETFLAGS=${SETFLAGS:-"amore_FLAGS='-O0' rsps_FLAGS='-O2' \
                   sftools_FLAGS='$XFFLAGS $FOPTIM' \
                   lgglib_FLAGS='$XFFLAGS -O0' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM' \
               refmac5_FLAGS='$XFFLAGS -O0' "}
      ;;
    *)
      SETFLAGS=${SETFLAGS:-"amore_FLAGS='-O0' rsps_FLAGS='-O2' \
                   sftools_FLAGS='$XFFLAGS $FOPTIM' \
                   lgglib_FLAGS='$XFFLAGS -O0' \
               arp_waters_FLAGS='$XFFLAGS $FOPTIM' "}
  esac
  XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
  XWIN_LIB=${XWIN_LIB:-"-L/usr/X11R6/lib -lXt -lSM -lX11 -lICE"}
  XTYPE=${XTYPE:-"LINUX"}
  TIDY=${TIDY:-"rm -f sta*"}
  if test "$shared_lib" = yes; then
    SHARE_LIB=${SHARE_LIB:-'ld -shared -soname libmmdb.so --whole-archive -o libmmdb.so libmmdb.a; ld -shared -soname libccp4c.so --whole-archive -o libccp4c.so libccp4c.a; ld -shared -soname libccp4f.so --whole-archive -o libccp4f.so libccp4f.a'}
    SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so; '
    XLDFLAGS="-Wl,-rpath,$CLIB $XLDFLAGS"
    XFFLAGS="$XFFLAGS -Qoption,ld,-Bdynamic -Qoption,ld,-rpath,$IA32ROOT/lib -Qoption,ld,-rpath,$CLIB"
    XCFLAGS="$XCFLAGS -Qoption,ld,-Bdynamic -Qoption,ld,-rpath,$IA32ROOT/lib -Qoption,ld,-rpath,$CLIB"
    XCXXFLAGS="$XCXXFLAGS -Qoption,ld,-Bdynamic -Qoption,ld,-rpath,$IA32ROOT/lib -Qoption,ld,-rpath,$CLIB"
  fi
  # Set Mapslicer command library flags
  MAPSLICER_SHARE=${MAPSLICER_SHARE:-'ld -shared -soname libccp4map.so --whole-archive -o libccp4map.so libccp4map.a'}
  ;;
linux | linux64 )
  case `uname -sr` in
    Linux*)
       
       ;;
    *)
       echo "! This doesn't appear to be a Linux system. You should run"
       echo "! configure on a machine of the correct type."
       exit 1 ;;
  esac

  case $system in
    linux64 )
      CC=${CC:-"gcc -m64"}
      CXX=${CXX:-"g++ -m64"}
      ;;
    *)
      CC=${CC:-gcc}
      CXX=${CXX:-g++}
      ;;
    esac

cat >conftest.c <<_ACEOF
int main ()
{
 ;
}
_ACEOF
 echo
 test_compile="$CC $XCFLAGS conftest.c -o conftest.o"
 if { (eval echo "testing linux ABI using: \"$CC $XCFLAGS\"")
  (eval $test_compile ) 2>&1
  ac_status=$?
  (exit $ac_status); }; then
    case `/usr/bin/file conftest.o` in
    *32-bit*)
       (eval echo "\$ 32-bit")
      ;;
    *64-bit*)
      (eval echo "\$ 64-bit")
# need linux64 for blas/lapack search
      system=linux64
      XWIN_LIB=${XWIN_LIB:-"-L/usr/X11R6/lib64 -lXt -lSM -lX11 -lICE"}
      ;;
    esac
  fi
  rm -rf conftest*
 
  if test "$with_f2c" ; then 
    M4=${M4:-"m4 -D_f2c=1"}
    XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"}
  else
    case `$CC -dumpversion 2>&1` in
      4.* )      
# default to gfortran for the moment
      case $system in
        linux64 ) FC=${FC:-"gfortran -m64"} ;;
        *) FC=${FC:-gfortran} ;;
        esac
    esac
#for non 4.* set g77, etc.
    case $system in
      linux64 ) FC=${FC:-"g77 -m64"} ;;
      *) FC=${FC:-g77} ;;
      esac
  fi
  
  case `$CC -dumpversion 2>&1` in
    2.96* )
     if test `rpm -q --qf '%{version}' redhat-release` -eq 7.0  ; then
# This is really on redhat 7.0 with only origional compilers - will work with -O0
       XFFLAGS=${XFFLAGS:-"-fno-second-underscore -fno-globals -fno-automatic -O0"}
     else
       XFFLAGS=${XFFLAGS:-"-fno-second-underscore -fno-globals -fno-automatic"} 
     fi
     ;;
   4.* )
# default to gfortran for the moment
     case $FC in
       *gfortran )
         XFFLAGS=${XFFLAGS:-"-fno-second-underscore"} 
         M4=${M4-"m4 -D_gfort=1"}
         XCFLAGS=${XCFLAGS:-"-DGFORTRAN -DPROTOTYPE"}
         F_LIBS=${F_LIBS:-"-lgfortran"}
         SETFLAGS=${SETFLAGS:-"lgglib_FLAGS='$XFFLAGS -O0' arp_waters_FLAGS='$XFFLAGS $FOPTIM -fforce-mem' " }
         ;;
       esac
     XCFLAGS=${XCFLAGS:-"-DG77 -DPROTOTYPE"}
     ;;
    *) 
     XFFLAGS=${XFFLAGS:-"-fno-second-underscore -fno-globals -fno-automatic"} ;;
  esac
 
#default values to catch all 
  M4=${M4-"m4 -D_g77=1"}
  XCFLAGS=${XCFLAGS:-"-DG77 -DPROTOTYPE -DHAVE_G2C_H"}
#Note, space is important, otherwise XCXXFLAGS defaults to XCFLAGS
  XCXXFLAGS=${XCXXFLAGS:-" "}
  F_LIBS=${F_LIBS:-"-lg2c"}
# Michael Wahl says this is sometimes needed: may need to be removed.
  XFFLAGS=${XFFLAGS:-"-fno-second-underscore -fno-globals"}

# Test to see if warnings should not be suppressed
  if test ! "$warnings" = yes; then
      XFFLAGS="-w $XFFLAGS" 
      XCFLAGS="-w $XCFLAGS"
      XCXXFLAGS="-w $XCXXFLAGS"
  fi
  if test "$non_shared" = yes; then
#this is a bit of a cheat/fudge but thats life!
      FC="$FC -static"
      CC="$CC -static"
      CXX="$CXX -static"     
  fi
  FOPTIM=${FOPTIM:-"-O"}
  COPTIM=${COPTIM:-"-O"}
  INSTALL_DATA=${INSTALL_DATA:-"cp"}
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
  SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM' \
                      arp_waters_FLAGS='$XFFLAGS $FOPTIM -fforce-mem' \
                      mlphare_FLAGS='$XFFLAGS $FOPTIM -fno-move-all-movables' \
                      stereo_FLAGS='$XFFLAGS $FOPTIM -fno-move-all-movables' "}

  XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
  XWIN_LIB=${XWIN_LIB:-"-L/usr/X11R6/lib -lXt -lSM -lX11 -lICE"}
  XTYPE=${XTYPE:-"LINUX"}
  CXX_LIBS=${CXX_LIBS:-"-lstdc++"}
  XLDFLAGS=${XLDFLAGS:-"-lm"}
  if test "$shared_lib" = yes; then
    SHARE_LIB=${SHARE_LIB:-'ld -shared -soname libmmdb.so --whole-archive -o libmmdb.so libmmdb.a; ld -shared -soname libccp4c.so --whole-archive -o libccp4c.so libccp4c.a; ld -shared -soname libccp4f.so --whole-archive -o libccp4f.so libccp4f.a'}
    SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so; '
    XLDFLAGS="-Wl,-rpath,$CLIB $XLDFLAGS"
    XFFLAGS="$XFFLAGS -fPIC"
    XCFLAGS="$XCFLAGS -fPIC"
    XCXXFLAGS="$XCXXFLAGS -fPIC"
  fi
  # Set Mapslicer command library flags
  MAPSLICER_SHARE=${MAPSLICER_SHARE:-'ld -shared -soname libccp4map.so --whole-archive -o libccp4map.so libccp4map.a'}
  ;;
# linux_ia64_sgi_altix)
# work by SGI Japan
ia64_linux_intel)
  case `uname -sr` in
    Linux*)

       ;;
    *)
       echo "! This doesn't appear to be a Linux system. You should run"
       echo "! configure on a machine of the correct type."
       exit 1 ;;
  esac

  if test -z "$FC"; then
    ac_cv_prog_F77=$FC
    for ac_prog in ifort efc 
    do
      echo $ECHO_N "checking for $ac_prog... $ECHO_C" 
      as_save_IFS=$IFS
      IFS=:
      for as_dir in $PATH 
        do
        IFS=$as_save_IFS
        test -z "$as_dir" && as_dir=.
        if test -f "$as_dir/$ac_prog" ; then
           ac_cv_prog_F77="$ac_prog"
           break
        fi
      done
    if test -n "$ac_cv_prog_F77"; then
      echo "${ECHO_T}$ac_cv_prog_F77"
    else
      echo "${ECHO_T}no"
    fi
    test -n "$ac_cv_prog_F77" && break
    done
    FC=$ac_cv_prog_F77
  fi

  if test -z "$CC"; then
    ac_cv_prog_CC=$CC
    for ac_prog in icc ecc        
    do
      echo $ECHO_N "checking for $ac_prog... $ECHO_C" 
      as_save_IFS=$IFS
      IFS=:
      for as_dir in $PATH
        do
        IFS=$as_save_IFS
        test -z "$as_dir" && as_dir=.
        if test -f "$as_dir/$ac_prog" ; then
           ac_cv_prog_CC="$ac_prog"
           break
        fi 
      done
    if test -n "$ac_cv_prog_CC"; then
      echo "${ECHO_T}$ac_cv_prog_CC"
    else
      echo "${ECHO_T}no"
    fi
    test -n "$ac_cv_prog_CC" && break
    done
    CC=$ac_cv_prog_CC
  fi

  if test -z  "$FC" || test -z "$CC"; then
       echo "! You don't appear to have the Intel compiler (ifort/efc,icc/ecc). "
       echo "! You may need to source the corect file for them to be on your path."
            exit 1
  fi

  if test -z "$CXX"; then
    ac_cv_prog_CXX=$CXX
    for ac_prog in icpc icc ecc
    do
      echo $ECHO_N "checking for $ac_prog... $ECHO_C"
      as_save_IFS=$IFS
      IFS=:
      for as_dir in $PATH
        do
        IFS=$as_save_IFS
        test -z "$as_dir" && as_dir=.
        if test -f "$as_dir/$ac_prog" ; then
           ac_cv_prog_CXX="$ac_prog"
           break
        fi
      done
    if test -n "$ac_cv_prog_CXX"; then
      echo "${ECHO_T}$ac_cv_prog_CXX"
    else
      echo "${ECHO_T}no"
    fi
    test -n "$ac_cv_prog_CXX" && break
    done
    CXX=$ac_cv_prog_CXX
  fi

  case $FC in 
    *ifort )
      M4=${M4:-"m4 -D_ifc=8"} 
      F_LIBS=${F_LIBS:-"-L`which ifort | sed 's/bin\/ifort/lib/'` -lifport -lifcore"}
      ;;
    * )
      M4=${M4:-"m4 -D_efc=1"}
      XLDFLAGS="-Vaxlib $XLDFLAGS"
      ;;
  esac
  XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"}
  case $CXX in
    *icpc ) 
      CXX_LIBS=${CXX_LIBS:-"-L`which icc | sed 's/bin\/icc/lib/'` -lcxa -lipr -lunwind"}
      ;;  
    *icc ) 
      XCXXFLAGS="$XCXXFLAGS -Kc++"
      CXX_LIBS=${CXX_LIBS:-"-L`which icc | sed 's/bin\/icc/lib/'` -lcxa -lipr -lunwind"}
      ;;
    *ecc ) XCXXFLAGS="$XCXXFLAGS -Kc++" 
      CXX_LIBS=${CXX_LIBS:-"-L`which ecc | sed 's/bin\/ecc/lib/'` -lcprts"}
      ;;
    esac

# Test to see if warnings should not be suppressed
  if test ! "$warnings" = yes; then
      XFFLAGS="-w -w95 -w90 $XFFLAGS"
      XCFLAGS="-w $XCFLAGS"
      XCXXFLAGS="-w $XCXXFLAGS"
  fi
  FOPTIM=${FOPTIM:-"-g -O"}
  COPTIM=${COPTIM:-"-g -O"}
  INSTALL_DATA=${INSTALL_DATA:-"cp"}
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
  SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM' \
                      refmac5_FLAGS='$XFFLAGS $FOPTIM' \
                      arp_waters_FLAGS='$XFFLAGS $FOPTIM'\
                      distang_FLAGS='$XFFLAGS -O1' "}
  XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
  XWIN_LIB=${XWIN_LIB:-"-L/usr/X11R6/lib -lXt -lSM -lX11 -lICE"}
  XTYPE=${XTYPE:-"LINUX"}
  if test "$shared_lib" = yes; then
    SHARE_LIB=${SHARE_LIB:-'ld -shared -soname libmmdb.so --whole-archive -o libmmdb.so libmmdb.a; ld -shared -soname libccp4c.so --whole-archive -o libccp4c.so libccp4c.a; ld -shared -soname libccp4f.so --whole-archive -o libccp4f.so libccp4f.a'}
    SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so; '
    XLDFLAGS=${XLDFLAGS:-"-Wl,-rpath,$CLIB"}
    XCXXFLAGS="-fPIC $XCXXFLAGS"
  fi
  # Set Mapslicer command library flags
  MAPSLICER_LIBS=${MAPSLICER_LIBS:-"-ldl"}
  MAPSLICER_SHARE=${MAPSLICER_SHARE:-"ld -shared -soname libccp4map.so --whole-archive -o libccp4map.so libccp4map.a"}
  ;;
Darwin)
  CC=${CC:-gcc}
  CXX=${CXX:-g++}
  case `$CC -v 2>&1` in
   *4.* )
# default to gfortran for the moment
    FC=${FC:-gfortran} ;;
   *) FC=${FC:-g77} ;;
  esac
  case $FC in
    *g77* )
      M4="m4 -D_g77=1"
      case `$CC -v 2>&1` in
        *4.* ) XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"} ;;
        *) 
# do I have g2c.h
  cat >> conftest.c << _EOF
#include <g2c.h>
_EOF
  if { (eval $CC -E conftest.c) 2>conftest.er1
    ac_status=$?
    grep -v '^ *+' conftest.er1 >conftest.err
    rm -f conftest.er1
    (exit $ac_status); } >/dev/null; then
    if test -s conftest.err; then
      g2c_hdr=no
    else
      g2c_hdr=yes
    fi
  else
    g2c_hdr=no
  fi
  rm conftest.*
  if test "$g2c_hdr" = yes; then
    XCFLAGS=${XCFLAGS:-"-DG77 -DPROTOTYPE -DHAVE_G2C_H"}
  else
         XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"}
  fi
        ;;
      esac
      XFFLAGS=${XFFLAGS:-"-funroll-loops -fno-fast-math -fno-second-underscore -fno-globals -fno-automatic"}
      F_LIBS=${F_LIBS:-"-lg2c"}
#      case `$CXX -v 2>&1` in
#        *4.* ) CXX_LIBS=${CXX_LIBS:-"-lstdc++ -lSystemStubs"}
#      esac
      ;;
    *gfortran* )
       XFFLAGS=${XFFLAGS:-"-fno-second-underscore"}
       M4=${M4-"m4 -D_gfort=1"}
       XCFLAGS=${XCFLAGS:-"-DGFORTRAN -DPROTOTYPE"}
       F_LIBS=${F_LIBS:-"-lgfortran"}
    ;;
  esac
#version specific elements
#gfortran 4.0.3 requires -O1 default 
  echo `$FC --version`
  case `$FC --version` in
    GNU\ Fortran\ 95\ \(GCC\ 4.0.3\)* | GNU\ Fortran\ 95\ \(GCC\ 4.0.2\)* )
      case $UNAME_ARCH in
        i386 ) FOPTIM="-O1" 
               SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM' \
                      refmac5_FLAGS='$XFFLAGS -O1' \
                      arp_waters_FLAGS='$XFFLAGS $FOPTIM -fforce-mem' \
                      mplot_FLAGS='$XFFLAGS -O1' \
                      molrep_FLAGS='$XFFLAGS -O1' \
                      xdlmapman_FLAGS='$XFFLAGS -O1'\
                      lgglib_FLAGS='$XFFLAGS -O0' "}
        ;;
      esac
      ;;
    esac

#need -lstdc++ , and also may be in different location to fortran
  if test x"$CXX_LIBS" = x ; then
cat >> conftest.cc << _EOF
main () 
{ 
  
  ;
  return 0;
} 
_EOF
 test_compile="$CXX -v $XCXXFLAGS conftest.cc -o conftest"
 link_output=`eval $test_compile 5>&1 2>&1 | grep lcrt1` 
 got_already=
 set X $link_output
 while test $# != 1; do
   shift
   ac_arg=$1
   case $ac_arg in
     [\\/]*.a | ?:[\\/]*.a)
        ac_exists=false
        for ac_i in $CXX_LIBS; do
          if test x"$ac_arg" = x"$ac_i"; then
            ac_exists=true
            break
          fi
        done

        if test x"$ac_exists" = xtrue; then
          :
        else
          CXX_LIBS="$CXX_LIBS $ac_arg"
        fi
        ;;
     -bI:*)
        ac_exists=false
        for ac_i in $CXX_LIBS; do
          if test x"$ac_arg" = x"$ac_i"; then
            ac_exists=true
            break
          fi
        done
        if test x"$ac_exists" = xtrue; then
          :
        else
          CXX_LIBS="$CXX_LIBS $ac_arg"
        fi
        ;;
          # Ignore these flags.
     -lang* | -lcrt0.o | -lc | -lgcc | -libmil | -LANG:=*)
          ;;
     -lcrt1.o | -lcrt2.o |-lcrtbegin.o )
          ;;
     -lkernel32)
          test x"$CYGWIN" != xyes && ac_cv_cxxlibs="$ac_cv_cxxlibs $ac_arg"
          ;;
     -[LRuY])
          # These flags, when seen by themselves, take an argument.
          # We remove the space between option and argument and re-iterate
          # unless we find an empty arg or a new option (starting with -)
          case $2 in
             "" | -*);;
             *)
                ac_arg="$ac_arg$2"
                shift; shift
                ;;
          esac
          ;;
     -YP,*)
          for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
            ac_exists=false
            for ac_i in $CXX_LIBS; do
              if test x"$ac_j" = x"$ac_i"; then
                ac_exists=true
                break
              fi
            done
            if test x"$ac_exists" = xtrue; then
              :
            else
              CXX_LIBS="$CXX_LIBS $ac_j"
            fi
          done
          ;;
     -[lLR]*)
          ac_exists=false
          for ac_i in $CXX_LIBS; do
            if test x"$ac_arg" = x"$ac_i"; then
              ac_exists=true
              break
            fi
          done
          if test x"$ac_exists" = xtrue; then
            :
          else
            CXX_LIBS="$CXX_LIBS $ac_arg"
          fi
          ;;
          # Ignore everything else.
  esac
done
rm conftest*
fi # CXX_LIBS

#defaults
  FOPTIM=${FOPTIM:-"-O2"}
  COPTIM=${COPTIM:-"-O2"}
  CXXOPTIM=${CXXOPTIM:-"-O2"}
  INSTALL_DATA=${INSTALL_DATA:-"cp"}
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
  SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM' \
                      refmac5_FLAGS='$XFFLAGS -O1' \
                      arp_waters_FLAGS='$XFFLAGS $FOPTIM -fforce-mem' \
                      mplot_FLAGS='$XFFLAGS -O1' \
                      molrep_FLAGS='$XFFLAGS -O1' \
                      xdlmapman_FLAGS='$XFFLAGS -O1'"}
  XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
  XWIN_LIB=${XWIN_LIB:-"-L/usr/X11R6/lib -lXt -lSM -lX11 -lICE"}
  XTYPE=${XTYPE:-"LINUX"}
  TIDY=${TIDY:-"rm -f sta*"}
  MAPSLICER_SHARE=${MAPSLICER_SHARE:-""}
  CXX_LIBS=${CXX_LIBS:-"-lstdc++"}
  XLDFLAGS=${XLDFLAGS:-"-lm"}
  XCXXFLAGS=${XCXXFLAGS:-" "}
  XMKMF="IMAKECPP=/usr/bin/cpp xmkmf"
  if test "$shared_lib" = yes; then
    SHARED_LIB_CFLAGS=${SHARED_LIB_CFLAGS:-'-fPIC -fno-common'}
    SHARE_LIB='${CC} -dynamiclib -flat_namespace -undefined suppress ${SHARED_LIB_CFLAGS} -install_name libmmdb.dylib -all_load libmmdb.a -o libmmdb.dylib -lstdc++; ${CC} -dynamiclib -flat_namespace -undefined suppress ${SHARED_LIB_CFLAGS} -install_name libccp4c.dylib -all_load libccp4c.a  -o libccp4c.dylib'
    SHARE_INST='${INSTALL_DATA} `pwd`/libmmdb.dylib ${libdir}/libmmdb.dylib; ${INSTALL_DATA} `pwd`/libccp4c.dylib ${libdir}/libccp4c.dylib'
  fi     
#need -lcc_dynamic to get restFP and saveFP for g77 3.4 under darwin 7
  case `$FC --version` in
    *3.4* ) 
      case $UNAME_VERS in
        7.* ) XLDFLAGS="$XLDFLAGS -lcc_dynamic" ;;
      esac
  esac
#  LDFLAGS="-lccp4f -lccp4c -lmmdb \$(XCIF_LIB) \$(XLAPACK_LIB) \$(XLDFLAGS)"
  ;;
Darwin_ibm_compilers)
  M4=${M4:-"m4 -D_xlf=1"}
  FC=${FC:-xlf}
  CC=${CC:-xlc}
  CXX=${CXX:-xlc++}
  LD=${LD:-/usr/bin/ld}
  XFFLAGS=${XFFLAGS:-"-qextname -qarch=auto -qtune=auto -qstrict"}
  XCFLAGS=${XCFLAGS:-"-DPROTOTYPE -qarch=auto -qtune=auto -qstrict"}
  XCXXFLAGS=${XCXXFLAGS:-"-qarch=auto -qtune=auto -qstrict"}
  F_LIBS=${F_LIBS:-"-lxlf90 -lxlfmath"}
  C_LIBS=${C_LIBS:-"-lc -lgcc"}
  CXX_LIBS=${CXX_LIBS:-"-libmc++ -lstdc++"}
  XLDFLAGS=${XLDFLAGS:-"-lm"}
  FOPTIM=${FOPTIM:-"-O3 -qmaxmem=-1 -qstrict"}
  COPTIM=${COPTIM:-"-O2"}
  CXXOPTIM=${CXXOPTIM:-"-O2"}
  INSTALL_DATA=${INSTALL_DATA:-"cp"}      
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
  SETFLAGS=${SETFLAGS:-"xdlmapman_FLAGS='$XFFLAGS -O1 -qfixed=80' \
                      sapi_FLAGS='$XFFLAGS -O0 -qmaxmem=-1' \
                      molrep_FLAGS='$XFFLAGS -O0 -qmaxmem=-1' \
                      crunch2_FLAGS='$XFFLAGS -O0 -qmaxmem=-1' \
                      pmf_FLAGS='$XFFLAGS -O0 -qmaxmem=-1'"}
  XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
  XWIN_LIB=${XWIN_LIB:-"-L/usr/X11R6/lib -lXt -lSM -lX11 -lICE"}
  XTYPE=${XTYPE:-"LINUX"}
  TIDY=${TIDY:-"rm -f sta*"}
  MAPSLICER_SHARE=${MAPSLICER_SHARE:-""}
  XMKMF="IMAKECPP=/usr/bin/cpp xmkmf -D_CALL_SYSV"
  if test "$shared_lib" = yes; then
    SHARED_LIB_CFLAGS=${SHARED_LIB_CFLAGS:-'-qpic -qnocommon'}
#cc_dynamic resolves restFP and saveFP
#dylib1.o is dyld_stub_binding_helper
#disable fortran shared library to allow access to common blocks
    SHARE_LIB='${CXX} -qmkshrobj -flat_namespace -undefined suppress -Wl,-install_name,libmmdb.dylib bfgs_min.o mmdb_chain.o mmdb_manager.o mmdb_symop.o file_.o mmdb_cifdefs.o mmdb_mask.o mmdb_title.o linalg_.o mmdb_coormngr.o mmdb_mmcif.o mmdb_utils.o machine_.o mmdb_cryst.o mmdb_model.o stream_.o mattype_.o mmdb_file.o mmdb_rwbrook.o mmdb_atom.o mmdb_graph.o mmdb_selmngr.o mmdb_align.o mmdb_tables.o math_.o mmdb_sbase.o mmdb_uddata.o mmdb_xml.o mmdb_bondmngr.o mmdb_ficif.o random_n.o -o libmmdb.dylib; ${LD} -dylib -dynamic -flat_namespace -undefined suppress -install_name:libccp4c.dylib -all_load libccp4c.a -o libccp4c.dylib -ldylib1.o;'
    SHARE_INST='${INSTALL_DATA} `pwd`/libmmdb.dylib ${libdir}/libmmdb.dylib; ${INSTALL_DATA} `pwd`/libccp4c.dylib ${libdir}/libccp4c.dylib;'
  fi
  LDFLAGS="-lccp4f -lccp4c -lmmdb \$(XCIF_LIB) \$(XLAPACK_LIB) \$(CXX_LIBS) \$(C_LIBS) \$(XLDFLAGS)"
  LDCFLAGS="-lccp4c -lmmdb \$(XCIF_LIB) \$(XLAPACK_LIB) \$(CXX_LIBS) \$(XLDFLAGS)"
  LDCXXFLAGS="-lccp4c -lmmdb \$(XCIF_LIB) \$(XLAPACK_LIB) \$(C_LIBS) \$(XLDFLAGS)"
    case `uname -sr` in
      *Darwin\ 7.* ) 
         XLDFLAGS="$XLDFLAGS -lcc_dynamic"
         if test "$shared_lib" = yes; then
           SHARE_LIB='${CXX} -qmkshrobj -flat_namespace -undefined suppress -Wl,-install_name,libmmdb.dylib bfgs_min.o mmdb_chain.o mmdb_manager.o mmdb_symop.o file_.o mmdb_cifdefs.o mmdb_mask.o mmdb_title.o linalg_.o mmdb_coormngr.o mmdb_mmcif.o mmdb_utils.o machine_.o mmdb_cryst.o mmdb_model.o stream_.o mattype_.o mmdb_file.o mmdb_rwbrook.o mmdb_atom.o mmdb_graph.o mmdb_selmngr.o mmdb_align.o mmdb_tables.o math_.o mmdb_sbase.o mmdb_uddata.o mmdb_xml.o mmdb_bondmngr.o mmdb_ficif.o random_n.o -o libmmdb.dylib; ${LD} -dylib -dynamic -flat_namespace -undefined suppress -install_name:libccp4c.dylib -all_load libccp4c.a -o libccp4c.dylib -lcc_dynamic -ldylib1.o;'
        fi
      ;;
# With apples move to intel CPUs, xlf and xlc need some help.
# You must have the 3.3 compilers for this to work as
# these give you __ZNSt24__default_alloc_templates_... as a
# global in libstdc++.a.  They are not global in libstdc++.dylib.
# Alternatively linking libstdc++.a into /usr/lib may work.
     *Darwin\ 8.* )
       if test -e /usr/lib/gcc/darwin/3.3/libstdc++.a ; then
         LDCXXFLAGS="$LDCXXFLAGS /usr/lib/gcc/darwin/3.3/libstdc++.a"
         LDFLAGS="$LDFLAGS /usr/lib/gcc/darwin/3.3/libstdc++.a"
       fi
    esac
  ;;
gnu_win32)
  if test x"$enable_x" = xyes; then
    echo "! Xwindows installation has not been tested    !"
    echo "! for this system and so will not be attempted.!"
    enable_x=no
  fi
  case `uname -sr` in
    CYGWIN32_*)
       echo; echo "! You will need the fsplit utility"
       echo; echo "*************************************************************"
       echo " ! Sorry but you MUST also do a minor change to \$CPROG/Makefile and"
       echo " ! (to be safe) \$CPROG/Makefile.in."
       echo " ! sfcheck will not compile with the object sfch_unix and so all"
       echo " ! cases of sfch_unix.o or sfch_unix.f must be replaced with "
       echo " ! sfch_linux.o or sfch_linux.f prior to makeing the suite."
       echo " ! This will eventually be automated!"; echo
       ;;
    *)
       echo "! This doesn't appear to be a gnu32 system. You should run"
       echo "! configure on a machine of the correct type."
       exit 1 ;;
  esac
  test "$with_f2c" && M4=${M4:-"m4 -D_f2c=1"}
  test "$with_f2c" && XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"}
  test ! "$with_f2c" && M4=${M4-"m4 -D_g77=1"}
  test ! "$with_f2c" && XCFLAGS=${XCFLAGS:-"-DG77 -D_WIN32 -DPROTOTYPE"}
  test ! "$with_f2c" && XCXXFLAGS=${XCXXFLAGS:-"-DG77 -D_WIN32"}
  FC=${FC:-g77}
  CC=${CC:-gcc}
  CXX=${CXX:-g++}
# Michael Wahl says this is sometimes needed: may need to be removed.
  XFFLAGS=${XFFLAGS:-"-fno-second-underscore"}
  FOPTIM=${FOPTIM:-"-O"}
  COPTIM=${COPTIM:-"-O"}
  INSTALL_DATA=${INSTALL_DATA:-"cp"}
  INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
  SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM'"}
  ;;
freebsd)
	case `uname -sr` in
		FreeBSD*) ;;
		*)
			echo "! This doesn't appear to be a FreeBSD system.
  You should run configure on a machine of the correct type."
    	exit 1 ;;
	esac
  if test "$with_f2c" ; then 
    M4=${M4:-"m4 -D_f2c=1"}
    XCFLAGS=${XCFLAGS:-"-DPROTOTYPE"}
    XFFLAGS=${XFFLAGS:-'-Nx400'}
    XCXXFLAGS=${XCXXFLAGS:-" "}
    FOPTIM=${FOPTIM:-"-O"}
    SETFLAGS=${SETFLAGS:-""}
  else
#g77 config from Tim Gruene
    MAKE=${MAKE:-gmake}
    M4=${M4:-"m4 -D_g77=1"}
    XCFLAGS=${XCFLAGS:-"-DG77 -DPROTOTYPE -DHAVE_G2C_H"}
#Note, space is important, otherwise XCXXFLAGS defaults to XCFLAGS
    XCXXFLAGS=${XCXXFLAGS:-" "}
    FC=${FC:-g77}
    CC=${CC:-gcc}
    CXX=${CXX:-g++}
    XFFLAGS=${XFFLAGS:-"-fno-second-underscore -fno-globals"}
    if test ! "$warnings" = yes; then
      XFFLAGS="-w $XFFLAGS"
      XCFLAGS="-w $XCFLAGS"
      XCXXFLAGS="-w $XCXXFLAGS"
    fi
    FOPTIM=${FOPTIM:-"-O"}
    COPTIM=${COPTIM:-"-O"}
    INSTALL_DATA=${INSTALL_DATA:-"cp"}
    INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"}
    SETFLAGS=${SETFLAGS:-"sftools_FLAGS='$XFFLAGS $FOPTIM' \
                      arp_waters_FLAGS='$XFFLAGS $FOPTIM -fforce-mem'"}
    XDL_LIB=${XDL_LIB:-"-L${CCP4_LIB} -lxdl_view"}
    XWIN_LIB=${XWIN_LIB:-"-L/usr/X11R6/lib -lXt -lSM -lX11 -lICE"}
    XTYPE=${XTYPE:-"LINUX"}
    XLDFLAGS=${XLDFLAGS:-"-lstdc++ -lg2c -lm"}
    if test "$shared_lib" = yes; then
    SHARE_LIB=${SHARE_LIB:-'ld -shared -soname libmmdb.so --whole-archive -o libmmdb.so libmmdb.a; ld -shared -soname libccp4c.so --whole-archive -o libccp4c.so libccp4c.a; ld -shared -soname libccp4f.so --whole-archive -o libccp4f.so libccp4f.a'}
    SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.so $(libdir)/libmmdb.so; $(INSTALL_DATA) `pwd`/libccp4c.so $(libdir)/libccp4c.so; $(INSTALL_DATA) `pwd`/libccp4f.so $(libdir)/libccp4f.so; '
    XLDFLAGS="-Wl,-rpath,$CLIB $XLDFLAGS"
    fi
  # Set Mapslicer command library flags
  # Cannot figure out the options for building shared at the moment so
  # don't bother
    MAPSLICER_SHARE=${MAPSLICER_SHARE:-""}
  fi
  ;;
generic) ;;			# just the defaults (library.c will barf)
esac

### defaults for the variables if not set above:

RANLIB=${RANLIB:-ranlib} 	# ranlib for libraries -- Berzerkeley has it,
				# SysVile doesn't use it
FC=${FC:-f77}			# fortran compiler
# some of the extra configures check F77 not FC
F77=${F77:-"$FC"}
# XFFLAGS (special fortran flags) null by default
CC=${CC:-cc}			# C compiler
XCFLAGS=${XCFLAGS:-""}		# special C flags
FOPTIM=${FOPTIM:-""}		# Fortran optimisation flag
COPTIM=${COPTIM:-"-O"}		# C optimisation flag
LNS=${LNS:-"ln -s"}		# make symbolic link or copy if system
				# doesn't have symbolic links, because can't hard link across
				# file systems [fixme: configure could test ability to hard
				# link from $srcdir to . ]
# default CXX options to those for C
CXXOPTIM=${CXXOPTIM:-"$COPTIM"}
XCXXFLAGS=${XCXXFLAGS:-"$XCFLAGS"}
CXX=${CXX:-"$CC"}

# how to run m4 to preprocess unix.m4
# The BSD4.2 m4 doesn't allow any command-line flags.  With it
# `pre-defines' will have to be specified in an extra file and sync
# lines can't be inserted.  Actually, sync lines probably lose for
# various reasons, so don't use them.  Where there's a choice you
# probably want the SysVile m4.
if test -z "$M4"; then
  if test "$with_f2c"; then
    M4="m4 -D_f2c=1"
  else
    M4=m4
  fi
else true
fi
MAKE=${MAKE:-make}      		# We need the variable MAKE for recursion in
				# the makefiles and some makes don't set it.  Setting it with
				# configure prevents using e.g., gmake, pmake at different
				# times
F=${F:-f}			# extension for fortran files (now always .f)

test "$with_f2c" && test "$hush" != 1 && XCFLAGS="$XCFLAGS -DF2C" || true

# if we do not have CXX_LIBS, lets try and get it
# to be done
# XLDFLAGS (extra load flags e.g., for libraries) null by default
  LDFLAGS=${LDFLAGS:-"-lccp4f -lccp4c -lmmdb \$(XCIF_LIB) \$(XLAPACK_LIB) \$(CXX_LIBS) \$(XLDFLAGS)"}
  LDCFLAGS=${LDCFLAGS:-"-lccp4c -lmmdb \$(XCIF_LIB) \$(XLAPACK_LIB) \$(CXX_LIBS) \$(XLDFLAGS)"}
  LDCXXFLAGS=${LDCXXFLAGS:-"-lccp4c -lmmdb \$(XLDFLAGS) \$(XCIF_LIB) \$(XLAPACK_LIB)"}

# SETFLAGS defines individual FCFLAGS for some targets which need
# special treatment, probably through optimiser problems and is
# normally null.  If program foo needs flags -bar and -baz, define
# SETFLAGS="foo_FLAGS=-bar\ -baz".  To express null flags use use
# foo_FLAGS=' '.
# n.b. amore has horrible data-aliasing problems -- always turn off optimistion
# in the hope they won't bite...
# Actually, -O0 isnt always valid...
#SETFLAGS=${SETFLAGS:-"amore_FLAGS=$XCFLAGS\ $LDFLAGS\ -O0"}
INSTALL_PROGRAM=${INSTALL_PROGRAM:-"cp"} # command to install executables --
					# use BSD install if available, to
					# avoid chaos with running programs
INSTALL_DATA=${INSTALL_DATA:-"cp"} # install for non-executables -- BSD install
				  # with appropriate -m if available
XMKMF=${XMKMF:-"xmkmf"}

test -z "$MAKE" || MAKELINE="MAKE = $MAKE"

test "$shared_lib" = yes && test -z "$SHARE_LIB" &&
  echo "! --with-shared-libs not supported for $system" || true

if test "$shared_lib" = yes; then
	case $system in
# fixme: I think this is wrong and was corrected previously.
# LD_LIBRARY_PATH probably works -- needs checking.
# 	osf1) test -z "$_RLD_LIST" &&
# 			echo; echo "! Set _RLD_LIST to use the shared library"; echo; ;;
	*) test -z "$LD_LIBRARY_PATH" &&
			( echo; echo "! Set LD_LIBRARY_PATH to use the shared library"; echo; ) ;;
  esac
else true
fi

# some setting up for xwindows - or not
if test x"$enable_x" = xyes; then
    DIRS=". $src $unsupp $xwindir $rotgendir \
           lib/src lib/data"
    /bin/cp $xwindir/XCCPJIFFY/Imakefile $xwindir/XCCPJIFFY/Imakefile.bak
    echo "#define $XTYPE" > $xwindir/XCCPJIFFY/Imakefile
    echo "PLOT_COMMAND = " $PLOT_COMMAND >> $xwindir/XCCPJIFFY/Imakefile 
    echo "PRINT_COMMAND = " $PRINT_COMMAND >> $xwindir/XCCPJIFFY/Imakefile
    cat $xwindir/XCCPJIFFY/Imakefile.in >> $xwindir/XCCPJIFFY/Imakefile
else
    if test -f x-windows/Makefile; then 
      /bin/mv x-windows/Makefile x-windows/Makefile.old
      echo 
      echo "* an old x-windows/Makefile has been moved to "
      echo "* x-windows/Makefile.old for safe keeping!"
    else true
    fi
    DIRS=". $src $unsupp lib/src lib/data"
fi

### Test for working m4 utility
echo
if test -f test_m4.m4; then
  /bin/rm test_m4.m4
fi
if test -f test_m4.f; then
  /bin/rm test_m4.f
fi
cat > test_m4.m4 <<EOF
define(_value,1)
C test for working m4 utility
      SUBROUTINE DUMMY(IDUM)
      IMPLICIT NONE
      INTEGER IDUM
      IDUM = _value
      RETURN
      END
EOF
test_m4="$M4 test_m4.m4 > test_m4.f"
echo -n " Testing command for running m4 ($M4) ... "
if { (eval $test_m4 2>/dev/null) 2>&1; } && test -s test_m4.f ; then
  # m4 appears to be working
  echo "ok"
  /bin/rm test_m4.f test_m4.m4
else
  echo "command failed"
  echo
  echo "! There is a problem with the m4 command on this system."
  echo "! The CCP4 suite cannot be built without the m4 utility."
  /bin/rm test_m4.m4
  exit 1
fi

### Define rxdir for Makefile
rxdir=""

### Set CCIF variables, and run separate configure unless disabled
if test "$disable_ccif" = yes; then
# disable CCIF stuff
  ccifdir= 
  XCIF_LIB= 
  CIFLIBTARGETS=
  CIFLIBOBJS=
  CIFTARGETS=
  if test ! -f $srcdir/lib/src/harv_orig.f; then 
     /bin/mv $srcdir/lib/src/harvlib.f $srcdir/lib/src/harv_orig.f; else true; fi
  /bin/cp $srcdir/lib/src/harv_dummy.f $srcdir/lib/src/harvlib.f
else
# run configure for CCIF library
  ccifdir=lib/ccif
  XCIF_LIB="-L$srcdir/lib/ccif -lccif"
  CIFLIBTARGETS=cciflib
  CIFLIBOBJS="\$(LF)(cciflib.o)"
  CIFTARGETS=cif2mtz
  if test -f $srcdir/lib/src/harv_orig.f; then 
     /bin/cp $srcdir/lib/src/harv_orig.f $srcdir/lib/src/harvlib.f; else true; fi
  CFLAGS="${COPTIM} ${XCFLAGS}"
  FFLAGS="${FOPTIM} ${XFFLAGS}"
  CXXFLAGS="${CXXOPTIM} ${XCXXFLAGS}"
  if test "$CC" = gcc && test "$shared_lib" = yes; then
    CFLAGS="${COPTIM} ${XCFLAGS} -fPIC"
    FFLAGS="${FOPTIM} ${XFFLAGS} -fPIC"
    CXXFLAGS="${CXXOPTIM} ${XCXXFLAGS} -fPIC"
  fi
  export CFLAGS CXXFLAGS FFLAGS SHARED_LIB_CFLAGS SHARED_LIB_FFLAGS
  if test "$shared_lib" = yes; then 
    xopts="--enable-shared=yes"
  else
    xopts="--enable-shared=no"
  fi
  if test "$system" = sunos64; then
    xopts="$xopts --enable-64-bit=yes"
  fi
  if test "$with_rxdispencer" = yes; then
    rxdir="lib/rxdispencer"
    echo 
    echo "Running separate configure for rxdispencer."
    echo
    MAKE=${MAKE:-make}
    cd lib/rxdispencer
    if [ "X$LIBFOPTIM" != "X" ]; then
      FOPTIM_save=$FOPTIM
      FOPTIM=$LIBFOPTIM
      FFLAGS="${FOPTIM} ${XFFLAGS}"
    fi
    if [ "X$LIBCOPTIM" != "X" ]; then
      COPTIM_save=$COPTIM
      COPTIM=$LIBCOPTIM
      CFLAGS="${COPTIM} ${XCFLAGS}"
    fi
    ./configure --srcdir=${srcdir}/lib/rxdispencer
    if [ "X$LIBFOPTIM" != "X" ]; then
      FOPTIM=$FOPTIM_save
      FFLAGS="${FOPTIM} ${XFFLAGS}"
    fi
    if [ "X$LIBCOPTIM" != "X" ]; then
      COPTIM=$COPTIM_save
      CFLAGS="${COPTIM} ${XCFLAGS}"
    fi
    $MAKE
    cd ../..
    RX_H="$srcdir/lib/rxdispencer/rx"
    RX_L="$configdir/lib/rxdispencer/rx"
    export RX_H RX_L
  fi
  echo 
  echo "Running separate configure for CCIF library."
  echo
  cd lib/ccif
  echo "Updating modification times for configuration files"
  echo "Please wait..."
  for i in configure.in aclocal.m4 configure Makefile.in; do
    touch $i && sleep 1   
  done
  echo "...done."      

  if [ "X$LIBFOPTIM" != "X" ]; then
    FOPTIM_save=$FOPTIM
    FOPTIM=$LIBFOPTIM
    FFLAGS="${FOPTIM} ${XFFLAGS}"
  fi
  if [ "X$LIBCOPTIM" != "X" ]; then
    COPTIM_save=$COPTIM
    COPTIM=$LIBCOPTIM
    CFLAGS="${COPTIM} ${XCFLAGS}"
  fi
  ( touch /tmp/$$.cache_file 2>/dev/null && \
    cat /dev/null > /tmp/$$.cache_file && \
    ./configure $xopts --libdir=${libdir} --srcdir=${srcdir}/lib/ccif --cache-file=/tmp/$$.cache_file ) || \
    ./configure $xopts --libdir=${libdir} --srcdir=${srcdir}/lib/ccif
  rm -f /tmp/$$.cache_file
  if [ "X$LIBFOPTIM" != "X" ]; then
    FOPTIM=$FOPTIM_save
    FFLAGS="${FOPTIM} ${XFFLAGS}"
  fi
  if [ "X$LIBCOPTIM" != "X" ]; then
    COPTIM=$COPTIM_save
    CFLAGS="${COPTIM} ${XCFLAGS}"
  fi
  cd ../..
  echo
  echo "Returning to main configure."
  echo
fi

### Set variables for LAPACK build, and run configure if enabled
if test "$disable_lapack" = yes; then
  # disable BLAS and LAPACK
  lapackdir=
  XLAPACK_LIB=
else
  # configure to use LAPACK and BLAS functions
  echo 
  echo "********* BLAS AND LAPACK CONFIGURATION ***********"
  echo
  echo "Warning: this option has not been extensively tested!"
  echo "Please report problems to ccp4@ccp4.ac.uk"
  # Search for vendor LAPACK/BLAS first
  if test ! "$with_netlib_lapack" ; then
    # Initialise variables to blank
    lapackdir=
    XLAPACK_LIB=
    # Possible directories to check for vendor or pre-existing LAPACK or
    # BLAS - add to these if you want to test others
    trydirs="/lib /usr/lib /usr/local/lib"
    # Possible library names
    # These are the names like xxxx where the library will be libxxxx.a
    # or libxxxx.so
    echo
    echo "Guessing names for native/vendor LAPACK and/or BLAS libraries"
    echo "on this system"
    case $system in
      linux | linux64 )
        # linux users will usually have them in /usr/lib but dont call it
        trylapack="lapack"
        tryblas="blas"
        # if code is non_shared then this can lead to problems. both blas and lapack
        # need to be resolved even if they are not called!
        if test "$non_shared" = yes; then
          echo "You are compiling linux non_shared. This sometimes causes problems "
          echo "  so checking for requirements." 
          echo "Checking: try to link library against test program"
          if test -f testlink.f || test -f testlink ; then
            rm -f testlink*
          fi 
          cat > testlink.f <<EOF
      PROGRAM TESTLINK
C A bit of scala code to test the linking
      real bf(3), bnorm
c
      integer maxbmt
      parameter (maxbmt = 2)
      double precision B(maxbmt,maxbmt), eigval(maxbmt),
     $   eigvec(maxbmt,maxbmt), w(5*maxbmt)
      integer m, ia, ix, istat
c
      B(1,1) = 1.00
      B(1,2) = 1.00
      B(2,1) = 1.00
      B(2,2) = 1.00
c
      m = maxbmt
      ia = maxbmt
      ix = maxbmt
      call dsyev('N', 'L', m, B, ia, eigval, w, 5*maxbmt, istat)
      end
EOF
          #firslty test without -lblas
          test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -llapack"
          echo $test_compile
          if { (eval $test_compile >& /dev/null ) 2>&1; } && test -s testlink ; then
            # Compilation was okay
            echo "... only -llapack needed"
            XLAPACK_LIB="-llapack"
            # Set the next two variables so that configure
            # doesn't try to build netlib libraries
            LAPACKLIB="lapack"
            noblas=yes
            trylapack=
            tryblas=
          else
	    echo "more than just -llapack needed...."
            test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -llapack -lblas"
            echo $test_compile
            if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
              # Compilation was okay
              echo "...-llapack and -lblas were needed"
              XLAPACK_LIB="-llapack -lblas"
              # Set the next two variables so that configure
              # doesn't try to build netlib libraries
              LAPACKLIB="lapack blas"
              noblas=no
              trylapack=
              tryblas=
	    else
              echo "....could not find either lapack or blas."
	    fi
          fi
        fi
        # add 64 bit libs
        case $system in
          linux64 ) trydirs="/usr/lib64 ${trydirs}" ;;
        esac

        ;;
      osf1)
        # OSF1 has dxml (old version) and cxml
        # which should have both lapack and blas 
        trylapack="dxml cxml"
        tryblas=
        trydirs="${trydirs} /usr/shlib"
        ;;
      irix)
        # Additional search paths for IRIX
        trydirs="${trydirs} /usr/lib32"
        # SCSL should have both LAPACK and BLAS
        trylapack="scs"
        tryblas="blas"
        ;;
      irix64)
        # Additional search paths for IRIX64
        trydirs="${trydirs} /usr/lib64"
        # SCSL should have both LAPACK and BLAS
        trylapack="scs"
        tryblas="blas"
        # Extra compiler flags?
        #XLAPACKFLAGS="-OPT:IEEE_NaN_inf=ON"
        ;;
      aix)
        # Additional search paths for AIX
        trydirs="${trydirs}" 
        # AIX might have ESSL library - blas only I think
        trylapack=
        tryblas="essl"
        ;;
      hpux)
        # Additional search paths for HPUX
        trydirs="${trydirs} /opt/fortran/lib /opt/fortran/lib/pa2.0 /opt/mlib/lib/pa2.0"
        # HPUX should have both LAPACK (part of mlib) and BLAS
        trylapack="lapack"
        tryblas="blas"
        # Extra compiler flags?
        # +U77 required for ETIME function - this is already in XFFLAGS
        #XLAPACKFLAGS="+U77"
        ;;

      sunos | sunos64)
        # Sun has libraries with BLAS and LAPACK invoked using
        # -xlic_lib=sunperf
        trylapack=
        tryblas=
        echo "SunOs can use the Sun Performance Library (if installed)"
        echo "which has both BLAS and LAPACK 3.0"
        echo 
        echo "Looking for a valid library to use..."
        echo
	# Loop over the possible library names
        try_libs="sunperf"
        for testlib in $try_libs
        do
          if test ! "$XLAPACK_LIB" ; then
            # Try running a test compile to see if this a valid library
            if test -f testlink.f || test -f testlink ; then
              rm -f testlink*
            fi
            cat > testlink.f <<EOF
c Test fortran program to link against library
      PROGRAM TESTLINK
      IMPLICIT NONE
      INTEGER A
      A = 1
      STOP
      END
EOF
            test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -dalign -xlic_lib=$testlib"
            echo $test_compile
            if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
              # Compilation was okay
              echo "... -xlic_lib=$testlib is okay"
              XLAPACK_LIB="-dalign -xlic_lib=$testlib"
              # Set the next two variables so that configure
              # doesn't try to build netlib libraries
              LAPACKLIB="$testlib"
              noblas=yes
            else
              # Compilation failed
              echo "... cannot use -xlic_lib=$testlib"
            fi
            # End of test for testlib
          fi
          # End of loop over possible lib names
        done
	# Report if no suitable library was found
        if test ! "$XLAPACK_LIB" ; then
          echo
          echo "No suitable LAPACK library was found."
          echo "This may be because the Sun Performance Library is not"
          echo "installed on your system"
          echo "Contact your system adminstrator or Sun vendor"
        fi
        ;;
      Darwin )
        # Darwin has libraries with BLAS and LAPACK invoked using 
        # -framework vecLib
        echo "Darwin can use the vecLib Library (if installed)"
        echo "which has both BLAS and LAPACK 3.0"
        echo
        # This is a special case so try running a test compile
        echo "Checking: try to link library against test program"
        if test -f testlink.f || test -f testlink ; then
          rm -f testlink*
        fi
        cat > testlink.f <<EOF
c Test fortran program to link against library
      PROGRAM TESTLINK
      IMPLICIT NONE     
      INTEGER A
      A = 1
      STOP
      END
EOF
        test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -framework vecLib"
        echo $test_compile
        if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
          # Compilation was okay
          echo "... -framework vecLib is okay"
          XLAPACK_LIB="-framework vecLib"
          # Set the next two variables so that configure
          # doesn't try to build netlib libraries
          LAPACKLIB="vecLib"
          noblas=yes
        else
#alternative linking for vecLib libraries
          case `uname -sr` in
            *Darwin\ 7.* ) test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -lcc_dynamic -Wl,-framework -Wl,vecLib" ;;
            * ) test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -Wl,-framework -Wl,vecLib" ;;
          esac

        echo $test_compile
        if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
          # Compilation was okay
          echo "... -framework vecLib is okay"
          XLAPACK_LIB="-Wl,-framework -Wl,vecLib"
          # Set the next two variables so that configure
          # doesn't try to build netlib libraries
          LAPACKLIB="-Wl,-framework -Wl,vecLib"
          noblas=yes
        else
          # Compilation failed
          echo "... cannot use -framework vecLib"
          echo
         fi
        fi
        trylapack=
        tryblas=
# try the fink installation
        trydirs="${trydirs} /sw"
        ;;
      Darwin_ibm_compilers )
        # Darwin has libraries with BLAS and LAPACK invoked using
        # -framework vecLib
        echo "Darwin can use the vecLib Library (if installed)"
        echo "which has both BLAS and LAPACK 3.0"
        echo
        # This is a special case so try running a test compile
        echo "Checking: try to link library against test program"
        if test -f testlink.f || test -f testlink ; then
          rm -f testlink*
        fi
        cat > testlink.f <<EOF
c Test fortran program to link against library
      PROGRAM TESTLINK
      IMPLICIT NONE
      INTEGER A
      A = 1
      STOP
      END
EOF
      case `uname -sr` in
        Darwin\ 8* )
        XLAPACK_LIB="-L/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A -lLAPACK -lBLAS"
        test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f $XLAPACK_LIB"
        ;;
        Darwin\ 7* )
        XLAPACK_LIB="-L/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A -lLAPACK -lBLAS"
        test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -lcc_dynamic $XLAPACK_LIB"
        ;;
        *)
        XLAPACK_LIB="/System/Library/Frameworks/vecLib.Framework/Versions/Current/VecLib"
        test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f $XLAPACK_LIB"
        esac
        echo $test_compile
        if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
          # Compilation was okay
          echo "... -framework vecLib is okay"
          # Set the next two variables so that configure
          # doesn't try to build netlib libraries
          LAPACKLIB="vecLib"
          noblas=yes
        else
          # Compilation failed
          XLAPACK_LIB=""
          echo "... cannot use -framework vecLib"
          echo
        fi
        trylapack=
        tryblas=
# try the fink installation
        trydirs="${trydirs} /sw"
        ;;
#       linux_ia64_sgi_altix)
# SGI Japan
      ia64_linux_intel) 
        # Additional search paths for Linux/IA64
        trydirs="${trydirs} /opt/scsl/lib /usr/lib /usr/local/lib"
        # SCSL and MKL should have both LAPACK and BLAS
        trylapack="scs mkl lapack"
        tryblas="scs mkl blas"
        ;;
      linux_ibm_compilers )
        trylapack="lapack"
        tryblas="blas"
        ;;
      linux64_ibm_compilers )
        trydirs="/usr/lib64 ${trydirs}"
        trylapack="lapack"
        tryblas="blas"
        ;;
      *)
        echo "The guesses for this system may not be correct - please"
        echo "e-mail ccp4@ccp4.ac.uk if you have any extra information"
	echo
        # Default guess is just libblas
        trylapack="lapack"
        tryblas="blas"
        ;;
    esac
    #
    # Search for LAPACK libraries
    #
    # Write out what the guesses are
    if test "$trylapack" ; then
      echo "Possible LAPACK library names for this system:"
      for libname in $trylapack
      do
        echo "   lib$libname"
      done
      # Possible library name extensions
      tryexts="a so dylib"
      # Now loop over all the possibilities and see if anything
      # turns up
      echo
      echo "Searching for libraries with LAPACK and BLAS:"
      for testdir in $trydirs
      do
        for testlib in $trylapack
        do
          for ext in $tryexts
          do
            if test ! "$LAPACKLIB"; then
              if test -s "$testdir/lib$testlib.$ext" ; then
                echo "...found LAPACK library: $testdir/lib$testlib.$ext"
                # Now try and link to a test program
                # This is really for IRIX where libraries can be
                # o32 or n32
                echo "   Testing: try to link library against test program"
                if test -f testlink.f || test -f testlink ; then
                  rm -f testlink*
                fi
                cat > testlink.f <<EOF
c Test fortran program to link against library
      PROGRAM TESTLINK
      IMPLICIT NONE
      INTEGER A
      A = 1
      STOP
      END
EOF
                test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -L$testdir -l$testlib"
                test_ccompile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -L$testdir -l$testlib $XLDFLAGS"
                echo $test_compile
                if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
                  have_lapack=yes
                else
# cover clapack option
                  echo $test_ccompile
                  if { (eval $test_ccompile ) 2>&1; } && test -s testlink ; then
                    have_lapack=yes
                  fi
                fi
                if test x$have_lapack = xyes ; then
                # This one is okay
                  LAPACKLIB="$testlib"
                  LAPACKDIR="$testdir"
                  echo "Link ok - using lib$LAPACKLIB from $LAPACKDIR"
		  #
		  XLAPACK_LIB="-L$LAPACKDIR -l$LAPACKLIB"
                  #
                  # Test to see if we need BLAS too
                  # Do this by trying to compile a test program
                  # Use the LSAME test for now
                  echo
                  echo "   * Checking whether we need a separate BLAS library *"
                  echo "   Testing: try linking library against test program"
                  cd lib/lapack/test
                  if test -f testlsame ; then
                    rm -f testsame testlsame.o
                  fi
                  test_compile="$FC $FOPTIM $XFFLAGS -o testlsame lsametst.f -L$LAPACKDIR -l$LAPACKLIB"
                  test_ccompile="$FC $FOPTIM $XFFLAGS -o testlsame lsametst.f -L$LAPACKDIR -l$LAPACKLIB $XLDFLAGS"
                  echo $test_compile
                  if { ( eval $test_compile) 2>&1;} && test -s testlsame ; then
                    have_blas=yes
                  else
#cblas route
                    echo $test_ccompile
                    if { ( eval $test_ccompile) 2>&1;} && test -s testlsame ; then
                      have_blas=yes
                    fi
                  fi
                  if test x$have_blas = xyes ; then
                    echo "Test program okay - additional separate BLAS not required"
                    noblas=yes
                  else
                    echo "Test program failed - need a separate BLAS library"
                  fi
                  cd ../../..
                else
                # Keep looking
                  echo "   link failed - cannot use lib$testlib"
                fi
              fi
            fi
          done
        done
        if test ! "$LAPACKLIB"; then
          echo "...nothing in $testdir"
        fi
      done
    fi

    # If LAPACKLIB hasn't been set at this point then no LAPACK library
    # was found 
    if test ! "$LAPACKLIB" ; then
      echo
      echo "No pre-existing LAPACK library found - NetLib LAPACK will be built instead"
      make_lapack=lapacklib
    fi
    # Look for possible BLAS
    if test ! "$noblas" ; then
      if test "$tryblas" ; then
        echo
        echo "Possible BLAS library names for this system:"
        for libname in $tryblas
        do
          echo "   lib$libname"
        done
        # Possible library name extensions
        tryexts="a so"
        # Now loop over all the possibilities and see if anything
        # turns up
        echo
        echo "Searching for libraries with BLAS:"
        for testdir in $trydirs
        do
          for testlib in $tryblas
          do
            for ext in $tryexts
            do
              if test ! "$BLASLIB"; then
                if test -s "$testdir/lib$testlib.$ext" ; then
                  echo "...found BLAS library: $testdir/lib$testlib.$ext"
                  # Now try and link to a test program
                  # This is really for IRIX where libraries can be
                  # o32 or n32
                  echo "   Testing: try to link library against test program"
                  if test -f testlink.f || test -f testlink ; then
                    rm -f testlink*
                  fi
                  cat > testlink.f <<EOF
c Test fortran program to link against library
      PROGRAM TESTLINK
      IMPLICIT NONE
      INTEGER A
      A = 1
      STOP
      END
EOF
                  test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -L$testdir -l$testlib"
                  test_ccompile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -L$testdir -l$testlib $XLDFLAGS"
                  echo $test_compile
                  if { ( eval $test_compile) 2>&1;} && test -s testlink ; then
                    have_blas=yes
                  else
                    echo $test_ccompile
                    if { ( eval $test_compile) 2>&1;} && test -s testlink ; then
                      have_blas=yes
                    fi
                  fi
                  if test x$have_blas = xyes ; then
                    # This one is okay
                    BLASLIB="$testlib"
                    BLASDIR="$testdir"
                    BLASEXT="$ext"
                    echo "Link ok - using lib$BLASLIB from $BLASDIR"
		    XLAPACK_LIB="$XLAPACK_LIB -L$BLASDIR -l$BLASLIB"
                  else
                  # Keep looking
                    echo "   link failed - cannot use lib$testlib"
                  fi
                fi
              fi
            done
          done
          if test ! "$BLASLIB"; then
            echo "...nothing in $testdir"
          fi
        done
      fi
      # Do we need to build BLAS too?      
      if test ! "$BLASLIB" ; then
        echo
        echo "No pre-existing BLAS library was found - NetLib BLAS will be built instead"
        echo "This may result in poorer performance of the LAPACK routines"
        make_blas=blaslib
        BLASLIB=blas
        BLASDIR="$CCP4_LIB/lapack"
        BLASEXT="a"
      fi
    fi
  # Otherwise force building of NetLib BLAS and LAPACK libs
  else
    echo
    echo "! Force building of NetLib BLAS and LAPACK..."
    make_blas=blaslib
    make_lapack=lapacklib
    BLASLIB=blas
    BLASDIR="$CCP4_LIB/lapack"
    BLASEXT="a"
  fi
  # need to know if we the lapack library was linked using the C or
  # fortran linker
  if test -f testlink.f || test -f testlink || test -f testlink.c ; then
    rm -f testlink*
  fi
  cat > testlink.c <<EOF
#define MAXBMT 2

int main(int argc, char *argv) {
/* A bit of scala code to test the linking */
   float bf[3], bnorm;
   double B[MAXBMT][MAXBMT], eigval[MAXBMT],
     eigvec[MAXBMT][MAXBMT], w[5*MAXBMT];
   int m, ia, ix, istat;

   B[0][0] = 1.00;
   B[1][0] = 1.00;
   B[1][0] = 1.00;
   B[1][1] = 1.00;

   m = MAXBMT;
   ia = MAXBMT;
   ix = MAXBMT;
   dsyev('N', 'L', &m, B, &ia, eigval, w, 5*MAXBMT, &istat);
   return 0;
}
EOF
  echo " Test C linking for lapack library"
  test_compile="$CC $COPTIM $XCFLAGS -o testlink testlink.c $XLAPACK_LIB"
  echo $test_compile
  if { (eval $test_compile 2>&1 ); }  || test -s testlink ; then
   rm -f testlink
   else
    case $system in
      irix* | Darwin* | linux* )
        LDCFLAGS="$LDCFLAGS \$(F_LIBS)"
        LDCXXFLAGS="$LDCXXFLAGS \$(F_LIBS)" ;;
      osf1 )
       LDCFLAGS="$LDCFLAGS \$(F_LIBS) -lm -lmld"
       LDCXXFLAGS="$LDCXXFLAGS \$(F_LIBS) -lm -lmld" ;;
    esac
  fi
  if test -f testlink.c || test -f testlink ; then
    rm -f testlink*
  fi
 
  #
  # Generate makefiles
  if (test -n "$make_lapack" || test -n "$make_blas") ; then
    # If building LAPACK then get the right version of ilaenv
    # for the IEEE compliance (or otherwise) of this system
    # Maybe this needs to be set in the main body of configure?
    case $system in
      osf1)
        # OSF1 is non-IEEE-754 compliant (at least for V4.0)
        non_ieee="yes"
        ;;
      *)
        # In the absence of information to the contrary assume
        # that all other systems are IEEE-compliant
        non_ieee="no"
        ;;
    esac
    if test "$non_ieee" = yes; then
      echo
      echo "Assuming this system is not IEEE-754 compliant for Nan and infinity"
      echo "arithmetic"
      echo "Using the modified version of ILAENV appropriate for such a system" 
      cp -f lib/lapack/src/ilaenv-non-ieee.f lib/lapack/src/ilaenv.f
    else
      echo
      echo "Assuming this system is IEEE-754 compliant for Nan and infinity arithmetic"
      echo "Using the default version of ILAENV"
      cp -f lib/lapack/src/ilaenv-dist.f lib/lapack/src/ilaenv.f
    fi
    # No options for shared libraries yet
    XFFLAGS_LAPACK=""
    if test "$shared_lib" = yes; then
      echo
      echo "! Sorry... cannot configure make to build shared BLAS or"
      echo "! LAPACK libraries at present"
      # Check for and remove -fPIC as this may cause problems
      # for non-shared compilations
      echo
      echo "! Removing -fPIC (if present) from compiler flags for LAPACK"
      for i in ${XFFLAGS}; do
        if test "$i" = "-fPIC"; then true
        else
          XFFLAGS_LAPACK="${XFFLAGS_LAPACK} $i"
        fi
      done
      echo "! XFFLAGS_LAPACK=${XFFLAGS_LAPACK}"
    else
      XFFLAGS_LAPACK="${XFFLAGS}"
    fi
    #
    # Create the Makefile header for the LAPACK build
    cd lib/lapack
    echo
    echo "Creating make.inc header file for BLAS and/or LAPACK Makefiles..."
    if [ "X$LIBFOPTIM" != "X" ]; then
      FOPTIM_save=$FOPTIM
      FOPTIM=$LIBFOPTIM
      FFLAGS="${FOPTIM} ${XFFLAGS}"
    fi
    cat > make.inc <<EOF
#
SHELL = /bin/sh
#
MAKE     = ${MAKE:-make}
FORTRAN  = ${FC}
OPTS     = ${FOPTIM} ${XFFLAGS_LAPACK}
DRVOPTS  = \$(OPTS)
NOOPT    = ${NOOPT:--O0 ${XFFLAGS_LAPACK}}
LOADER   = 
#
ARCH     = ar
ARCHFLAGS= r
RANLIB   = ${RANLIB}
INSTALL_DATA = ${INSTALL_DATA}
libdir   = $libdir
#
BLASLIB     = lib${BLASLIB}.${BLASEXT}
LAPACKLIB   = liblapack.a
#
# These variables define targets in the main Makefile
blaslib   = ${make_blas}
lapacklib = ${make_lapack}
EOF
    echo "...done"
  #
  # Create the necessary Makefiles
  # BLAS:
    if test "$make_blas" = blaslib; then
      cd blas/src
      cat ../../make.inc Makefile.in > Makefile
      cd ../..
      echo
      echo "Created lib/blas/src/Makefile for BLAS compilation"
    else
      # Check that lsame and xerbla are available in BLAS
      # This is to prevent duplication of routines when building
      # Netlib versions, which can cause problems when linking
      CCP4_LAPACKAUX=
      if test "$make_lapack" = lapacklib; then
        cd test
        echo
        echo "Checking for LSAME in lib$BLASLIB"
        if test -f testlsame ; then
          rm -f testsame testlsame.o
        fi
        test_compile="$FC $FOPTIM $XFFLAGS -o testlsame lsametst.f -L$BLASDIR -l$BLASLIB"
        echo $test_compile
        if { ( eval $test_compile) 2>&1;} && test -s testlsame ; then
          echo "Found LSAME in lib$BLASLIB"
        else
          echo "LSAME not found: adding lsame.o to list of targets in LAPACK build"
          CCP4_LAPACKAUX="$CCP4_LAPACKAUX lsame.o"
        fi
	echo
        echo "Checking for XERBLA in lib$BLASLIB"
        if test -f testxerbla ; then
          rm -f testxerbla testxerbla.o
        fi
        test_compile="$FC $FOPTIM $XFFLAGS -o testxerbla xerblatst.f -L$BLASDIR -l$BLASLIB"
        echo $test_compile
        if { ( eval $test_compile) 2>&1;} && test -s testxerbla ; then
          # Found lsame
          echo "Found XERBLA in lib$BLASLIB"
        else
          echo "XERBLA not found: adding xerbla.o to list of targets in LAPACK build"
          CCP4_LAPACKAUX="$CCP4_LAPACKAUX xerbla.o"
        fi
        cd ..
      fi
      cat >> make.inc <<EOF

# Additional targets to include in the LAPACK build
# if not found in libblas
CCP4_LAPACKAUX = $CCP4_LAPACKAUX

EOF
    fi
  # LAPACK
    if test "$make_lapack" = lapacklib; then
      cd src
      cat ../make.inc Makefile.in > Makefile
      cd ..
      echo
      echo "Created src/Makefile for LAPACK compilation"
    fi
  # Top level Makefile
    cat make.inc Makefile.in > Makefile
    echo
    echo "Created top-level LAPACK Makefile."
    cd ../..
    #
    lapackdir=lib/lapack
    XLAPACK_LIB="-L$srcdir/lib/lapack -llapack -L$BLASDIR -l$BLASLIB"
# netlib lapack is in fortran, so we may need the fortran libraries when
# we are linking using the C or C++ compilers
    case $system in 
      irix* | Darwin* | linux* ) 
        LDCFLAGS="$LDCFLAGS \$(F_LIBS)" 
        LDCXXFLAGS="$LDCXXFLAGS \$(F_LIBS)" ;;
      osf1 ) 
       LDCFLAGS="$LDCFLAGS \$(F_LIBS) -lm -lmld"
       LDCXXFLAGS="$LDCXXFLAGS \$(F_LIBS) -lm -lmld" ;;
      sunos* ) 
       LDCFLAGS="$LDCFLAGS \$(F_LIBS)" 
       LDCXXFLAGS="$LDCXXFLAGS \$(F_LIBS)" ;;
    esac
  fi
  # Clean up
  if test -f testlink.f || test -f testlink ; then
    rm -f testlink*
  fi
  echo
  echo "Linking in LAPACK/BLAS using XLAPACK_LIB=\"${XLAPACK_LIB}\""
  echo 
  echo "***** BLAS AND LAPACK CONFIGURATION FINISHED *******"
  if [ "X$LIBFOPTIM" != "X" ]; then
    FOPTIM=$FOPTIM_save
    FFLAGS="${FOPTIM} ${XFFLAGS}"
  fi
fi

# installing fftw?
if test "${enable_fftw:+set}" = set; then
  enableval="$enable_fftw"
  case $enableval in
    yes) enable_fftw=yes ;;
    no) enable_fftw=no ;;
    *) enable_fftw=no ;;
  esac
else
  enable_fftw=yes
fi

# with-fftw same as enable, but with-fftw= disables
if test "${with_fftw:+set}" = set; then
  withval="$with_fftw"
  if test "x${withval}" != xyes ; then
    prefix_fftw=$withval
    enable_fftw=no
    if test -f ${withval}/include/sfftw.h ; then
      FFTW_LIBS="-L${withval}/lib -lsrfftw -lsfftw"
    else
      FFTW_LIBS="-L${withval}/lib -lrfftw -lfftw"
    fi
    FFTW_CXXFLAGS="-I${withval}/include"
  else
    enable_fftw=yes
  fi
fi

fftwdir=""
if test "$enable_fftw" = yes; then
  fftwdir="lib/fftw"
  prefix_fftw="${srcdir}/lib"
  CFLAGS="${COPTIM} ${XCFLAGS}"
  FFTW_LIBS="-L${srcdir}/lib -lrfftw -lfftw"
  FFTW_CXXFLAGS="-I${srcdir}/lib/fftw/fftw -I${srcdir}/lib/fftw/rfftw"
  export CFLAGS
# must use --enable-float
  xopts="--enable-float"
  if test "$shared_lib" = yes; then
    xopts="${xopts} --enable-shared=yes"
  else
    xopts="${xopts} --enable-shared=no"
  fi
  echo
  echo "********* FFTW CONFIGURATION ***********"
  echo
  cd ${srcdir}/lib/fftw
  # It is important for some systems that the files
  # configure.in, Makefile.am, aclocal.m4, configure,
  # and Makefile.in have the correct timestamp relative
  # to each other (Clemens Vonrhein)
  echo "Updating modification times for configuration files"
  echo "Please wait..."
  for i in configure.in Makefile.am aclocal.m4 configure Makefile.in ltconfig ltmain.sh; do
    touch $i && sleep 1
  done
  echo "...done."
  echo
  echo "configure $xopts --exec_prefix=${srcdir} --prefix=${srcdir} --bindir=${bindir} --libdir=${libdir}"
  ./configure $xopts --exec_prefix=${srcdir} --prefix=${srcdir} --bindir=${bindir} --libdir=${libdir}
  echo 
  echo "***** FFTW CONFIGURATION FINISHED *******"
  echo
  cd $srcdir
fi

# installing clipper?
if test "${enable_clipper:+set}" = set; then
  enableval="$enable_clipper"
  case $enableval in
    yes) enable_clipper=yes ;;
    no) enable_clipper=no ;;
    *) enable_clipper=no ;;
  esac
else
  enable_clipper=yes;
fi

clipperdir=""
if test "$enable_clipper" = yes; then
  clipperdir="lib/clipper"
  CXXFLAGS="${CXXOPTIM} ${XCXXFLAGS}"
  export CXXFLAGS
  if test "$shared_lib" = yes; then
    xopts="--enable-shared=yes"
  else
    xopts="--enable-shared=no"
  fi
#fftw setup
  if test "${prefix_fftw:+set}" = set ; then
    xopts="${xopts} --with-fftw=${prefix_fftw}"
  fi
  if test "${FFTW_LIBS:+set}" = set ; then
    xopts="${xopts} FFTW_LIBS=\"${FFTW_LIBS}\" FFTW_CXXFLAGS=\"${FFTW_CXXFLAGS}\""
  fi
#mmdb setup
  xopts="${xopts} --with-mmdb=${srcdir}"
#ccp4 setup
  xopts="${xopts} --with-ccp4=${srcdir}"
#interface setup
  xopts="${xopts} --enable-mmdb --enable-cif --enable-ccp4 --enable-minimol"
  echo   
  echo "********* CLIPPER CONFIGURATION ***********"
  echo
  cd ${srcdir}/lib/clipper
  # It is important for some systems that the files  
  # configure.in, Makefile.am, aclocal.m4, configure,
  # and Makefile.in have the correct timestamp relative
  # to each other (Clemens Vonrhein)
  echo "Updating modification times for configuration files"
  echo "Please wait..."
  for i in configure.ac Makefile.am aclocal.m4 configure Makefile.in ltconfig ltmain.sh; do
    touch $i && sleep 1
  done
  echo "...done."
  echo 
  echo "configure $xopts --exec_prefix=${srcdir} --prefix=${srcdir} --bindir=${bindir} --libdir=${libdir}"
  eval ./configure $xopts --exec_prefix=${srcdir} --prefix=${srcdir} --bindir=${bindir} --libdir=${libdir}
  echo 
  echo "***** CLIPPER CONFIGURATION FINISHED *******"
  echo   
  cd $srcdir
fi

# installing ssm? 
if test "${enable_ssm:+set}" = set; then
  enableval="$enable_ssm"
  case $enableval in 
    yes) enable_ssm=yes ;;
    no) enable_ssm=no ;;
    *) enable_ssm=no ;;
  esac
else 
  enable_ssm=yes;
fi

ssmdir=""
if test "$enable_ssm" = yes; then
  ssmdir="lib/ssm"
  CXXFLAGS="${CXXOPTIM} ${XCXXFLAGS}"
  export CXXFLAGS
  if test "$shared_lib" = yes; then
    xopts="--enable-shared=yes"
  else
    xopts="--enable-shared=no"
  fi
#mmdb setup 
  xopts="${xopts} --with-mmdb=${srcdir}"
  echo
  echo "********* SSM CONFIGURATION ***********"
  echo
  cd ${srcdir}/lib/ssm
  # It is important for some systems that the files
  # configure.in, Makefile.am, aclocal.m4, configure,
  # and Makefile.in have the correct timestamp relative
  # to each other (Clemens Vonrhein)
  echo "Updating modification times for configuration files"
  echo "Please wait..."
  for i in configure.in Makefile.am aclocal.m4 configure Makefile.in ltconfig ltmain.sh; do    touch $i && sleep 1
  done
  echo "...done."
  echo 
  echo "configure $xopts --exec_prefix=${srcdir} --prefix=${srcdir} --bindir=${bindir} --libdir=${libdir}"
  eval ./configure $xopts --exec_prefix=${srcdir} --prefix=${srcdir} --bindir=${bindir} --libdir=${libdir}
  echo
  echo "***** SSM CONFIGURATION FINISHED *******"
  echo   
  cd $srcdir
fi

### Set variables for CCTBX library build
if test "$disable_cctbx" = yes; then
  # disable cctbx build
  cctbxdir=
else
  cctbxdir=lib/cctbx
  if test ! -f $cctbxdir/ccp4_build; then
    echo
    echo "Cannot find file $cctbxdir/ccp4_build"
    echo "CCTBX and Phaser builds disabled."
    echo
    cctbxdir=
    disable_cctbx=yes
    disable_phaser=yes
  fi
# platform specific elements
# initial force static because of allowd compiler options
  if test "$disable_cctbx" != yes ; then
  cctbxopts=${cctbxopts:-""}
  case $system in
    *linux*)
      case $CXX in
        *icpc ) cctbxopts="$cctbxopts --compiler=icpc" ;;
        *icc ) cctbxopts="$cctbxopts --compiler=icc" ;;
        *ecc ) cctbxopts="$cctbxopts --compiler=ecc" ;;
        *) echo "CCTBX will use the default (gnu) compiler"
        esac
      ;;
    *irix*)
      case $CXX in
        *g++* | *c++* ) cctbxopts="$cctbxopts --compiler=gcc" ;;
        *) echo "CCTBX will use the native (CC -n32) compler"
      esac
      ;;
    osf1)
      case $CXX in
        *g++* | *c++* ) cctbxopts="$cctbxopts --compiler=gcc" ;;
        *) echo "CCTBX will use the native (cxx) compiler"
      esac
      ;;
    sunos*)
      case $CXX in
        *g++* | *c++* ) cctbxopts="$cctbxopts --compiler=gcc" ;;
        *) echo "CCTBX will use the native (CC) compiler"
      esac
      ;;
    Darwin*)
      case $CXX in
        *g++* | *c++* ) cctbxopts="$cctbxopts --compiler=gcc" ;;
        *) echo "CCTBX will use the default (gnu) compiler"
      esac
      ;;
    gnu_win32) ;;
    * )
      echo "CCTBX does not officially support this platform"
      echo "the build has therefore been disabled."
      echo "To give it a try, make sure that cctbx is installed"
      echo "and comment out the following 3 lines"
      cctbxdir=
      disable_cctbx=yes
      disable_phaser=yes
      ;;
    esac
  fi
fi

### Set variables for Phaser build
if test "$disable_phaser" = yes; then
  # disable phaser build
  phaserdir=
else
  phaserdir=src/phaser
  if test ! -f $phaserdir/ccp4_build; then
    echo
    echo "Cannot find file $phaserdir/ccp4_build"
    echo "Phaser build disabled."
    echo
    phaserdir=
    disable_phaser=yes
  fi
  # set phaser options to cctbx options for consistency
  phaseropts=${phaseropts:-"$cctbxopts"}
fi

### Set variables for Mapslicer command library build
if test "$disable_mapslicer" = yes; then
  # disable Mapslicer build
  mapslicerdir=
else
  # configure for build of Mapslicer command library etc
  echo 
  echo "********* MAPSLICER CONFIGURATION ***********"
  echo
  echo "Please check the output below and report any problems to ccp4@ccp4.ac.uk"
  MAPSLICER_TARGETS=
  #
  # Clemens Vonrhein suggests using tclConfig.sh and tkConfig.sh
  # Need to check both tcl.h and tk.h
  #
  # Check if TCL_CONFIG and TCL_INCDIR have already been set
  # externally in the environment
  # The following blocks of code deal with the situation that the
  # user has explicitly set the locations of tclConfig.sh/tcl.h and
  # tkConfig.sh/tk.h
  # All the variables should be set in order for this to function
  # correctly
  if test -n "$TCL_CONFIG" ; then
    echo
    echo "Tcl configuration file is already defined: ${TCL_CONFIG}"
    if test -f "$TCL_CONFIG" ; then
      echo -n "Sourcing ${TCL_CONFIG} ... "
      . ${TCL_CONFIG}
      echo "ok"
    else
      echo
      echo "*** ${TCL_CONFIG} doesn't exist ***"
      echo "*** Please unset TCL_CONFIG or set it to an existing ***"
      echo "*** tclConfig.sh file before rerunning configure.    ***"
      exit 1
    fi
    echo -n "Tcl version is $TCL_VERSION ... "
    if test $TCL_MAJOR_VERSION -ge 8 ; then
      echo "ok"
    else
      echo "too old"
      echo
      echo "*** Tcl version must be 8.0 or higher ***"
      echo "*** Please unset TCL_CONFIG or set it to a more recent ***"
      echo "*** tclConfig.sh file before rerunning configure.      ***"
      exit 1
    fi
    if test ! "$TCL_INCDIR" ; then
      echo
      echo "*** No corresponding TCL_INCDIR has been defined          ***"
      echo "*** Please set TCL_INCDIR to a directory with an existing ***"
      echo "*** tcl.h file before rerunning configure.                ***"
      exit 1
    else
      echo "Tcl include already defined: ${TCL_INCDIR}"
      echo -n "Checking for tcl.h ... "
      if test -f "${TCL_INCDIR}/tcl.h" ; then
        echo "ok"
      else
        echo "not found"
        echo
        echo "*** Please set TCL_INCDIR to a directory with an existing ***"
        echo "*** tcl.h file before rerunning configure.                ***"
        exit 1
      fi
    fi
  fi
  # First check if TK_CONFIG and TK_INCDIR have already been set externally
  if test -n "$TK_CONFIG" ; then
    echo
    echo "Tk configuration file is already defined: ${TK_CONFIG}"
    if test -f "$TK_CONFIG" ; then
      echo -n "Sourcing ${TK_CONFIG} ... "
      . ${TK_CONFIG}
      echo "ok"
    else
      echo
      echo "*** ${TK_CONFIG} doesn't exist ***"
      echo "*** Please unset TK_CONFIG or set it to an existing ***"
      echo "*** tkConfig.sh file before rerunning configure.    ***"
      exit 1
    fi
    echo -n "Tk version is $TK_VERSION ... "
    if test $TK_MAJOR_VERSION -ge 8 ; then
      echo "ok"
    else
      echo "too old"
      echo
      echo "*** Tk version must be 8.0 or higher ***"
      echo "*** Please unset TK_CONFIG or set it to a more recent ***"
      echo "*** tkConfig.sh file before rerunning configure.      ***"
      exit 1
    fi
    if test ! "$TK_INCDIR" ; then
      echo
      echo "*** No corresponding TK_INCDIR has been defined          ***"
      echo "*** Please set TK_INCDIR to a directory with an existing ***"
      echo "*** tk.h file before rerunning configure.                ***"
      exit 1
    else
      echo "Tk include already defined: ${TK_INCDIR}"
      echo -n "Checking for tk.h ... "
      if test -f "${TK_INCDIR}/tk.h" ; then
        echo "ok"
      else
        echo "not found"
        echo
        echo "*** Please set TK_INCDIR to a directory with an existing ***"
        echo "*** tk.h file before rerunning configure.                ***"
        exit 1
      fi
    fi
  fi
  # The following code deals with the situation where the tclConfig.sh
  # and similar have not been explicitly defined in the environment.
  # In this case the algorithm searches for these files itself.
  echo
  if test ! "$TCL_CONFIG" || test ! "$TK_CONFIG" ; then
    echo "Searching for tclConfig.sh and/or tkConfig.sh..."
    trydirs="$CCP4I_TCLTK/.. /usr /usr/local"
    for testdir in $trydirs
    do
      # Look for tclConfig
      if test ! "$TCL_CONFIG" && test -f "$testdir/lib/tclConfig.sh" ; then
        echo "...found tclConfig.sh in ${testdir}/lib"
        . ${testdir}/lib/tclConfig.sh
        # Check that major version is at least 8
        if test $TCL_MAJOR_VERSION -ge 8 ; then
          echo "   TCL major version is $TCL_VERSION - OK"
          TCL_CONFIG="${testdir}/lib/tclConfig.sh"
          if test -f "$testdir/include/tcl.h" ; then
            TCL_INCDIR="${testdir}/include"
            echo "   Found tcl.h in $TCL_INCDIR"
          else
            echo "   No tcl.h in ${testdir}/include..."
          fi
        fi
      fi
      # Look for tkConfig
      if test ! "$TK_CONFIG" && test -f "$testdir/lib/tkConfig.sh" ; then
        echo "...found tkConfig.sh in ${testdir}/lib"
        . ${testdir}/lib/tkConfig.sh
        # Check that major version is at least 8
        if test $TK_MAJOR_VERSION -ge 8 ; then
          echo "   TK major version is $TK_VERSION - OK"
          TK_CONFIG="${testdir}/lib/tkConfig.sh"
          if test -f "$testdir/include/tk.h" ; then
            TK_INCDIR="${testdir}/include"
            echo "   Found tk.h in $TK_INCDIR"
          else
            echo "   No tk.h in ${testdir}/include..."
          fi
        fi
      fi
    done
  fi
  # Check that we actually have what we need
  if test ! "$TCL_CONFIG" || test ! "$TK_CONFIG" ; then
    echo
    echo "*** Can't find one or both of tclConfig.sh/tkConfig.sh which"
    echo "*** are at least version 8.0"
    echo "*** Or cannot find tcl.h/tk.h - check messages above."
    echo "*** This means the MapSlicer command library cannot be built"
    # Disable build of mapslicer command library
    mapslicerdir=
  else
    # Report the settings found in the Config files
    echo
    echo "Options acquired from tclConfig.sh:"
    echo "...to link to Tcl library                : $TCL_LIB_SPEC"
    if [ -z $TCL_INCDIR ] ; then
      echo "...switch to include tcl.h               : $TCL_INCLUDE_SPEC"
    fi
    echo
    echo "Options acquired from tkConfig.sh:"
    echo "...to link to Tk library                 : $TK_LIB_SPEC"
    echo "...other libraries for Tk                : $TK_LIBS"
    echo "...switch to make X11 includes accessible: $TK_XINCLUDES"
    #
    # Kludge: if TK_XINCLUDES starts with a comment character then
    # set it to blank
    case $TK_XINCLUDES in
     \#*) TK_XINCLUDES=
    esac
    #
    # Now deal with header files
    if test ! "$TCL_INCDIR" ; then
      # The tcl header file wasn't found where we expected previously
      # Check to see if TCL_INCLUDE_SPEC is present
      # Note that TCL_INCLUDE_SPEC is not defined for pre-8.4 versions
      # of Tcl
      if test "$TCL_INCLUDE_SPEC" ; then
        TCL_INCDIR="$( echo $TCL_INCLUDE_SPEC | cut -c 3- )"
        echo
        echo "Looking for tcl.h in $TCL_INCDIR (derived from TCL_INCLUDE_SPEC)"
        if test -f $TCL_INCDIR/tcl.h ; then
          echo "...Found $TCL_INCDIR/tcl.h"
        else
          echo "...Cannot find $TCL_INCDIR/tcl.h"
          TCL_INCDIR=
        fi
      fi
    fi
    if test ! "$TK_INCDIR" && test "$TCL_INCDIR" ; then
      # Either we have already found tk.h, or it wasn't where we
      # expected to find it previously
      # tkConfig.sh doesn't support a TK_INCLUDE_SPEC (or similar)
      # as of Tk 8.4.9. So let's guess that it's in the same place
      # as tcl.h
      if test -f $TCL_INCDIR/tk.h ; then
        echo
        echo "Found tk.h in $TCL_INCDIR (same location as tcl.h)"
        TK_INCDIR=$TCL_INCDIR
      else
        echo
        echo "Failed to find tk.h in $TCL_INCDIR"
      fi
    fi
    if [ -z $TCL_INCDIR ] || [ -z $TK_INCDIR ] ; then
      # We don't have the information required to even attempt
      # to compile the program
      echo
      echo "*** Unable to figure out the header file options required to"
      echo "*** build the MapSlicer command library."
      echo "*** This means the MapSlicer command library cannot be built"
      # Disable build of mapslicer command library
      mapslicerdir=
    else
      # Try test compilation with these settings
      echo
      echo "Checking: try to compile test program using these settings..."
      echo
      if test -f testcomp.c || test -f testcomp ; then
        rm -f testcomp*
      fi
      cat > testcomp.c <<EOF
/* testcomp.c
   Build Tcl/Tk interpreter */
#include "tcl.h"
#include "tk.h"
int Tk_AppInit(Tcl_Interp *interp);
int main(int argc, char *argv[])
{
  Tk_Main(argc, argv, Tk_AppInit);
  exit(0);
}
int Tk_AppInit(Tcl_Interp *interp)
{
  if (Tcl_Init(interp) == TCL_ERROR) {
    return TCL_ERROR;
  }
  if (Tk_Init(interp) == TCL_ERROR) {
    return TCL_ERROR;
  }
  return TCL_OK;
}
EOF
      test_compile="$CC -I$TCL_INCDIR $TK_XINCLUDES $CFLAGS -o testcomp testcomp.c $TK_LIB_SPEC $TCL_LIB_SPEC $TK_LIBS"
      echo $test_compile
      if { ( eval $test_compile) 2>/dev/null ;} && test -s testcomp ; then
        echo
        echo "Test compilation successful - using these settings to build ccp4mapwish"
        echo
        if test "$MAPSLICER_SHARE" ; then
          echo "Also configured to build the command library as a loadable package"
          MAPSLICER_TARGETS="$MAPSLICER_TARGETS libccp4map.so"
        else
          echo "Not configured to build the command library as a loadable package"
        fi
        # Standalone ccp4mapwish will always be built
        MAPSLICER_TARGETS="$MAPSLICER_TARGETS ccp4mapwish"
        mapslicerdir=src/ccp4mapwish_
      else
        # Flags are broken, cannot build ccp4mapwish
        echo
        echo "****        Test compilation failed           ****"
        echo "**** ccp4mapwish cannot be built or installed ****"
        # Remove any existing ccp4mapwish Makefile
        if test -f src/ccp4mapwish_/Makefile ; then
          rm -f src/ccp4mapwish_/Makefile
        fi
      fi
    fi
  fi
  echo 
  echo "***** MAPSLICER CONFIGURATION FINISHED *******"
fi
DIRS="$DIRS $mapslicerdir"


# Check for disabling of PDB_EXTRACT suite
PDB_EXTRACT_SUITE=
if test -n "$disable_pdb_extract"; then
  echo
  echo " Building of the RCSB PDB_EXTRACT suite has been suppressed."
  echo " As a result you will not be able to use the PDB_EXTRACT programs."
else
  # Check for presence of bison which is needed to build PDB_EXTRACT
  case `which bison 2>/dev/null` in
     *bison )
     got_bison=yes ;;
  esac
  if test -n "$got_bison"; then
     echo
     echo " Configure will try to set up and build the RCSB PDB_EXTRACT suite"
     echo " ***** This may not be possible for some systems! *****"
     echo " To disable inclusion of the RCSB PDB_EXTRACT suite, use the"
     echo " --disable-pdb_extract flag"
     PDB_EXTRACT_SUITE=pdb_extract_suite
     #testing to check compiler - CC variable
     cd src/harvest_app_/pdb_extract
     make configure
     cd ../../../
  else
     echo
     echo " ************************* WARNING ****************************"
     echo " Configure could not find the bison parser"
     echo " This means that the RCSB PDB_EXTRACT suite cannot be built"
     echo
     echo " Bison can be obtained from the GNU site http://www.gnu.org"
     echo
     echo " If you wish to use the PDB_EXTRACT programs then you must"
     echo " install bison and then rerun configure."
  fi
fi



### Build makefiles in the sub-directories
for i in $DIRS ; do

 if [ "X$i" = "Xlib/src" ]; then
  if [ "X$LIBFOPTIM" != "X" ]; then
     FOPTIM_save=$FOPTIM
     FOPTIM=$LIBFOPTIM
     FFLAGS="${FOPTIM} ${XFFLAGS}"
   fi
   if [ "X$LIBCOPTIM" != "X" ]; then
     COPTIM_save=$COPTIM
     COPTIM=$LIBCOPTIM
     CFLAGS="${COPTIM} ${XCFLAGS}"
   fi
 fi

# this section checks to see if the compiler is gcc, you are dooing shared libs
# and you are currently creating lib/src/Makefile. otherwise will skip
if test $i = lib/src && test "$CC" = gcc && test "$shared_lib" = yes; then
   XFFLAGS=$XFFLAGS" -fPIC"
   XCFLAGS=$XCFLAGS" -fPIC"
   XCXXFLAGS=$XCXXFLAGS" -fPIC"
fi
if test $i = lib/src && test $system = HP-UX && test "$shared_lib" = yes; then
   XFFLAGS=$XFFLAGS" +z"
   XCFLAGS=$XCFLAGS" +z"
   XCXXFLAGS=$XCXXFLAGS" +z"
fi

# this section checks to see if the compiler is gcc and you are building mapslicer
# as -fPIC is required under these conditions
if test "$CC" = gcc; then
   MAPSLICER_XCFLAGS=" -fPIC"
else
   MAPSLICER_XCFLAGS=" "
fi

  cat >$i/Makefile <<END
# This file was generated by configure -- don't edit it!

TMPDIR = $tmpdir
top_srcdir = $srcdir
libdir = $libdir
rxdir = $rxdir
ccifdir = $ccifdir
lapackdir = $lapackdir
clipperdir = $clipperdir
ssmdir = $ssmdir
fftwdir = $fftwdir
cctbxdir = $cctbxdir
cctbxopts = $cctbxopts
phaserdir = $phaserdir
phaseropts = $phaseropts
bindir = $bindir
RANLIB = $RANLIB
FC     = $FC
FOPTIM = $FOPTIM
COPTIM = $COPTIM
XFFLAGS = $XFFLAGS
XCFLAGS = $XCFLAGS
FFLAGS = \$(FOPTIM) \$(XFFLAGS)
CXXOPTIM = $CXXOPTIM
XCXXFLAGS = $XCXXFLAGS
CXXFLAGS = \$(CXXOPTIM) \$(XCXXFLAGS)
CXX   = $CXX
XCIF_LIB = $XCIF_LIB
CIFLIBTARGETS=$CIFLIBTARGETS
CIFLIBOBJS=$CIFLIBOBJS
CIFTARGETS=$CIFTARGETS
PDB_EXTRACT_SUITE=$PDB_EXTRACT_SUITE
XLAPACK_LIB = $XLAPACK_LIB
XLDFLAGS = $XLDFLAGS
LDCFLAGS = $LDFLAG $LDCFLAGS
LDFLAGS = $LDFLAG $LDFLAGS
LDCXXFLAGS = $LDFLAG $LDCXXFLAGS
F_LIBS = $F_LIBS
C_LIBS = $C_LIBS
CXX_LIBS = $CXX_LIBS
CFLAGS = \$(COPTIM) \$(XCFLAGS)
XDL_LIB = $XDL_LIB
XWIN_LIB = \$(XDL_LIB) $XWIN_LIB
CC     = $CC
LNS    = $LNS
M4     = $M4
SETFLAGS = $SETFLAGS
F      = $F
INSTALL_PROGRAM = $INSTALL_PROGRAM
INSTALL_DATA = $INSTALL_DATA
TIDY   = $TIDY
XMKMF  = $XMKMF
$MAKELINE

END

if [ "X$i" = "Xlib/src" ]; then
  if [ "X$LIBFOPTIM" != "X" ]; then
    FOPTIM=$FOPTIM_save
    FFLAGS="${FOPTIM} ${XFFLAGS}"
  fi
  if [ "X$LIBCOPTIM" != "X" ]; then
    COPTIM=$COPTIM_save
    CFLAGS="${COPTIM} ${XCFLAGS}"
  fi
  cat >>$i/Makefile <<END
SHARE_LIB = $SHARE_LIB
SHARE_INST = $SHARE_INST
SHARED_LIB_CFLAGS = $SHARED_LIB_CFLAGS
SHARED_LIB_FFLAGS = $SHARED_LIB_FFLAGS
END
else true
fi

# Mapslicer command library
if test $i = src/ccp4mapwish_; then
  cat >>$i/Makefile <<END

MAPSLICER_SHARE = $MAPSLICER_SHARE -L\$(LIB_DIR) -lccp4c
MAPSLICER_TARGETS = $MAPSLICER_TARGETS
MAPSLICER_XCFLAGS = $MAPSLICER_XCFLAGS
tclinc = $TCL_INCDIR
tkinc  = $TK_INCDIR
# Dont worry if TCL_DBGX is specified but not defined
TCL_LIB_SPEC = $TCL_LIB_SPEC
TK_LIB_SPEC  = $TK_LIB_SPEC
TK_LIBS      = $TK_LIBS
TK_XINCLUDES = $TK_XINCLUDES
END
else true
fi

cat $srcdir/$i/Makefile.in >>$i/Makefile

done

if test x"$enable_x" = xyes; then
  echo 
  echo "********* X-WINDOWS CONFIGURATION ***********"
  echo
# run configure for xdlview library
  CFLAGS="${COPTIM} ${XCFLAGS}"
  FFLAGS="${FOPTIM} ${XFFLAGS}"
  CXXFLAGS="${CXXOPTIM} ${XCXXFLAGS}"
  export CFLAGS CXXFLAGS FFLAGS SHARED_LIB_CFLAGS SHARED_LIB_FFLAGS
  if test "$shared_lib" = yes; then 
    xopts="--enable-shared=yes"
  else
    xopts="--enable-shared=no"
  fi
  echo "CCP4 configure: Running separate configure for xdlview library."
  echo
  cd x-windows/xdl_view/src
  # It is important for some systems that the files
  # configure.in, Makefile.am, aclocal.m4, configure,
  # and Makefile.in have the correct timestamp relative
  # to each other (Clemens Vonrhein)
  echo "Updating modification times for configuration files in xdl_view"
  echo "Please wait..."
  for i in configure.in Makefile.am aclocal.m4 configure Makefile.in ltconfig ltmain.sh; do
    touch $i && sleep 1
  done
  echo "...done."
  echo
  echo "configure $xopts --libdir=${libdir}"
  ./configure $xopts --libdir=${libdir} 
  echo
  echo "CCP4 configure: Running separate configure for libjwc_c library."
  echo
  cd ${srcdir}/${xwindir}/libjwc/libjwc_c
  echo "Updating modification times for configuration files in libjwc_c"
  echo "Please wait..."
  for i in configure.in Makefile.am aclocal.m4 configure Makefile.in ltconfig ltmain.sh; do
    touch $i && sleep 1
  done
  echo "...done."
  echo
  echo "configure $xopts --libdir=${libdir}"
  ( touch /tmp/$$.cache_file 2>/dev/null && \
    cat /dev/null > /tmp/$$.cache_file && \
    ./configure $xopts --libdir=${libdir} --cache-file=/tmp/$$.cache_file ) || \
    ./configure $xopts --libdir=${libdir}
  rm -f /tmp/$$.cache_file
  echo
  echo "CCP4 configure: Running separate configure for libjwc_f library."
  echo
  cd ${srcdir}/${xwindir}/libjwc/libjwc_f
  # for g77 3.1 some builds do not have no-common for system libs,
  # so disable for now
  echo "Updating modification times for configuration files in libjwc_f"
  echo "Please wait..."
  for i in configure.in Makefile.am aclocal.m4 configure Makefile.in ltconfig ltmain.sh; do
    touch $i && sleep 1
  done
  echo "...done."
  echo
  # for g77 3.1 some builds do not have no-common for system libs,
  # so disable for now
  case $system in
  Darwin_ibm_compilers | Darwin )
    echo "configure --disable-shared --libdir=${libdir}"
    ( touch /tmp/$$.cache_file 2>/dev/null && \
      cat /dev/null > /tmp/$$.cache_file && \
      ./configure --disable-shared --libdir=${libdir} --cache-file=/tmp/$$.cache_file ) || \
      ./configure --disable-shared --libdir=${libdir}
    ;;
  * )
    echo "configure $xopts --libdir=${libdir}"
    ( touch /tmp/$$.cache_file 2>/dev/null && \
      cat /dev/null > /tmp/$$.cache_file && \
      ./configure $xopts --libdir=${libdir} --cache-file=/tmp/$$.cache_file ) || \
      ./configure $xopts --libdir=${libdir}
  esac
  rm -f /tmp/$$.cache_file
  echo
  echo "CCP4 configure: Running separate configure for rotgen"
  echo
  cd ${srcdir}/${rotgendir}
  echo "Updating modification times for configuration files in rotgen"
  echo "Please wait..."
  for i in configure.in Makefile.am aclocal.m4 configure Makefile.in ltconfig ltmain.sh; do
    touch $i && sleep 1
  done
  echo "...done."
  echo
  echo "configure $xopts --with-ccp4-prefix=${libdir} --bindir=${bindir}"
  ( touch /tmp/$$.cache_file 2>/dev/null && \
    cat /dev/null > /tmp/$$.cache_file && \
    ./configure $xopts --with-ccp4-prefix=${libdir} --bindir=${bindir} --cache-file=/tmp/$$.cache_file ) || \
    ./configure $xopts --with-ccp4-prefix=${libdir} --bindir=${bindir}
  rm -f /tmp/$$.cache_file

  # checking for compiler_o_lo yourself
  echo
  echo " *** checking for compiler_o_lo using $FC $FOPTIM $XFFLAGS ..."
  cat <<end_ip > $$.f
      program test
      write(*,*) 'Hello World!'
      end
end_ip
  cat <<end_ip > $$.sh
#!/bin/sh
$FC $FOPTIM $XFFLAGS -c -o $$.lo $$.f >/dev/null 2>&1
echo $?
end_ip
  chmod +x $$.sh
  if [ `./$$.sh` -ne 0 ] || [ ! -f $$.lo ]; then
    if [ -f libtool ]; then
      sed "s/^compiler_o_lo=\"yes\"$/compiler_o_lo=\"no\"/g" libtool > $$.libtool && \
      mv $$.libtool libtool && \
      chmod +x libtool
      echo "   resetting compiler_o_lo to \"no\""
    fi
  else
    if [ -f libtool ]; then
      sed "s/^compiler_o_lo=\"no\"$/compiler_o_lo=\"yes\"/g" libtool > $$.libtool && \
      mv $$.libtool libtool && \
      chmod +x libtool
      echo "   resetting compiler_o_lo to \"yes\""
    fi
  fi
  rm -f $$*
  echo
  echo "CCP4 configure: Running separate configure for Mosflm"
  echo
  cd ${srcdir}/${mosflmdir}
  echo "configure $xopts --libdir=${libdir}"
  ./configure $xopts --libdir=${libdir}
  echo
  cd ../..
  echo "Returning to main configure."
  echo
  echo "********* X-WINDOWS CONFIGURATION FINISHED ***********"
  echo
fi

# fixme: decide whether we should zap any existing libccp4.a

# That's it.  Record the result in config.status for possible re-use
# (following the GNU convention) and give the luser some idea what we've
# done...

test $src || opts=" --onlylibs"
test "$with_f2c" && opts=$opts" --with-f2c" || true
test "$shared_lib" = yes && opts="$opts --with-shared-libs" || true
test "$tmpdir"  && opts="$opts --tmpdir=$tmpdir" || true
test "$enable_x" = yes && opts="$opts --enable-x" || true
test "$enable_x" = no && opts="$opts --disable-x" || true
test "$with_rxdispencer" = yes && opts="$opts --with-rxdispencer" || true
test "$disable_ccif" = yes && opts="$opts --disable-ccif" || true
test "$disable_cctbx" = yes && opts="$opts --disable-cctbx" || true
test "$disable_phaser" = yes && opts="$opts --disable-phaser" || true
test "$with_netlib_lapack" = yes && opts="$opts --with-netlib-lapack" || true
test "$disable_lapack" = yes && opts="$opts --disable-lapack" || true
test "$disable_mapslicer" = yes && opts="$opts --disable-mapslicer" || true
test "$enable_clipper" = yes && opts="$opts --enable-clipper" || true
test "$enable_ssm" = yes && opts="$opts --enable-ssm" || true
test "$enable_fftw" = yes && opts="$opts --enable-fftw" || true
test "$enable_clipper" = no && opts="$opts --disable-clipper" || true
test "$enable_ssm" = no && opts="$opts --disable-ssm" || true
test "$enable_fftw" = no && opts="$opts --disable-fftw" || true
test "${with_fftw:+set}" = set && opts="$opts --with-fftw=${prefix_fftw}" || true
test "$warnings" = yes && opts="$opts --with-warnings" || true
test "$non_shared" = yes && opts="$opts --non_shared" || true
test "$disable_pdb_extract" = yes && opts="$opts --disable-pdb_extract" || true

cat <<EOF >config.statusx
#!/bin/sh
# (Generated automatically by configure)
# CCP4 was configured as follows:
libdir="$libdir"		RANLIB="$RANLIB" \\
FC="$FC"			FOPTIM="$FOPTIM" \\
COPTIM="$COPTIM"		XFFLAGS="$XFFLAGS" \\
XCFLAGS="$XCFLAGS"	 	CC="$CC" \\
LNS="$LNS"			M4="$M4" \\
XCXXFLAGS="$XCXXFLAGS"	 	CXX="$CXX" \\
CXXOPTIM="$CXXOPTIM"   \\
M4FLAGS="$M4FLAGS"		SETFLAGS="$SETFLAGS" \\
MAKE="$MAKE"			F="$F"       \\
INSTALL_PROGRAM="$INSTALL_PROGRAM"	INSTALL_DATA="$INSTALL_DATA" \\
XLDFLAGS="$XLDFLAGS" \\
SHARE_LIB="$SHARE_LIB" \\
SHARED_LIB_CFLAGS="$SHARED_LIB_CFLAGS" \\
SHARED_LIB_FFLAGS="$SHARED_LIB_FFLAGS" \\
SHARE_INST="$SHARE_INST" \\
$srcdir/configure --srcdir=$srcdir --bindir=$bindir --libdir=$libdir $opts $system -hush

EOF

chmod a+x config.statusx

echo
echo "The configuration can be re-built by executing config.status :"
echo
# indirect as we may be executing config.status
cat config.statusx
mv config.statusx config.status

touch Makefile			# for Makefile target in itself

##########
# FSPLIT
##########
# The following is commented out (since even if they have a locally
# available fsplit, it won't be used now) but not removed at present
# for the sake of reference - pjx.
#    if test $system = irix; then
#       cat <<\+
#! You need to install the ftn_dev util stuff, which apparently isn\'t done
#! by default.  You should then see something like this:
#!   % versions long ftn_dev | grep fsplit
#!   f 33940    29 ftn_dev.sw.util         usr/bin/fsplit
#!   f 51059     4 ftn_dev.man.util        usr/share/catman/u_man/cat1/fsplit.z
#+
#    else
#       echo "!  You can get a copy e.g. by ftp or via the Web from"
#       echo "! http://src.doc.ic.ac.uk/computing/systems/unix/bsd-sources/usr.bin/fsplit"
#       echo "! amongst other places.  Also complain to your vendor!"
#    fi

if test -f lib/src/libccp4f.a; then
	echo
	echo "If the compiled library \`lib/src/libccp4f.a' is from a previous release"
	echo "you should delete it before compiling the current version."
else true
fi
if test -f lib/src/libccp4c.a; then
	echo
	echo "If the compiled library \`lib/src/libccp4c.a' is from a previous release"
	echo "you should delete it before compiling the current version."
else true
fi
if test -f lib/src/libmmdb.a; then
	echo
	echo "If the compiled library \`lib/src/libmmdb.a' is from a previous release"
	echo "you should delete it before compiling the current version."
else true
fi
if test -f lib/ccif/libccif.a; then
	echo
	echo "If the compiled library \`lib/ccif/libccif.a' is from a previous release"
	echo "you should delete it before compiling the current version."
else true
fi
#

