#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/configure                            */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Tue Jan 25 16:05:10 1994                          */
#*    Last change :  Fri Nov 30 14:32:39 2001 (serrano)                */
#*    Copyright   :  1994-2001 Manuel Serrano, see LICENSE file        */
#*    -------------------------------------------------------------    */
#*    The Bigloo configuration file                                    */
#*    -------------------------------------------------------------    */
#*    Please, dont talk to me about autoconf. I simply dont want       */
#*    to ear about it...                                               */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    Bigloo revision number                                           */
#*---------------------------------------------------------------------*/
release=2.4b

#*---------------------------------------------------------------------*/
#*    User variables                                                   */
#*---------------------------------------------------------------------*/
#*--- paths -----------------------------------------------------------*/
prefix=/usr/local
bindir=$prefix/bin
libdir=$prefix/lib/bigloo/$release
zipdir=$prefix/lib/bigloo/$release
mandir=$prefix/man/man1
infodir=$prefix/info
docdir=$prefix/doc/bigloo-$release
lispdir=$prefix/lib/xemacs/site-lisp/bigloo
tmp=/tmp

#*--- C back-end user configure ---------------------------------------*/
nativebackend=yes # set to "no" not to install the native (C) back-end
cc=gcc
cflags=""
coflags="-O3"
cstrip="-s"
cpicflags="no" # Possible values for cpicflags are:
               #  - "no" not to use position independent code (recommended)
               #  - blank (uninitalized) for automatic configuration of the
               #       position independent code compiler option
               #  - a legal C compiler option that enable PIC code.
as=as
ar=ar
arflags=qc

strip=strip

#*--- Java back-end user configuration --------------------------------*/
jvmbackend=yes # set to "no" not to install the Jvm back-end
zip=zip
jar="jar cmf"
zflags=
javac=javac
jcflags=-O
java=java
jflags=
jvflags=-noverify
jshell=sh

#*--- Misc user configuration -----------------------------------------*/
shell=/bin/sh
xemacs=xemacs
makeinfo=makeinfo
makeinfoopt="-U oldinfo"
texi2dvi=texi2dvi
texi2dviopt=-b
texi2html=texi2html
texi2htmlopt="-menu -monolithic -number"
texi2pdf=texi2pdf
iinfo=install-info
dlopenopt=-ldl
dirname=dirname
defaultbackend="native"
aout=""
abat=""
exe=""

#*--- socket library (left empty for automatic configuration) ---------*/
socketlibs=

#*--- gc source directory (left blank for default configuration) ------*/
gcdir=

#*--- indent ----------------------------------------------------------*/
indent="/usr/local/bin/indent -npro -bap -bad -nbc -bl -ncdb -nce -nfc1 -ip0 -nlp -npcs -nsc -nsob -cli0.5 -di0 -l80 -d1 -c0 -ts2 -st"

#*--- mask of Bigloo intalled files -----------------------------------*/
bmask=755

#*--- ld shared library option ----------------------------------------*/
# set this variable to `no-share' if you don't want shared library
ldopt=
sharedsuffix=so

#*--- should the compiler be dynamically linked?  ---------------------*/
# the legal value for that variable is `yes' or `no'
sharedcompiler=no

#*--- cygwin specific configuration -----------------------------------*/
# The location where cygwin is installed
cygwindospath=""

#*---------------------------------------------------------------------*/
#*    Hacker variables                                                 */
#*    -------------------------------------------------------------    */
#*    Dont modifiy these variables unless you know what you are        */
#*    doing.                                                           */
#*---------------------------------------------------------------------*/
#*--- The basename of the compiler ------------------------------------*/
bigloo=bigloo

#*--- libraries -------------------------------------------------------*/
libraryname=$bigloo

#--- additional user library used to link bigloo applications ---------*/
extralibs="-lm"

#*---------------------------------------------------------------------*/
#*                 !!! DONT EDIT AFTER THIS LINE !!!                   */
#*---------------------------------------------------------------------*/
action=all
makefile_cfg=Makefile.config
autoconfdir=`dirname $0 2> /dev/null`/autoconf
pwd=`pwd`
bootdir=$pwd
cgcflags53="-DSILENT -DNO_SIGNALS -DOLD_BLOCK_ALLOC -DFINALIZE_ON_DEMAND -DNO_DEBUGGING"
cgcflags="-DSILENT -DNO_SIGNALS -DFINALIZE_ON_DEMAND -DNO_DEBUGGING -Iinclude"
backptrflags="-DKEEP_BACK_PTRS"
bigloo_config_h=
bigloo_config_jvm=
summary=yes
java_configured=no
os=posix
jvmln="ln -s"
jvmcpath=""
gcspecial=
hardtune=

if [ $? != "0" ]; then
   autoconfdir="autoconf"
fi

# Argument parsing
while : ; do
  case $1 in
    "")
      break;;

    --bootconfig)
      bindir=$PWD/bin;
      libdir=$PWD/lib/$release;
      zipdir=$libdir
      bootdir=$PWD;
      sharedcompiler=no;
      infodir=$PWD/info;
      java=/usr/java/jdk/bin/java;
      javac=/usr/java/jdk/bin/javac;
      action="all";;

    --bigloo_config.h)
      action="bigloo_config";;
    
    --bigloo_config.h=*)
      action="bigloo_config";
      bigloo_config_h="`echo $1 | sed 's/^[^=]*=//'`";;

    --bigloo_config.jvm=*)
      action="bigloo_config";
      bigloo_config_jvm="`echo $1 | sed 's/^[^=]*=//'`";;

    --Makefile.config)
      action="Makefile.config";;

    --bindir=*)
      bindir="`echo $1 | sed 's/^[^=]*=//'`";;

    --libdir=*)
      libdir="`echo $1 | sed 's/^[^=]*=//'`";;

    --zipdir=*)
      zipdir="`echo $1 | sed 's/^[^=]*=//'`";;

    --mandir=*)
      mandir="`echo $1 | sed 's/^[^=]*=//'`";;

    --infodir=*)
      infodir="`echo $1 | sed 's/^[^=]*=//'`";;

    --docdir=*)
      docdir="`echo $1 | sed 's/^[^=]*=//'`";;

    --indent=*)
      indent="`echo $1 | sed 's/^[^=]*=//'`";;

    --dirname=*)
      dirname="`echo $1 | sed 's/^[^=]*=//'`";;

    --lispdir=*)
      lispdir="`echo $1 | sed 's/^[^=]*=//'`";;

    --prefix=*)
      prefix="`echo $1 | sed 's/^[^=]*=//'`";
      bindir=$prefix/bin;
      libdir=$prefix/lib/bigloo/$release;
      zipdir=$libdir;
      mandir=$prefix/man/man1;
      infodir=$prefix/info;
      docdir=$prefix/doc/bigloo-$release;
      lispdir=$prefix/lib/xemacs/site-lisp;;

    --cc=*)
      cc="`echo $1 | sed 's/^[^=]*=//'`";;

    --cflags=*)
      cflags="`echo $1 | sed 's/^[^=]*=//'`";;

    --coflags=*)
      coflags="`echo $1 | sed 's/^[^=]*=//'`";;

    --native=*)
      nativebackend="`echo $1 | sed 's/^[^=]*=//'`";;

    --a.out=*)
      aout="`echo $1 | sed 's/^[^=]*=//'`";;

    --a.bat=*)
      abat="`echo $1 | sed 's/^[^=]*=//'`";;

    --jvm=*)
      jvmbackend="`echo $1 | sed 's/^[^=]*=//'`";;

    --java=*)
      java="`echo $1 | sed 's/^[^=]*=//'`";;

    --javac=*)
      javac="`echo $1 | sed 's/^[^=]*=//'`";;

    --javaprefix=*)
      java="`echo $1 | sed 's/^[^=]*=//'`"/java;
      javac="`echo $1 | sed 's/^[^=]*=//'`"/javac;;

    --javashell=sh)
      jshell="sh";;

    --javashell=msdos)
      jshell="msdos";;

    --native-default-backend)
      defaultbackend="native";;

    --jvm-default-backend)
      defaultbackend="jvm";;

    --no-share)
      ldopt="no-share";;

    --os-win32)
      os="win32";;

    --cygwin-dos-path==*)
      cygwindospath="`echo $1 | sed 's/^[^=]*=//'`";;

    --arch=athlon)
      hardtune="athlon";
      gcspecial=-DUSE_3DNOW_PREFETCH;;

    --arch=k6III)
      hardtune="k6III";
      gcspecial=-DUSE_3DNOW_PREFETCH;;

    --arch=pIII)
      hardtune="Pentium III";
      gcspecial=-DUSE_I686_PREFETCH;;

    --arch=pIV)
      hardtune="Pentime IV";
      gcspecial=-DUSE_I686_PREFETCH;;

    --no-summary)
      summary=no;;

    -*)
      echo "*** ERROR: Illegal option \"$1\""
      echo ""
      echo ""
      echo "Usage: configure [options]" >&2;
      echo "   --native=yes|no" >&2;
      echo "   --prefix=dir" >&2;
      echo "   --bindir=file" >&2;
      echo "   --libdir=file" >&2;
      echo "   --zipdir=file" >&2;
      echo "   --mandir=file" >&2;
      echo "   --infodir=file" >&2;
      echo "   --docdir=file" >&2;
      echo "   --lispdir=file" >&2;
      echo "   --jvm=yes|no|force" >&2;
      echo "   --cc=comp" >&2;
      echo "   --cflags=compilation_flags" >&2;
      echo "   --coflags=optimization_flags" >&2;
      echo "   --indent=file" >&2;
      echo "   --a.out=file" >&2;
      echo "   --a.bat=file" >&2;
      echo "   --dirname=file-or-command" >&2;
      echo "   --bigloo_config.h[=file]" >&2;
      echo "   --bigloo_config.jvm[=file]" >&2;
      echo "   --Makefile.config=file" >&2;
      echo "   --java=file" >&2;
      echo "   --javac=file" >&2;
      echo "   --javaprefix=dir" >&2;
      echo "   --javashell=shell [should be sh or msdos (default sh)]" >&2;
      echo "   --no-share" >&2;
      echo "   --bootconfig" >&2;
      echo "   --no-summary" >&2;
      echo "   --native-default-backend" >&2;
      echo "   --jvm-default-backend" >&2;
      echo "   --os-win32" >&2;
      echo "   --cygwin-dos-path=[dos path]" >&2;
      echo "   --arch=[athlon|k6III|pIII|pIV]"  >&2;
      exit 3;
  esac
  shift
done

# The bigloo_config.h file
if [ "$bigloo_config_h " = " " ]; then
  bigloo_config_h=lib/$release/bigloo_config.h
fi

# The bigloo_config.jvm file
if [ "$bigloo_config_jvm " = " " ]; then
  bigloo_config_jvm=runtime/Jlib/configure.java
fi

# The gc directory
if [ "$gcdir " = " " ]; then
   gcdir=../gc-boehm
fi

# Start configuring
if [ "$summary" = "yes" ]; then
  echo "** Configure **"
  echo 
fi

# Cleaning
/bin/rm -f configure.log

#*---------------------------------------------------------------------*/
#*    Testing the Posix OS                                             */
#*---------------------------------------------------------------------*/
posixos=`$autoconfdir/os`

# Setting the default a.out production according to the OS
if [ "$aout " = " " ]; then
  case $posixos in
    cygwin)
      aout=a.exe;;
    *)
      aout=a.out;;
  esac
fi

if [ "$abat " = " " ]; then
  case $posixos in
    cygwin)
      abat=a.bat;;
    *)
      abat=a.out;;
  esac
fi

if [ $posixos = "cygwin" ]; then
  exe=".exe";
  jshell="msdos";

  if [ "$cygwindospath " = " " ]; then
    cygwindospath=`$autoconfdir/cygwindospath`
  fi

  if [ "$cygwindospath " = " " ]; then
    echo "*** ERROR:Can't find out where cygwin is installed."
    echo "Run configure with the --cygwin-dos-path option."
    exit 1
  else
    cygwindospath=`echo "$cygwindospath" | sed -e 's/\\\\/\\\\\\\\/g'`
    zipdir=$cygwindospath$zipdir
  fi
fi

#*---------------------------------------------------------------------*/
#*    If the operating system is win32 we have to turn the / into \ in */
#*    path names                                                       */
#*---------------------------------------------------------------------*/
if [ $os = "win32" ]; then
  ldopt="no-share"
  bindir=`echo $bindir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
  libdir=`echo $libdir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
  zipdir=`echo $zipdir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
  mandir=`echo $mandir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
  infodir=`echo $infodir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
  docdir=`echo $docdir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
  lispdir=`echo $lispdir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
fi

#*---------------------------------------------------------------------*/
#*    We don't support shared libraries on cygwin yet.                 */
#*---------------------------------------------------------------------*/
if [ $posixos = "cygwin" ]; then
  ldopt="no-share"
  jvmln=cp
  jvmcpath="-classpath \".;..\""
fi

#*---------------------------------------------------------------------*/
#*    all action                                                       */
#*---------------------------------------------------------------------*/
if [ $action = "all" ]; then
  if [ ! -d bin ]; then
     mkdir bin || exit 3
  fi
  if [ ! -d lib ]; then
     mkdir lib || exit 3
  fi
  if [ ! -d lib/$release ]; then
     mkdir lib/$release || exit 3
  fi
fi

#*---------------------------------------------------------------------*/
#*    Finding a user name                                              */
#*---------------------------------------------------------------------*/
user=`$autoconfdir/user`

#*---------------------------------------------------------------------*/
#*    Testing C compiler                                               */
#*---------------------------------------------------------------------*/
$autoconfdir/cctest --cc="$cc" --user=$user
if [ $? != "0" ]; then
  echo "*** ERROR:configure:the C compiler does not seem to work. Aborting";
  exit 1;
fi

#*---------------------------------------------------------------------*/
#*    bigloo_config.h                                                  */
#*    -------------------------------------------------------------    */
#*    This part of the configure script produces the file              */
#*    runtime/Include/bigloo_config.h. This file contains all the      */
#*    machine dependant information used by Bigloo.                    */
#*---------------------------------------------------------------------*/
if [ $action = "all" -o $action = "bigloo_config" ]; then

  # Tell what we are doning
  echo "Configuring $bigloo_config_h & $bigloo_config_jvm:"

  # We first cleanup the files
  rm -f $bigloo_config_h 2> /dev/null
  echo "/* Automatically generated file (don't edit) */" > $bigloo_config_h
  echo "/* `date` */" >> $bigloo_config_h
  echo "" >> $bigloo_config_h

  rm -f $bigloo_config_jvm 2> /dev/null
  echo "/* Automatically generated file (don't edit) */" > $bigloo_config_jvm
  echo "/* `date` */" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_jvm
  echo "package bigloo;" >> $bigloo_config_jvm
  echo "public class configure {" >> $bigloo_config_jvm

  # The release number
  echo "#undef BGL_RELEASE_NUMBER" >> $bigloo_config_h
  echo "#define BGL_RELEASE_NUMBER \"$release\"" >> $bigloo_config_h
  echo "  public static byte[] BGL_RELEASE_NUMBER = \"$release\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # The default target
  echo "#undef BGL_DEFAULT_BACK_END" >> $bigloo_config_h
  echo "#define BGL_DEFAULT_BACK_END \"$defaultbackend\"" >> $bigloo_config_h
  echo "  public static byte[] BGL_DEFAULT_BACK_END = \"$defaultbackend\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # The default target
  echo "#undef BGL_DEFAULT_A_OUT" >> $bigloo_config_h
  echo "#define BGL_DEFAULT_A_OUT \"$aout\"" >> $bigloo_config_h
  echo "  public static byte[] BGL_DEFAULT_A_OUT = \"$aout\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # The default target
  echo "#undef BGL_DEFAULT_A_BAT" >> $bigloo_config_h
  echo "#define BGL_DEFAULT_A_BAT \"$abat\"" >> $bigloo_config_h
  echo "  public static byte[] BGL_DEFAULT_A_BAT = \"$abat\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # The C compiler options
  cflags=`$autoconfdir/ccoptim --user=$user --cc="$cc" --cflags="$cflags"`

  # The -O C compiler options
  coflags=`$autoconfdir/ccoptim --user=$user --cc="$cc" --cflags="$coflags"`

  # The -s C linker options
  csflags=`$autoconfdir/ccstrip --user=$user --cc="$cc" --cflags="$cstrip"`

  # The -pic C compiler options
  if [ "$cpicflags" = "no" ]; then
    cpicflags=""
  else
    cpicflags=`$autoconfdir/ccpic --user=$user --cc="$cc" --cflags="$cpicflags"`
  fi

  if [ "$cpicflags " = " " ]; then
    cpicflags=-DBGL_NO_PIC;
  fi

  # The -p C compiler options
  cpflags=`$autoconfdir/ccprof --user=$user --cc="$cc"`

  # The stack direction
  stackgrows=`$autoconfdir/stackdown --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:stack. Aborting";
     exit 1;
  fi

  echo "#undef STACK_GROWS_DOWN" >> $bigloo_config_h
  if( test $stackgrows = "1" ); then
    echo "   stack grows: down"
    echo "#define STACK_GROWS_DOWN 1" >> $bigloo_config_h
    echo "  public static boolean STACK_GROWS_DOWN = true;" >> $bigloo_config_jvm
  else
    echo "   stack grows: up"
    echo "#define STACK_GROWS_DOWN 0" >> $bigloo_config_h
    echo "  public static boolean STACK_GROWS_DOWN = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # The pointer alignment
  alignment=`$autoconfdir/alignment --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:alignment. Aborting";
     exit 1;
  fi

  echo "   log2 ptr alignment: " $alignment
  echo "#undef PTR_ALIGNMENT" >> $bigloo_config_h
  echo "#define PTR_ALIGNMENT $alignment" >> $bigloo_config_h
  echo "  public static int PTR_ALIGNMENT = $alignment;" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # setjmp/longjmp
  prefix=`$autoconfdir/setjmp --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:setjmp. Aborting";
     exit 1;
  fi

  setjmp="$prefix"setjmp
  longjmp="$prefix"longjmp

  echo "   setjmp: $setjmp longjmp: $longjmp"
  echo "#undef SETJMP" >> $bigloo_config_h
  echo "#define SETJMP $setjmp" >> $bigloo_config_h
  echo "  public static byte[] SETJMP = \"$setjmp\".getBytes();" >> $bigloo_config_jvm
  echo "#undef LONGJMP" >> $bigloo_config_h
  echo "#define LONGJMP $longjmp" >> $bigloo_config_h
  echo "  public static byte[] LONGJMP = \"$longjmp\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # Does the system have bcopy?
  bcopy=`$autoconfdir/bcopy --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:bcopy. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_BCOPY" >> $bigloo_config_h
  if( test $bcopy = "1" ); then
    echo "   bcopy: yes"
    echo "#define HAVE_BCOPY 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_BCOPY = true;" >> $bigloo_config_jvm
  else
    echo "   bcopy: no"
    echo "#define HAVE_BCOPY 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_BCOPY = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # The number of window register
  window=`$autoconfdir/winreg --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:winreg. Aborting";
     exit 1;
  fi

  echo "   nb window register: " $window
  echo "#undef NB_WINDOW_REGISTER" >> $bigloo_config_h
  echo "#define NB_WINDOW_REGISTER $window" >> $bigloo_config_h
  echo "  public static int NB_WINDOW_REGISTER = $window;" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # Does the system have sigsetmask?
  sigsetmask=`$autoconfdir/sigsetmask --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:sigsetmask. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_SIGSETMASK" >> $bigloo_config_h
  if( test $sigsetmask = "0" ); then
    echo "   sigsetmask: no"
    echo "#define HAVE_SIGSETMASK 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_SIGSETMASK = false;" >> $bigloo_config_jvm
   else
    echo "   sigsetmask: yes"
    echo "#define HAVE_SIGSETMASK 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_SIGSETMASK = true;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # Does the system have sigprocmask?
  sigprocmask=`$autoconfdir/sigprocmask --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:sigprocmask. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_SIGPROCMASK" >> $bigloo_config_h
  if( test $sigprocmask = "0" ); then
    echo "   sigprocmask: no"
    echo "#define HAVE_SIGPROCMASK 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_SIGPROCMASK = false;" >> $bigloo_config_jvm
  else
    echo "   sigprocmask: yes"
    echo "#define HAVE_SIGPROCMASK 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_SIGPROCMASK = true;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # A warning if neither sigsetmask nor sigprocmask is defined
  if( test $sigsetmask = "0" -a $sigprocmask = "0"); then
     echo "*** WARNING:sigsetmask nor sigprocmask: yes"
     echo "(^C disabled in the interpreter)."
  fi

  # Does the system have alloca?
  alloca=`$autoconfdir/alloca --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:alloca. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_ALLOCA" >> $bigloo_config_h
  if( test $alloca = "1" ); then
    echo "   alloca: yes"
    echo "#define HAVE_ALLOCA 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_ALLOCA = true;" >> $bigloo_config_jvm
  else
    echo "   alloca: no"
    echo "#define HAVE_ALLOCA 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_ALLOCA = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # Does the system have getcwd?
  getcwd=`$autoconfdir/getcwd --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:getcwd. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_GETCWD" >> $bigloo_config_h
  if( test $getcwd = "0" ); then
    echo "   getcwd: no"
    echo "#define HAVE_GETCWD 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_GETCWD = false;" >> $bigloo_config_jvm
  else
    echo "   getcwd: yes"
    echo "#define HAVE_GETCWD 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_GETCWD = true;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # Does the system have getwd?
  getwd=`$autoconfdir/getwd --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:getwd. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_GETWD" >> $bigloo_config_h
  if( test $getwd = "0" ); then
    echo "   getwd: no"
    echo "#define HAVE_GETWD 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_GETWD = false;" >> $bigloo_config_jvm
  else
    echo "   getwd: yes"
    echo "#define HAVE_GETWD 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_GETWD = true;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # Where to find the socket api
  socket=`$autoconfdir/socket --user=$user --cc="$cc" --lib="$socketlibs"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:socket. Aborting";
     exit 1;
  fi

  if [ "$socket " = " " ]; then
    echo "   socket: yes"
  else
    echo "   socket: $socket"
    extralibs="$socket $extralibs"
  fi

  # Are the static constants aligned?
  cnstalign=`$autoconfdir/cnstalign --user=$user --cc="$cc" --alignment=$alignment`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:cnstalign. Aborting";
     exit 1;
  fi

  enforcedcnstalign=`$autoconfdir/enforcedcnstalign --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:enforcedcnstalign. Aborting";
     exit 1;
  fi

  echo "#undef CONSTANT_ALIGNED" >> $bigloo_config_h
  if( test $cnstalign = "1" ); then
    echo "   constant alignment: ok"
    echo "#define CONSTANT_ALIGNED 1" >> $bigloo_config_h
    echo "  public static boolean CONSTANT_ALIGNED = true;" >> $bigloo_config_jvm
  elif( test $cnstalign = "0" ); then
    if( test $enforcedcnstalign = "1" ); then
       echo "   constant alignment: enforced"
       echo "#define CONSTANT_ALIGNED 0" >> $bigloo_config_h
       echo "  public static boolean CONSTANT_ALIGNED = false;" >> $bigloo_config_jvm
    else
       echo "*** ERROR:configure:illegal alignment."
       echo "It is then impossible install Bigloo on this architecture, sorry."
       exit 1
    fi
  fi
  echo "" >> $bigloo_config_h

  # Endianness
  endian=`$autoconfdir/bigendian --user=$user --cc="$cc"`
  if( test $endian = "1" ); then
    echo "   Endianness: big"
    echo "#undef BGL_BIG_ENDIAN" >> $bigloo_config_h
    echo "#define BGL_BIG_ENDIAN 1" >> $bigloo_config_h
    echo "  public static boolean BGL_BIG_ENDIAN = true;" >> $bigloo_config_jvm
  else
    echo "   Endianness: little"
    echo "#undef BGL_BIG_ENDIAN" >> $bigloo_config_h
    echo "#define BGL_BIG_ENDIAN 0" >> $bigloo_config_h
    echo "  public static boolean BGL_BIG_ENDIAN = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # Does this system implements pipe?
  pipe=`$autoconfdir/pipe --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:pipe. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_PIPE" >> $bigloo_config_h
  if( test $pipe = "0" ); then
    echo "   popen/pclose: no"
    echo "#define HAVE_PIPE 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_PIPE = false;" >> $bigloo_config_jvm
  else
    echo "   popen/pclose: yes"
    echo "#define HAVE_PIPE 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_PIPE = true;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # Does this compiler implements longlong?
  longlong=`$autoconfdir/longlong --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:longlong. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_LONGLONG" >> $bigloo_config_h
  if( test $longlong = "1" ); then
    echo "   long long: yes"
    echo "#define HAVE_LONGLONG 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_LONGLONG = true;" >> $bigloo_config_jvm
  else
    echo "   long long: no"
    echo "#define HAVE_LONGLONG 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_LONGLONG = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # Is sigchld available for us
  sigchld=`$autoconfdir/sigchld --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:sigchld. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_SIGCHLD" >> $bigloo_config_h
  if( test "$sigchld" = "1" ); then
    echo "   sigchld: yes"
    echo "#define HAVE_SIGCHLD 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_SIGCHLD = true;" >> $bigloo_config_jvm
  else
    echo "   sigchld: no"
    echo "#define HAVE_SIGCHLD 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_SIGCHLD = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h
  
  # Is sigaction available
  sigaction=`$autoconfdir/sigaction --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:sigaction. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_SIGACTION" >> $bigloo_config_h
  if( test $sigaction = "1" ); then
    echo "   sigaction: yes"
    echo "#define HAVE_SIGACTION 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_SIGACTION = true;" >> $bigloo_config_jvm
  else
    echo "   sigaction: no"
    echo "#define HAVE_SIGACTION 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_SIGACTION = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h
  
  # Is select available
  select=`$autoconfdir/select --user=$user --cc="$cc"`
  echo "#undef BGL_HAVE_SIGACTION" >> $bigloo_config_h
  
  if [ "$select" = "1" ]; then
    echo "   select: yes"
    echo "#define BGL_HAVE_SELECT 1" >> $bigloo_config_h
    echo "  public static boolean BGL_HAVE_SELECT = true;" >> $bigloo_config_jvm
  else
    echo "   select: no"
    echo "#define BGL_HAVE_SELECT 0" >> $bigloo_config_h
    echo "  public static boolean BGL_HAVE_SELECT = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h
  
  # Is termio available
  termio=`$autoconfdir/termio --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:termio. Aborting";
     exit 1;
  fi

  echo "#undef HAVE_TERMIO" >> $bigloo_config_h
  if( test $termio = "1" ); then
    echo "   termio: yes"
    echo "#define HAVE_TERMIO 1" >> $bigloo_config_h
    echo "  public static boolean HAVE_TERMIO = true;" >> $bigloo_config_jvm
  else
    echo "   termio: no"
    echo "#define HAVE_TERMIO 0" >> $bigloo_config_h
    echo "  public static boolean HAVE_TERMIO = false;" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h
  
  # for now only the port is Unix
  echo "   operating system: unix"
  $autoconfdir/unix --user=$user >> $bigloo_config_h
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:os. Aborting";
     exit 1;
  fi
  echo "" >> $bigloo_config_h
  $autoconfdir/unix --user=$user --jvm >> $bigloo_config_jvm
  echo "" >> $bigloo_config_jvm

  # which shell to use
  `$shell -c "ls -l > /dev/null 2> /dev/null"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:$shell. Aborting";
     exit 1;
  fi

  echo "   shell: $shell"
  echo "#undef SHELL" >> $bigloo_config_h
  echo "#define SHELL \"$shell\"" >> $bigloo_config_h
  echo "  public static byte[] SHELL = \"$shell\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # which C compiler to use
  echo "   c compiler: $cc"
  echo "#undef C_COMPILER" >> $bigloo_config_h
  echo "#define C_COMPILER \"$cc\"" >> $bigloo_config_h
  echo "  public static byte[] C_COMPILER = \"$cc\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # C compiler option
  echo "   c option: $cflags"
  echo "#undef C_FLAGS" >> $bigloo_config_h
  echo "#define C_FLAGS \"$cflags\"" >> $bigloo_config_h
  echo "  public static byte[] C_FLAGS = \"$cflags\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # C optimization compiler option
  echo "   c compiler optimization: $coflags"
  echo "#undef C_OPTIM_FLAGS" >> $bigloo_config_h
  echo "#define C_OPTIM_FLAGS \"$coflags $cflags\"" >> $bigloo_config_h
  echo "  public static byte[] C_OPTIM_FLAGS = \"$coflags\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # C linker strip option
  echo "   c linker strip: $csflags"
  echo "#undef C_STRIP_FLAGS" >> $bigloo_config_h
  echo "#define C_STRIP_FLAGS \"$csflags\"" >> $bigloo_config_h
  echo "  public static byte[] C_STRIP_FLAGS = \"$csflags\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # C profile compiler option
  echo "   c compiler profiling: $cpflags"
  echo "#undef C_PROFILE_FLAGS" >> $bigloo_config_h
  echo "#define C_PROFILE_FLAGS \"$cpflags $cflags\"" >> $bigloo_config_h
  echo "  public static byte[] C_PROFILE_FLAGS = \"$cpflags $cflags\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # the library directory
  echo "   library directory: $libdir"
  echo "#undef LIBRARY_DIRECTORY" >> $bigloo_config_h
  echo "#define LIBRARY_DIRECTORY \"$libdir\"" >> $bigloo_config_h
  echo "  public static byte[] LIBRARY_DIRECTORY  = \"$libdir\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # the zip directory
  echo "   zip directory: $zipdir"
  echo "#undef ZIP_DIRECTORY" >> $bigloo_config_h
  echo "#define ZIP_DIRECTORY \"$zipdir\"" >> $bigloo_config_h
  echo "  public static byte[] ZIP_DIRECTORY  = \"$zipdir\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # additionals non bigloo library
  echo "   additional libraries: $extralibs"
  echo "#undef USER_LIBRARIES" >> $bigloo_config_h
  echo "#define USER_LIBRARIES \"$extralibs\"" >> $bigloo_config_h
  echo "  public static byte[] USER_LIBRARIES = \"$extralibs\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # the C beautifier
  echo "#undef C_BEAUTIFIER" >> $bigloo_config_h
  if( test `$autoconfdir/indent --user=$user --cc="$cc" --cflags="$cflags" --indent="$indent"` != "1" ); then
    echo "   c beautifier: no"
    echo "#define C_BEAUTIFIER \"\"" >> $bigloo_config_h
    echo "  public static byte[] C_BEAUTIFIER = \"\".getBytes();" >> $bigloo_config_jvm
  else
    echo "   c beautifier: $indent"
    echo "#define C_BEAUTIFIER \"$indent\"" >> $bigloo_config_h
    echo "  public static byte[] C_BEAUTIFIER = \"$indent\".getBytes();" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # the dirname command
  echo "#undef DIRNAME_CMD" >> $bigloo_config_h
  dirname=`$autoconfdir/dirname --user=$user --cc="$cc" --cflags="$cflags" --dirname="$dirname"`
  echo "   dirname: $dirname"
  echo "#define DIRNAME_CMD \"$dirname\"" >> $bigloo_config_h
  echo "  public static byte[] DIRNAME_CMD = \"$dirname\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # library basename
  echo "   library basename: $libraryname"
  echo "#undef LIBRARY_BASE_NAME" >> $bigloo_config_h
  echo "#define LIBRARY_BASE_NAME \"$libraryname\"" >> $bigloo_config_h
  echo "  public static byte[] LIBRARY_BASE_NAME =  \"$libraryname\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # double precision
  prec=`$autoconfdir/doubleprec --user=$user --cc="$cc"`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:doubleprec. Aborting";
     exit 1;
  fi

  echo "   double precision: $prec"
  echo "#undef DOUBLE_PRECISION" >> $bigloo_config_h
  echo "#define DOUBLE_PRECISION $prec" >> $bigloo_config_h
  echo "  public static int DOUBLE_PRECISION = $prec;" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # static link additional option
  ldstaticopt=`$autoconfdir/ldstaticopt --user=$user`
  echo "#undef ADDITIONAL_STATIC_LINK_OPTION" >> $bigloo_config_h
  echo "#define ADDITIONAL_STATIC_LINK_OPTION \"$ldstaticopt\"" >> $bigloo_config_h
  echo "  public static byte[] ADDITIONAL_STATIC_LINK_OPTION = \"$ldstaticopt\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # shared link additional option
  ldsharedopt=`$autoconfdir/ldsharedopt --user=$user $libdir`
  echo "#undef ADDITIONAL_SHARED_LINK_OPTION" >> $bigloo_config_h
  echo "#define ADDITIONAL_SHARED_LINK_OPTION \"$ldsharedopt\"" >> $bigloo_config_h
  echo "  public static byte[] ADDITIONAL_SHARED_LINK_OPTION = \"$ldsharedopt\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # The shared libraries
  echo "#undef HAVE_SHARED_LIBRARY" >> $bigloo_config_h
  if( test "$ldopt" = "no-share" ); then
     ldopt=
     echo "   shared library: no"
     echo "#define HAVE_SHARED_LIBRARY 0" >> $bigloo_config_h
     echo "  public static boolean HAVE_SHARED_LIBRARY = false;" >> $bigloo_config_jvm
  else
     ldopt=`$autoconfdir/ldshare --user=$user --cc="$cc" -ldopt="$ldopt"`
     if( test "$ldopt" = "" ); then
       echo "   shared library: no (because I don't know ld option)"
       echo "#define HAVE_SHARED_LIBRARY 0" >> $bigloo_config_h
       echo "  public static boolean HAVE_SHARED_LIBRARY = false;" >> $bigloo_config_jvm
     else
       echo "   shared library: yes"
       echo "#define HAVE_SHARED_LIBRARY 1" >> $bigloo_config_h
       echo "  public static boolean HAVE_SHARED_LIBRARY = true;" >> $bigloo_config_jvm
     fi
  fi

  # Does the system have dlopen?
  if [ ! "$ldopt " = " " ]; then
    dlopen=`$autoconfdir/dlopen --user=$user --cc="$cc" --dlopt="$dlopenopt"`
    if [ "$dlopen" != "0" ]; then
      echo "   dlopen: yes [$dlopen]" 
      echo "#define HAVE_DLOPEN 1" >> $bigloo_config_h
      echo "#define DLOPEN_LD_OPT \"$dlopen\"" >> $bigloo_config_h
      echo "  public static boolean HAVE_DLOPEN = true;" >> $bigloo_config_jvm
      echo "  public static byte[] DLOPEN_LD_OPT = \"$dlopen\".getBytes();" >> $bigloo_config_jvm
      extralibs="$dlopen $extralibs"
    else
      echo "   dlopen: no"
      echo "#define HAVE_DLOPEN 0" >> $bigloo_config_h
      echo "#define DLOPEN_LD_OPT \"\"" >> $bigloo_config_h
    fi
  else
    echo "   dlopen: no"
    echo "#define HAVE_DLOPEN 0" >> $bigloo_config_h
    echo "#define DLOPEN_LD_OPT \"\"" >> $bigloo_config_h
    echo "  public static boolean HAVE_DLOPEN = false;" >> $bigloo_config_jvm
    echo "  public static byte[] DLOPEN_LD_OPT = \"\".getBytes();" >> $bigloo_config_jvm
  fi
  echo "" >> $bigloo_config_h

  # Heap debug C compilation option
  echo "   heap debugging copt: $backptrflags"
  echo "#undef BGL_HEAP_DEBUG_COPT" >> $bigloo_config_h
  echo "#define BGL_HEAP_DEBUG_COPT \"$backptrflags\"" >> $bigloo_config_h
  echo "  public static byte[] BGL_HEAP_DEBUG_COPT = \"$backptrflags\".getBytes();" >> $bigloo_config_jvm
  echo "" >> $bigloo_config_h

  # Java configuration
  if [ "$jvmbackend" = "yes" -o "$jvmbackend" = "force" ]; then
    if [ "$jshell" != "sh" ]; then
       if [ "$jshell" != "msdos" ]; then
          echo "*** ERROR:configure:Illegal Java shell \"$jshell\" (should be either \"sh\" or \"msdos\")";
          exit 3
       fi
    fi

    if [ "$jvmbackend" = "yes" ]; then
      $autoconfdir/javatest --java=$java --jflags=$jflags --jvflags=$jvflags \
                            --javac=$javac --jcflags=$jcflags --user=$user

      if [ $? = 0 ]; then
        echo "   java: yes"
      else
        echo "   java: no"
        echo "*** ERROR:configure:Can't configure Java. Command:"
        echo "$autoconfdir/javatest --java=$java --jflags=$jflags --jvflags=$jvflags --javac=$javac --jcflags=$jcflags --user=$user"
        echo "failed unexpectedly (see configure.log for details)."
        echo ""
        echo "To give up with the JVM backend, use:"
        echo "  ./configure --jvm=no"
        exit 3
      fi
    fi
    java_configured=yes

    echo "#undef BGL_JAVA" >> $bigloo_config_h
    echo "#define BGL_JAVA \"$java\"" >> $bigloo_config_h
    echo "  public static byte[] BGL_JAVA = \"$java\".getBytes();" >> $bigloo_config_jvm

    echo "" >> $bigloo_config_h
    echo "#undef BGL_JAVA_OPT" >> $bigloo_config_h
    echo "#define BGL_JAVA_OPT \"$jflags\"" >> $bigloo_config_h
    echo "  public static byte[] BGL_JAVA_OPT = \"$jflags\".getBytes();" >> $bigloo_config_jvm

    echo "" >> $bigloo_config_h
    echo "#undef BGL_JAVA_VOPT" >> $bigloo_config_h
    echo "#define BGL_JAVA_VOPT \"$jvflags\"" >> $bigloo_config_h
    echo "  public static byte[] BGL_JAVA_VOPT = \"$jvflags\".getBytes();" >> $bigloo_config_jvm

    echo "" >> $bigloo_config_h
    echo "#undef BGL_JAVA_SHELL" >> $bigloo_config_h
    echo "#define BGL_JAVA_SHELL \"$jshell\"" >> $bigloo_config_h
    echo "  public static byte[] BGL_JAVA_SHELL = \"$jshell\".getBytes();" >> $bigloo_config_jvm

    echo "" >> $bigloo_config_h
    echo "#undef BGL_JAR" >> $bigloo_config_h
    echo "#define BGL_JAR \"$jar\"" >> $bigloo_config_h
    echo "  public static byte[] BGL_JAR = \"$jar\".getBytes();" >> $bigloo_config_jvm
  else
    echo "#undef BGL_JAVA" >> $bigloo_config_h
    echo "#define BGL_JAVA \"java\"" >> $bigloo_config_h
    echo "#undef BGL_JAVA_OPT" >> $bigloo_config_h
    echo "#define BGL_JAVA_OPT \"\"" >> $bigloo_config_h
    echo "#undef BGL_JAVA_VOPT" >> $bigloo_config_h
    echo "#define BGL_JAVA_VOPT \"\"" >> $bigloo_config_h
    echo "#undef BGL_JAR" >> $bigloo_config_h
    echo "#define BGL_JAR \"\"" >> $bigloo_config_h
    echo "#undef BGL_JAVA_SHELL" >> $bigloo_config_h
    echo "#define BGL_JAVA_SHELL \"sh\"" >> $bigloo_config_h
  fi

  echo "}" >> $bigloo_config_jvm
  echo
fi
  
#*---------------------------------------------------------------------*/
#*    Makefile.config                                                  */
#*    -------------------------------------------------------------    */
#*    This part of the configure script produces the file              */
#*    Makefile.config. This file contains machine dependant            */
#*    informations and location where Bigloo is to be installed.       */
#*---------------------------------------------------------------------*/
if [ $action = "all" -o $action = "Makefile.config" ]; then

  # Tell what we are doning
  echo "Configuring $makefile_cfg":

  # We create an unexisting temporary file name
  name=$tmp/foo
  while( test -f "$name.s" -o -f "$name.o" ); do 
    name="$name"x;
  done

  # We first cleanup the file
  rm -f $makefile_cfg 2> /dev/null
  touch $makefile_cfg

  # The Bigloo release number
  echo "RELEASE=$release" >> $makefile_cfg
  echo >> $makefile_cfg

  # The Boot directory
  echo "BOOTDIR=$bootdir" >> $makefile_cfg
  echo "BOOTBINDIR=$bootdir/bin" >> $makefile_cfg
  echo "BOOTLIBDIR=$bootdir/lib/$release" >> $makefile_cfg
  echo >> $makefile_cfg

  # Directories
  echo "BINDIR=$bindir" >> $makefile_cfg
  echo "LIBDIR=$libdir" >> $makefile_cfg
  echo "MANDIR=$mandir" >> $makefile_cfg
  echo "INFODIR=$infodir" >> $makefile_cfg
  echo "DOCDIR=$docdir" >> $makefile_cfg
  echo >> $makefile_cfg

  # Native backend  
  echo "NATIVEBACKEND=$nativebackend" >> $makefile_cfg

  # The basename
  echo "LIBRARYNAME=$libraryname" >> $makefile_cfg
  echo >> $makefile_cfg

  # The C compiler
  echo "CC=$cc" >> $makefile_cfg
  echo "CFLAGS=$coflags $cflags" >> $makefile_cfg
  echo "CSTRIPFLAGS=$csflags" >> $makefile_cfg
  echo "CPICFLAGS=$cpicflags" >> $makefile_cfg
  echo "CFLAGS_P=$""(CFLAGS) $cpflags" >> $makefile_cfg
  echo "CGCFLAGS=$cgcflags $gcspecial" >> $makefile_cfg
  echo "EXTRALIBS=$extralibs" >> $makefile_cfg
  echo "BACKPTRFLAGS=$backptrflags" >> $makefile_cfg
  echo >> $makefile_cfg

  # additional bigloo compiler link flags (some architecture such as AIX
  # require a special to link huge executable)
  ldextraopt=`$autoconfdir/ldextraopt --user=$user --cc="$cc"`

  echo "EXTRA_LD_OPT=$ldextraopt" >> $makefile_cfg
  if [ $sharedcompiler = "yes" ]; then
     echo "SHRD_COMP=yes" >> $makefile_cfg;
  else
     echo "SHRD_COMP=no" >> $makefile_cfg;
  fi

  # Executable suffix
  echo "EXE_SUFFIX=$exe" >> $makefile_cfg;

  # The assembler
  echo "   checking $as"
  as=`$autoconfdir/ascpp --user=$user -as="$as" -cc="$cc" -tmp=$tmp --name=$name`
  if [ $? != "0" ]; then
     echo "*** ERROR:configure:as. Aborting";
     exit 1;
  fi

  if [ "$as " = " " ]; then
    echo "*** ERROR:configure:$as:can't find as that invokes cpp,";
    echo "set $as variable."
    rm -f $name.s $name.o
    exit 1;
  else
     echo "AS=$as" >> $makefile_cfg
  fi 
  echo >> $makefile_cfg

  # Ar checking
  echo "   checking $ar $arflags"

  (cd $tmp; 
   compile="$ar $arflags $name.a $name.o > /dev/null 2> /dev/null";
   if eval $compile; then
     /bin/rm -f $name.s $name.o $name.a
   else
      arflags="-q -c";
      compile="$ar $arflags $name.a $name.o > /dev/null 2> /dev/null";
      if eval $compile; then
        /bin/rm -f $name.s $name.o $name.a
      else
        echo "*** ERROR:configure:ar:Can't automatically setup ar flags"; 
        echo "Please, set ar flags up inside ./configure";
        /bin/rm -f $name.s $name.o $name.a; 
        exit 1
      fi
   fi) || exit $*
  echo "AR=$ar" >> $makefile_cfg
  echo "ARFLAGS=$arflags" >> $makefile_cfg
  
  # Does the system require ranlib?
  if( test `$autoconfdir/ranlib --user=$user --cc="$cc"` = "0" ); then
     echo "   ranlib: no"
     echo "RANLIB=true" >> $makefile_cfg
  else
     echo "   ranlib: yes"
     echo "RANLIB=ranlib" >> $makefile_cfg
  fi

  # The shared libraries
  if( test "$ldopt" = "" ); then
    echo "LD=true" >> $makefile_cfg
  else
    echo "LD=ld $ldopt" >> $makefile_cfg
  fi

  # The suffix of shared library
  echo "SHAREDSUFFIX=$sharedsuffix" >> $makefile_cfg
  echo >> $makefile_cfg

  # Does the system supports strip
  if( `$autoconfdir/strip --strip=$strip --user=$user --cc="$cc"` ); then
     echo "   strip: $strip"
     echo "STRIP=$strip" >> $makefile_cfg
     echo "" >> $makefile_cfg
  else
     echo "   strip: no"
     echo "STRIP=true" >> $makefile_cfg
     echo "" >> $makefile_cfg
  fi

  # Checking xemacs
  if( test `$autoconfdir/xemacsbin --xemacs=$xemacs` = "yes" ); then
     echo "   xemacs: yes"
  else
     echo "   xemacs: no"
     xemacs=""
  fi
  
  # The xemacs source path
  if [ "$xemacs " != " " ]; then
     if( test -d $lispdir ); then
        xemacslisppath=$lispdir
     else
        xemacslisppath=`$autoconfdir/xemacspath --user=$user --xemacs="$xemacs" --cc="$cc" --exe=$exe`
     fi

     if( test "$xemacslisppath" = "" ); then
        echo "   xemacs: no (because I can't find xemacs lisp path)"
     else
        echo "   xemacs lisp path: $xemacslisppath"
        echo "EMACS=$xemacs" >> $makefile_cfg
        echo "EMACSDIR=$xemacslisppath" >> $makefile_cfg
     fi
  fi
  echo >> $makefile_cfg

  # bmask
  echo "BMASK=$bmask" >> $makefile_cfg
  echo >> $makefile_cfg

  # The GC directory
  echo "   GC dir: $gcdir"
  echo "GC_DIR=$gcdir" >> $makefile_cfg
  echo "" >> $makefile_cfg

  # The info version
  infoinfo=`$autoconfdir/info --user=$user \
                              --makeinfo="$makeinfo" \
                              --texi2dvi="$texi2dvi" \
                              --texi2dviopt="$texi2dviopt" \
                              --texi2pdf="$texi2pdf" \
                              --texi2html="$texi2html" \
                              --texi2htmlopt="$texi2htmlopt"`

  if [ "$?" = "0" ]; then
     for p in $infoinfo; do
        case $p in 
          "")
             break;;
          makeinfover=*)
             makeinfover="`echo $p | sed 's/^[-a-z_.]*=//'`";;
          texi2dvi=*)
             texi2dvi="`echo $p | sed 's/^[-a-z0-9_.]*=//'`";;
          texi2dviopt=*)
             texi2dviopt="`echo $p | sed 's/^[-a-z0-9_.]*=//'`";;
          texi2pdf=*)
             texi2pdf="`echo $p | sed 's/^[-a-z0-9_.]*=//'`";;
          texi2html=*)
             texi2html="`echo $p | sed 's/^[-a-z0-9_.]*=//'`";;
          texi2htmlopt=*)
             texi2htmlopt="`echo $p | sed 's/^[^=]*=//'`";;
        esac
     done
     if [ "$makeinfover" = "old" ]; then
         makeinfoopt="-D oldinfo"
     fi

     echo "MAKEINFO=$makeinfo" >> $makefile_cfg
     echo "MAKEINFOOPT=$makeinfoopt" >> $makefile_cfg
     echo "TEXI2DVI=$texi2dvi" >> $makefile_cfg
     echo "TEXI2DVIOPT=$texi2dviopt" >> $makefile_cfg
     echo "TEXI2HTML=$texi2html" >> $makefile_cfg
     echo "TEXI2HTMLOPT=$texi2htmlopt" >> $makefile_cfg
     echo "TEXI2PDF=$texi2pdf" >> $makefile_cfg
  else
     echo "   makeinfo: no"
     makeinfo=no
     makeinfoopt=
     texi2dvi=
     texi2dviopt=
     texi2html=
     texi2htmlopt=
     texi2pdf=

     echo "MAKEINFO=" >> $makefile_cfg
  fi

  # The info installation
  echo "   checking install-info"
  if [ "$iinfo " = " " ]; then
    installinfo=`$autoconfdir/installinfo --user=$user --cc=$cc --exe=$exe`
  else
    installinfo=`$autoconfdir/installinfo --user=$user --cc=$cc --installinfo=$iinfo --exe=$exe`
  fi

  if [ "installinfo " = " " ]; then
     echo "   install-info: no"
     echo "INSTALLINFO=\"\"" >> $makefile_cfg
  else
     echo "   install-info: $installinfo"
     echo "INSTALLINFO=$installinfo" >> $makefile_cfg
  fi

  # The java configuration
  if [ "$jvmbackend" = "yes" -o "$jvmbackend" = "force" ]; then

    if [ "$jvmbackend" = "yes" ]; then
      $autoconfdir/ziptest --zip=$zip --zflags=$zflags --user=$user

      if [ $? = 0 ]; then
         echo "   zip: yes"
      else
         echo "   zip: no"
         echo "*** ERROR:configure:Can't configure JVM back-end"
         exit 3
      fi

      $autoconfdir/jartest --jar=$jar --user=$user

      if [ $? = 0 ]; then
         echo "   jar: yes"
      else
         echo "   jar: no"
         echo "*** ERROR:configure:Can't configure JVM back-end"
         exit 3
      fi

      if [ "$java_configured" = "no" ]; then
        $autoconfdir/javatest --java=$java --jflags=$jflags --jvflags=$jvflags \
                              --javac=$javac --jcflags=$jcflags --user=$user

        if [ $? = 0 ]; then
           echo "   java: yes"
        else
           echo "   java: no"
           echo "*** ERROR:configure:Can't configure JVM back-end"
           exit 3
        fi
        java_configured=yes
      fi
    else
        java_configured=yes
    fi

    echo "" >> $makefile_cfg
    echo "JVMBACKEND=yes" >> $makefile_cfg
    echo "JAVA=$java" >> $makefile_cfg
    echo "JFLAGS=$jflags" >> $makefile_cfg
    echo "JVFLAGS=$jvflags" >> $makefile_cfg
    echo "JAVAC=$javac" >> $makefile_cfg
    echo "JCFLAGS=$jcflags" >> $makefile_cfg
    echo "ZIP=$zip" >> $makefile_cfg
    echo "ZFLAGS=$zflags" >> $makefile_cfg
    echo "JAR=$jar" >> $makefile_cfg
    echo "JSHELL=$jshell" >> $makefile_cfg

    # How to link the Java files
    echo "" >> $makefile_cfg
    echo "JVMLN=$jvmln" >> $makefile_cfg
    echo "JVMCPATH=$jvmcpath" >> $makefile_cfg

    # Cygwin prefix
    if [ "$posixos" = "cygwin" ]; then
      echo "" >> $makefile_cfg
      echo CYGWINPREFIX=`echo "$cygwindospath" | sed -e 's/\\\\/\\\\\\\\/g'` >> $makefile_cfg
      echo "CYGWINJVMPATH=-classpath \".;$cygwindospath"`echo "$bootdir/lib/$release" | sed -e 's/\//\\\\\\\\/g'`"\\\\bigloo.zip\"" >> $makefile_cfg
      echo "RECETTEJVM=recette.bat" >> $makefile_cfg
    else
      echo "RECETTEJVM=recette" >> $makefile_cfg
    fi
  else
    echo "" >> $makefile_cfg
    echo "JVMLN=$jvmln" >> $makefile_cfg
    echo "JVMBACKEND=no" >> $makefile_cfg
  fi

fi

#*---------------------------------------------------------------------*/
#*    Ok, we are done now                                              */
#*---------------------------------------------------------------------*/
if [ "$summary" = "yes" ]; then
  echo 
  echo 
  echo "** Configuration summary **"
  echo 
  echo "Release number:"
  echo "  Bigloo release number................. $release"
  echo "  Bigloo default backend................ $defaultbackend"
  echo
  echo "Directories where Bigloo will be installed:"
  echo "  binaries.............................. $bindir"
  echo "  standard library...................... $libdir"
  echo "  standard zip.......................... $zipdir"
  echo "  manual pages.......................... $mandir"
  echo "  info documentation.................... $infodir"
  echo "  lisp files............................ $lispdir"
  echo
  echo "Compilers and linkers:"
  echo "  C compiler used....................... $cc"
  echo "  options for compiling................. $cflags"
  echo "  options for optimizing................ $coflags"
  echo "  options for stripping................. $csflags"
  echo "  options for PIC code.................. $cpicflags"
  echo "  options for profiling................. $cpflags"
  echo "  options for linking................... $extralibs"
  echo "  assembly.............................. $as"
  echo "  static library builder................ $ar"
  echo "  options for building static libs...... $arflags"
  if [ "$ldopt " = " " ]; then
    echo "  support for dynamic libraries......... no"
  else
    echo "  support for dynamic libraries......... yes"
    echo "  suffix of shared libraries............ $sharedsuffix"
    echo "  options for linking with shared libs.. $ldopt"
  fi
  echo "  dynamically linked compiler........... $sharedcompiler"
  echo
  echo "JVM:"
  if [ "$jvmbackend" = "yes" -o "$jvmbackend" = "force" ]; then
    echo "  JVM support........................... yes"
    if [ "$posixos" = "cygwin" ]; then
      echo "  Cygwin dos path....................... $cygwindospath"
    fi
    echo "  java default shell.................... $jshell"
    echo "  javac................................. $javac"
    echo "  options for compiling java............ $jcflags"
    echo "  java.................................. $java"
    echo "  options for running java.............. $jflags"
    echo "  options no byte code verification..... $jvflags"
    echo "  zip................................... $zip"
    echo "  zip flags............................. $zflags"
    echo "  jar................................... $jar"
  else
    echo "  JVM support........................... no"
  fi
  echo
  echo "GC configuration:"
  echo "  options for compilin the collector.... $cgcflags $gcspecial"
  echo "  options for compiling with debug...... $backptrflags"
  echo
  echo "XEmacs configuration:"
  echo "  xemacs................................ $xemacs"
  echo "  lisp directory........................ $xemacslisppath"
  echo
  echo "Info configuration:"
  if [ "$makeinfo" = "no" ]; then
    echo "  makeinfo.............................. no"
  else
    echo "  makeinfo.............................. $makeinfo"
    echo "  options for compiling info files...... $makeinfoopt"
    if [ "$texi2dvi " = " " ]; then
      echo "  texi2dvi.............................. no"
      echo "  texi2dvi options...................... no"
    else
      echo "  texi2dvi.............................. $texi2dvi"
      echo "  texi2dvi options...................... $texi2dviopt"
    fi
    if [ "$texi2html " = " " ]; then
      echo "  texi2html............................. no"
    else
      echo "  texi2html............................. $texi2html"
      echo "  texi2html options..................... $texi2htmlopt"
    fi
    if [ "$texi2pdf " = " " ]; then
      echo "  texi2pdf.............................. no"
    else
      echo "  texi2pdf.............................. $texi2pdf"
    fi
    if [ "installinfo " = " " ]; then
      echo "  installinfo........................... no"
    else
      echo "  installinfo........................... $installinfo"
    fi
  fi
  echo
  echo "Misc configuration:"
  echo "  mask for installed files.............. $bmask"
  echo 
  echo "System configuration:"
  echo "  hardware tuning....................... $hardtune"
  echo "  operating system...................... $posixos"
  echo "  default executable name............... $aout"
  if( test $stackgrows = "1" ); then
    echo "  stack grows........................... down"
  else
    echo "  stack grows........................... up"
  fi
  if( test $endian = "1" ); then
    echo "  endianness............................ big"
  else
    echo "  endianness............................ little"
  fi
  if( test $alloca = "1" ); then
    echo "  alloca................................ yes"
  else
    echo "  alloca................................ no"
  fi
  if( test $select = "1" ); then
    echo "  select................................ yes"
  else
    echo "  select................................ no"
  fi
  echo "  setjmp/longjmp........................ $setjmp/$longjmp"
  echo "  alignment............................. $alignment"
  echo "  window register....................... $window"
  if( test $sigsetmask = "1" ); then
    echo "  sigsetmask............................ yes"
  else
    echo "  sigsetmask............................ no"
  fi
  if( test $sigprocmask = "1" ); then
    echo "  sigprocmask........................... yes"
  else
    echo "  sigprocmask........................... no"
  fi
  echo 
fi
