#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/configure                            */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Tue Jan 25 16:05:10 1994                          */
#*    Last change :  Fri May 25 06:59:11 2012 (serrano)                */
#*    Copyright   :  1994-2012 Manuel Serrano, see LICENSE file        */
#*    -------------------------------------------------------------    */
#*    The Bigloo configuration file                                    */
#*    -------------------------------------------------------------    */
#*    Please, dont talk to me about autoconf. I simply dont want       */
#*    to hear about it...                                              */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    Bigloo revision number                                           */
#*---------------------------------------------------------------------*/
release=3.8c
version=
bigloourl=http://www.inria.fr/sophia/teams/indes/fp/Bigloo

bigloosvn=ssh://hop@hop.inria.fr/bigloo

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

#*--- api -------------------------------------------------------------*/
apis="pthread fthread ssl sqlite web multimedia mail calendar pkgcomp pkglib gstreamer text srfi1 srfi27 packrat crypto openpgp phone alsa mpg123 flac avahi phidget csv"

#*--- bee configuration -----------------------------------------------*/
bee=partial # "partial" or "full"

#*--- build directory -------------------------------------------------*/
buildtmp=$TMPDIR

#*--- C back-end user configure ---------------------------------------*/
nativebackend=yes # set to "no" not to install the native (C) back-end
ccstyle=gcc
cc=$CC  # left blank for default automatic configuration
cflags=$CFLAGS
lflags=$LDFLAGS
bigloo=$BIGLOO # used only for cross compiling
if [ "$BFLAGS " != " " ]; then
  bflags=$BFLAGS;
else
  bflags="-O3 -fcfa-arithmetic -q";
fi
bootflags=""
featureflags=
coflags=-O3

cstrip=""
cpicflags="demanded" # Possible values for cpicflags are:
             #  - "no" not to use position independent code (recommended)
             #  - "demanded" auto configuration but with a preference to "no"
             #  - any legal C compiler option that enables PIC code.
             #  - blank (uninitalized) for automatic configuration of the
             #    position independent code compiler option
as=          # left blank for autoconfiguration
ar=          # left blank for autoconfiguration
ranlib=      # left blank for autoconfiguration
arflags=     # left blank for autoconfiguration
ldstyle=gcc
ldflags=
ld=
ldlibs=-lc
ldcomplibs=-lc
strip=       # left blank for autoconfiguration
longlong=    # The C type to represent long long integers
havelonglong=
stringsplit="0"

gcconfigureopt="--disable-gcj-support --disable-java-finalization --disable-libcord"
gcconfigurethreadsopt=--enable-thread

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

#*--- Misc user configuration -----------------------------------------*/
shell=/bin/sh
shell_rm="/bin/rm"
shell_mv="/bin/mv"
bgl_shell_rm=$BGLRM
bgl_shell_mv=$BGLMV
emacs=
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=""
cobj=o
specific=""
ln_s="ln -s"

#*--- gmp version (left blank for autoconfiguration)    ---------------*/
gmpversion=
gmpforce=no
customgmp=no
gmpsrc=$GMPSRC
gmpconfigureopt=

srfi27force=no

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

#*--- posix threads library (left blank for autoconfiguration) --------*/
threadsupport=
pthreadlibs=
pthreadtimedlock=1
pthreadtermsig=15
pthreadlocalstorage=

#*--- openssl library (left blank for autoconfiguration) --------------*/
openssllibs=
openssldtls=
opensslv2=
opensslv23=

#*--- sqlite library (left blank for autoconfiguration) ---------------*/
sqlitelibs=

#*--- dbus library (left blank for autoconfiguration) -----------------*/
dbuslibs=

#*--- gstreamer (left blank for autoconfiguration) --------------------*/
gstreamer=
gstreamerlibs=
gstreamercflags=
gstreameraudio=
gstreameraudiolibs=
gstreameraudiocflags=
gstusethread=1

#*--- alsa (left blank for autoconfiguration) -------------------------*/
alsa=
alsalibs=
alsacflags=

#*--- mpg123 (left blank for autoconfiguration) -----------------------*/
mpg123=
mpg123libs=
mpg123cflags=

#*--- flac (left blank for autoconfiguration) -------------------------*/
flac=
flaclibs=
flaccflags=

#*--- avahi (left blank for autoconfiguration) ------------------------*/
avahi=
avahilibs=
avahicflags=

#*--- phidget (left blank for autoconfiguration) ----------------------*/
phidget=
phidgetlibs=
phidgetlibdir=$PHIDGETLIBDIR
phidgetcflags=
phidgetversion=21

#*--- regexp ----------------------------------------------------------*/
regexp=

#*--- gc source directory (left blank for default configuration) ------*/
customgc=yes
gccustom=gc-7.3alpha1-20120316
#gccustom=gc-7.2alpha6
#gccustom=bdwgc-7_2alpha5-20110313
#gccustom=bdwgc-7_2alpha5-20110107
gcversion=
# the following  variable is relevant only when using
# standard (i.e. already existing and operational) Boehm's GC
# and when customgc=no
stdgclib=gc
gcneedstackbase=0

isoc99=0
stdint=
stdlibint=0
unistdint=

#*--- indent ----------------------------------------------------------*/
indent="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 -----------------------------------*/
# obsolete, don't use it, use modXXX instead
bmask=755
modexe=755
moddir=755
modfile=644

#*--- ld shared library option ----------------------------------------*/
# set $ldopt to `no-share' if you don't want shared library
ldopt=
# set $ldsoname to `blank' if you want to force it empty
ldsoname=
ldinstallname=
ldinstallnamedirroot=lib
sharedsuffix=so
sharedlibraryclosed=no
sharedlibrarygcclosed='-l$(GCLIB)-$(RELEASE)'

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

#*--- forced OS -------------------------------------------------------*/
hostos=
hostosversion=
hostcpu=
jvmrecettebootpath=
jvmapibootpath=
oscharset=

buildos=
buildosversion=
buildcpu=

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

#*--- mingw/macosx specific configuration ------------------------------------*/
mingw="no"
macosx=auto

#*--- android specifics -----------------------------------------------*/
droidroot=$DROID_ROOT
droidsdkroot=$DROID_SDK_ROOT
droidtarget=generic
droidtmp=

#*---------------------------------------------------------------------*/
#*    Hacker variables                                                 */
#*    -------------------------------------------------------------    */
#*    Dont modifiy these variables unless you know what you are        */
#*    doing.                                                           */
#*---------------------------------------------------------------------*/
#*--- configure debugging ---------------------------------------------*/
configurelog=configure.log

#*--- The basename of the compiler and tools --------------------------*/
afile=bglafile
jfile=bgljfile
btags=bgltags
bdepend=bgldepend
bmake=bglmake
bpp=bglpp
bprof=bglprof
mco=bglmco
jas=bgljas
bmem=bglmem
bmemrun=bglmemrun
bdb=bgldb
bglpkg=bglpkg

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

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

#*--- custom GC configuration -----------------------------------------*/
gcincdir=
gclibdir=
customgclib=bigloogc
gchaveblocking=0
gchavedoblocking=0
gcfinalizer=0

#*--- Cross Compilation -----------------------------------------------*/
hostsh=
buildsh=

#*--- bglpkg compilation ----------------------------------------------*/
# valid values are "no", "yes" or "force"
enable_bgpkg="yes"

#*---------------------------------------------------------------------*/
#*                 !!! DONT EDIT AFTER THIS LINE !!!                   */
#*---------------------------------------------------------------------*/
action=all
actiongc=install
branch="`echo $release | sed 's/[.a-z]*//g'`0";
mode=standard
tuning=
makefile_cfg=Makefile.config
pwd=`pwd`
bootdir=$pwd
buildbindir=
cgcfinalflags="-DFINALIZE_ON_DEMAND"
bigloo_h=
bigloo_gc_h=
bigloo_config_h=
bigloo_config_jvm=
bigloo_config_sch=
bigloo_config_el=
summary=yes
java_configured=no
os=posix
gcspecial=
gcthread=
hardtune=
emacswarning=
stacksizerequired=2
configureinfo="no"
dnscache=1
scmpkgversion=0.0.1

autoconfdir=`dirname $0 2> /dev/null`/autoconf

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

logopt="$*"

autoconf="$autoconfdir/runtest -v1 -- "

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

    --bootconfig)
      bindir=$PWD/bin;
      libdir=$PWD/lib;
      fildir=$release;
      zipdir=$libdir/$fildir;
      dlldir=$libdir/$fildir;
      bootdir=$PWD;
      mandir=$HOME/house/man/man1
      lispdir=$HOME/emacs/site-lisp/bigloo;
      docdir=$PWD/manuals;
      sharedcompiler=no;
      sharedbde=yes;
      infodir=$HOME/house/info;
      java=java;
      javac=javac;
      ld=gcc;
      cflags="$cflags -Wpointer-arith -Wswitch -Wtrigraphs -DBGL_BOOTCONFIG";
      bootflags="$bootflags -cg";
      jvmbackend="force";
      mode=standard;
      configureinfo="yes";
      bee="full";
      havebdb=1;
      pthreadlocalstorage=;
      action="all";;

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

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

    --bigloo_config.h)
      action="bigloo_config";;

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

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

    --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/^[^=]*=//'`";;

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

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

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

    --configure.log=*)
      configurelog="`echo $1 | sed 's/^[^=]*=//'`";;

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

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

    --gcprefix=*)
      gcprefix="`echo $1 | sed 's/^[^=]*=//'`";
      gclibdir=$gcprefix/lib;
      gcincdir=$gcprefix/include/gc;;

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

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

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

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

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

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

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

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

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

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

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

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

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

    --xemacs=*)
      emacs="`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;
      fildir=bigloo/$release;
      zipdir=$libdir/$fildir;
      dlldir=$libdir/$fildir;
      mandir=$prefix/man/man1;
      infodir=$prefix/info;
      docdir=$prefix/doc/bigloo-$release;;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    --bee=partial)
      bee="partial";;

    --bee=full)
      bee="full";;

    --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;
      jar="`echo $1 | sed 's/^[^=]*=//'`/jar cmf";;

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

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

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

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

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

    --no-ldpreload)
      ldpreload="no";;

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

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

    --os-macosx)
      hostos="darwin";;

    --no-os-macosx)
      macosx=false;;

    --os-android)
      hostos="android";;

    --android-sdk-root=*)
      droidsdkroot="`echo $1 | sed 's/^[^=]*=//'`";;

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

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

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

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

    --cygwin-dos-jvm=yes)
      cygwindosjvm="yes";;

    --cygwin-dos-jvm=no)
      cygwindosjvm="no";;

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

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

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

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

    --arch=k6-2)
      hardtune="k6-2";
      gcspecial=-DUSE_3DNOW_PREFETCH;;

    --arch=k6-3)
      hardtune="k6-3";
      gcspecial=-DUSE_3DNOW_PREFETCH;;

    --arch=pentium3)
      hardtune="pentium3";
      gcspecial=-DUSE_I686_PREFETCH;;

    --arch=pentium4)
      hardtune="pentium4";
      gcspecial=-DUSE_I686_PREFETCH;;

    --arch=i586)
      hardtune="i586";;

    --arch=i686)
      hardtune="i686";;

    --no-summary)
      summary=no;;

    --icc)
      if [ "$cc " = " " ]; then
        cc=icc;
      fi;
      as=icc;
      ldopt="no-share";
      coflags="$coflags -O3 -ip";
      customgc=no;
      extralibs="";
      cstrip="no";;

    --strip=no)
      cstrip="no";
      strip="no";;

    --customgc=yes|--customgc)
      customgc=yes;;

    --customgc=no)
      customgc=no;;

    --finalization=yes)
      gcfinalizer=1;
      cgcfinalflags=;;

    --finalization=no)
      cgcfinalflags=-DFINALIZE_ON_DEMAND;;

    --stack-check=no)
      stacksizerequired=0;;

    --benchmark=no)
      mode=standard;;

    --benchmark=yes)
      if [ "$tuning " = "MacOS X " ]; then
        echo "*** ERROR: --benchmark is incompatible with --os-macosx";
        exit 1;
      fi;
      mode=benchmark;;

    --debug)
      cflags="$cflags -g";
      bflags="$bflags -cg";;

    --debug2)
      cstrip="";
      cflags="-g";
      bflags="-cg -q";;

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

    --configureinfo=no)
      configureinfo="no";;

    --configureinfo=yes)
      configureinfo="yes";;

    --mingw=yes)
      mingw="yes";;

    --enable-thread|--enable-threads)
      threadsupport=yes;
      addp=1;
      addf=1;
      for a in $apis; do
        case $a in
          pthread) addp=0;;
          fthread) addf=0;;
        esac;
      done
      if [ $addf = 1 ]; then
        apis="fthread $apis";
      fi
      if [ $addp = 1 ]; then
        apis="pthread $apis";
      fi
      ;;

    --disable-thread|--disable-threads)
      threadsupport=no;
      napis=;
      for a in $apis; do
         if [ $a != "fthread" -a $a != "pthread" -a $a != "gstreamer" ]; then
           if [ "$napis " = " " ]; then
             napis="$a";
           else
             napis="$napis $a";
           fi
         fi
      done
      apis=$napis;;

    --enable-thread-local-storage)
      pthreadlocalstorage=yes;;

    --disable-thread-local-storage)
      pthreadlocalstorage=no;;

    --thread-local-storage=auto)
      pthreadlocalstorage=;;

    --enable-gstreamer-thread)
      gstusethread=1;;

    --disable-gstreamer-thread)
      gstusethread=0;;

    --no-gmp|--disable-gmp)
      gmpversion="no";;

    --enable-gmp)
      gmpversion=""
      gmpforce="yes";;

    --customgmp=yes|--customgmp)
      customgmp=yes;;

    --customgmp=no)
      customgmp=no;;

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

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

    --enable-bglpkg)
      enable_bglpkg="force";;

    --disable-bglpkg)
      enable_bglpkg="no";;

    --enable-srfi27)
      srfi27force="yes";;

    --enable-*)
      api="`echo $1 | sed 's/--[^-]*-//'`";
      add=1;
      for a in $apis; do
        if [ "$a " = "$api " ]; then
          add=0;
          break;
        fi
      done
      if [ $add = 1 ]; then
        apis="$api $apis";
      fi
      ;;

    --disable-*)
      api="`echo $1 | sed 's/--[^-]*-//'`";
      napis=;
      for a in $apis; do
         if [ $a != $api ]; then
           if [ "$napis " = " " ]; then
             napis="$a";
           else
             napis="$napis $a";
           fi
         fi
      done
      apis=$napis;;

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

    -*)
      if [ "$1" != "-h" -a "$1" != "-help" -a "$1" != "--help" ]; then
        echo "*** ERROR: unknown option \"$1\""
        echo "Run \"$0 --help\" for available options." >&2;
        exit 1;
      fi
      # Existing apis
      eapis=
      cd $bootdir/api;
      for p in *; do
        if [ -d $p ]; then
          if [ "$eapis " = " " ]; then
            eapis="$p";
          else
            eapis="$eapis|$p";
          fi
        fi
      done;
      cd $bootdir;
      echo "Bigloo compiler:"  >&2;
      echo "   --native=yes|no [default yes]" >&2;
      echo "   --jvm=yes|no|force [default no]" >&2;
      echo "   --bee=partial|full [default partial]" >&2;
      echo "" >&2;
      echo "API:" >&2;
      echo "   --enable-[$eapis]" >&2;
      echo "   --disable-[$eapis]" >&2;
      echo "" >&2;
      echo "Path:"  >&2;
      echo "   --prefix=dir (sets bin, lib, zip, man, info and doc dirs)" >&2;
      echo "   --bindir=file" >&2;
      echo "   --libdir=file" >&2;
      echo "   --fildir=file" >&2;
      echo "   --zipdir=file" >&2;
      echo "   --dlldir=file" >&2;
      echo "   --mandir=file" >&2;
      echo "   --infodir=file" >&2;
      echo "   --docdir=file" >&2;
      echo "   --tmpdir=file (Bigloo tmp dir)" >&2;
      echo "   --tmp=file (Installation tmp dir)" >&2;
      echo "   --lispdir=file" >&2;
      echo "" >&2;
      echo "GC:"  >&2;
      echo "   --customgc=yes|no [default yes]" >&2;
      echo "   --gcprefix=dir (non-custom gc installation prefix (/usr)"  >&2;
      echo "   --gclibdir=dir (non-custom gc library dir (/usr/lib)" >&2;
      echo "   --gcincdir=dir (non-custon gc include dir (/usr/include/gc)" >&2;
      echo "   --gccustomversion=version (custom gc version, e.g. \"gc-7.1\")" >&2;
      echo "   --gccustominstall=[install|skip] (configure and install the gc))" >&2;
      echo "" >&2;
      echo "Tools and compilers:"  >&2;
      echo "   --bigloo=comp [default bigloo]" >&2;
      echo "   --cc=comp [default gcc]" >&2;
      echo "   --ld=comp [default gcc]" >&2;
      echo "   --as=asm" >&2;
      echo "   --bflags=Bigloo compilation flags" >&2;
      echo "   --cflags=C compilation flags" >&2;
      echo "   --lflags=compiler link flags" >&2;
      echo "   --coflags=optimization_flags" >&2;
      echo "   --cpicflags=pic_flags" >&2;
      echo "   --ldlibs=ld_libs" >&2;
      echo "   --ldcomplibs=ld_compiler_libs" >&2;
      echo "   --ldflags=ld_flags" >&2;
      echo "   --emacs=file" >&2;
      echo "   --xemacs=file (deprecated, use \"--emacs\" option)" >&2;
      echo "   --indent=file" >&2;
      echo "   --icc (configure for icc)"  >&2;
      echo "   --mv=cmd [default $shell_mv]" >&2;
      echo "   --rm=dmd [default $shell_rm]" >&2;
      echo "" >&2;
      echo "Host configuration:"  >&2;
      echo "   --arch=[i586|i686|athlon|athlon-tbird|athlon-mp|athlon-xp|k6-2|k6-3|pentium3|pentium4] (configure for specified hardware)"  >&2;
      echo "   --a.out=file" >&2;
      echo "   --a.bat=file" >&2;
      echo "   --dirname=file-or-command" >&2;
      echo "   --force-hostos=operating-system" >&2;
      echo "   --os-win32" >&2;
      echo "   --os-macosx (tune for MacOSX)"  >&2;
      echo "   --no-os-macosx (disable MacOSX auto configuration)"  >&2;
      echo "   --os-android (configure for Android)"  >&2;
      echo "   --android-sdk-root=path (Android SDK root directory)"  >&2;
      echo "   --android-root=path (Android root directory)"  >&2;
      echo "   --android-target=target (defaults to \"generic\")"  >&2;
      echo "   --android-tmp=path (tmp directory on the emulator)"  >&2;
      echo "   --cygwin-dos-path=[dos path]" >&2;
      echo "   --cygwin-dos-jvm=yes|no [default yes]" >&2;
      echo "   --no-share (disable shared libraries support)" >&2;
      echo "   --no-gmp (disable gmp libraries support)" >&2;
      echo "   --no-ldpreload" >&2;
      echo "   --sharedbde=yes|no [default no] (link Bde tools against shared libraries)" >&2;
      echo "   --sharedcompiler=yes|no [default no] (link Bigloo against shared libraries)" >&2;
      echo "" >&2;
      echo "JVM configuration:"  >&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 "   --native-default-backend" >&2;
      echo "   --jvm-default-backend" >&2;
      echo "" >&2;
      echo "Misc:"  >&2;
      echo "   --finalization=yes|no [default no]" >&2;
      echo "   --benchmark=yes|no [default no] (must use --arch too)" >&2;
      echo "   --strip=no (disable stripping during linking)" >&2;
      echo "   --debug[2] (configure for debugging)" >&2;
      echo "   --stack-check=no" >&2;
      echo "   --enable-thread-local-storage" >&2;
      echo "   --disable-thread-local-storage" >&2;
      echo "   --thread-local-storage=auto (auto detect)" >&2;
      echo "   --enable-gstreamer-thread" >&2;
      echo "   --disable-gstreamer-thread" >&2;
      echo "   --disable-gmp (see --no-gmp)" >&2;
      echo "   --customgmp=yes|no [default yes]" >&2;
      echo "   --gmpsrc=file [default \$GMP\")" >&2;
      echo "" >&2;
      echo "Configuration settings:"  >&2;
      echo "   --bigloo.h[=file]" >&2;
      echo "   --bigloo_gc.h[=file]" >&2;
      echo "   --bigloo_config.h[=file]" >&2;
      echo "   --bigloo_config.jvm[=file]" >&2;
      echo "   --Makefile.config=file" >&2;
      echo "   --$configurelog=file" >&2;
      echo "   --no-summary" >&2;
      echo "   --bootconfig" >&2;
      echo "   --bootdir=dir" >&2;
      echo "   --build-bindir=dir (directory which contains the binaries used to bootstrap)" >&2;
      echo "   --configureinfo=yes|no [default no]" >&2;
      echo "" >&2;
      echo "Environment variables:" >&2;
      echo "CC         C compiler command" >&2;
      echo "CFLAGS     C compiler flags" >&2;
      echo "LDFLAGS    linker flags, e.g. -L<lib dir> -static" >&2;
      echo "TAR        the tar archiving utility" >&2;
      echo "PATCH      the command that applies a diff file to an original" >&2;
      exit 3;
  esac
  shift
done

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

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

# 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 bigloo_config.sch file
if [ "$bigloo_config_sch " = " " ]; then
  bigloo_config_sch=lib/$release/bigloo_config.sch
fi

# The bigloo_bmacs.el file
if [ "$bigloo_config_el " = " " ]; then
  bigloo_config_el=bmacs/bmacs-config.el
fi

# Shell commands
if [ "$bgl_shell_rm " = " " ]; then
  bgl_shell_rm=$shell_rm;
fi

if [ "$bgl_shell_mv " = " " ]; then
  bgl_shell_mv=$shell_mv;
fi

# Cleaning
rm -f $configurelog
echo "# configure... " > $configurelog
echo -n "# " >> $configurelog
date >> $configurelog
echo "# $0 $logopt" >> $configurelog
echo >> $configurelog

# the mandir
if [ -d "$mandir/man1" ]; then
  mandir=$mandir/man1;
fi

# buildtmpdir
if [ "$buildtmp " = " " ]; then
  buildtmp=/tmp
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

echo "Checking local configuration..."

#*---------------------------------------------------------------------*/
#*    Weeding out bad configurations                                   */
#*---------------------------------------------------------------------*/
if [ "$action" != "bigloo_config_el" ]; then
  # checking the correctness of selected apis
  err=
  for p in $apis; do
    if [ ! -d api/$p ]; then
      err="$err $p";
    fi
  done

  if [ "$err " != " " ]; then
    echo "*** ERROR: unknown api(s):$err";
    exit 1
  fi
  
  # check apis cross dependencies
  srfi1_is_enabled=no
  packrat_is_enabled=no
  pkgcomp_is_enabled=no
  pkglib_is_enabled=no
  sqlite_is_enabled=no
  dbus_is_enabled=no
  fthread_is_enabled=no
  pthread_is_enabled=no
  srfi27_is_enabled=no
  crypto_is_enabled=no
  openpgp_is_enabled=no
  gstreamer_is_enabled=no
  
  for a in $apis; do
    case $a in
      srfi1) srfi1_is_enabled="yes";;
      srfi27) srfi27_is_enabled="yes";;
      packrat) packrat_is_enabled="yes";;
      sqlite) sqlite_is_enabled="yes";;
      pkgcomp) pkgcomp_is_enabled="yes";;
      pkglib) pkglib_is_enabled="yes";;
      dbus) dbus_is_enabled="yes";;
      pthread) pthread_is_enabled="yes";;
      fthread) fthread_is_enabled="yes";;
      crypto) crypto_is_enabled="yes";;
      openpgp) openpgp_is_enabled="yes";;
      gstreamer) gstreamer_is_enabled="yes";;
    esac
  done
  
  if [ $packrat_is_enabled = "yes" -a $srfi1_is_enabled = "no" ]; then
      echo "*** ERROR: packrat library requires srfi1."
      echo "Either disable packrat or enable srfi1."
      echo
      echo "Enabled apis: $apis"
      exit 1
  fi
  
  if [ $pkglib_is_enabled = "yes" -a $sqlite_is_enabled = "no" ]; then
      echo "*** ERROR: pkglib library requires sqlite."
      echo "Either disable pkglib or enable sqlite."
      echo
      echo "Enabled apis: $apis"
      exit 1
  fi
  
  if [ $fthread_is_enabled = "yes" -a $pthread_is_enabled = "no" ]; then
      echo "*** ERROR: fthread library requires pthread."
      echo "Either disable fthread or enable pthread."
      echo
      echo "Enabled apis: $apis"
      exit 1
  fi
  
  if [ $gstreamer_is_enabled = "yes" -a $pthread_is_enabled = "no" ]; then
      echo "*** ERROR: gstreamer library requires pthread."
      echo "Either disable gstreamer or enable pthread."
      echo
      echo "Enabled apis: $apis"
      exit 1
  fi
  
  if [ $openpgp_is_enabled = "yes" -a $crypto_is_enabled = "no" ]; then
      echo "*** ERROR: openpgp library requires crypto."
      echo "Either disable openpgp, or enable crypto."
      echo 
      echo "Enabled apis: $apis"
      exit 1
  fi
fi

# Check depends for bglpkg
if [ "$enable_bglpkg " = "yes " ]; then
    if [ $pkgcomp_is_enabled = "no" ]; then
	echo "*** WARNING: bglpkg binary requires pkgcomp library"
	echo "Disabling bglpkg."
	enable_bglpkg="no"
    fi
    if [ $pkglib_is_enabled = "no" ]; then
	echo "*** ERROR: bglpkg binary requires pkglib library"
	echo "Disabling bglpkg."
	enable_bglpkg="no"
    fi
    if [ $sqlite_is_enabled = "no" ]; then
	echo "*** ERROR: bglpkg binary requires sqlite library"
	echo "Disabling bglpkg."
	enable_bglpkg="no"
    fi
    if [ $web_is_enabled = "no" ]; then
	echo "*** ERROR: bglpkg binary requires web library"
	echo "Disabling bglpkg."
	enable_bglpkg="no"
    fi
fi

if [ "$enable_bglpkg " = "force " ]; then
    if [ $pkgcomp_is_enabled = "no" ]; then
	echo "*** ERROR: bglpkg binary requires pkgcomp library"
	echo "Either disable bglpkg, or enable pkgcomp."
	echo 
	echo "Enabled apis: $apis"
	exit 1
    fi
    if [ $pkglib_is_enabled = "no" ]; then
	echo "*** ERROR: bglpkg binary requires pkglib library"
	echo "Either disable bglpkg, or enable pkglib."
	echo 
	echo "Enabled apis: $apis"
	exit 1
    fi
    if [ $sqlite_is_enabled = "no" ]; then
	echo "*** ERROR: bglpkg binary requires sqlite library"
	echo "Either disable bglpkg, or enable sqlite."
	echo 
	echo "Enabled apis: $apis"
	exit 1
    fi
    if [ $web_is_enabled = "no" ]; then
	echo "*** ERROR: bglpkg binary requires web library"
	echo "Either disable bglpkg, or enable web."
	echo 
	echo "Enabled apis: $apis"
	exit 1
    fi
fi

# Here, bglpkg has all its dependencies, setting it just to "yes"
#  in order to have not to double test its value
if [ "$enable_bglpkg " = "force " ]; then
    enable_bglpkg="yes"
fi


#*---------------------------------------------------------------------*/
#*    User hostos specific configuration                               */
#*---------------------------------------------------------------------*/
echo "+ User specified host specific configuration ($hostos)..." >> $configurelog

dirsep="/"

case $hostos in
  android)
    if [ "$droidsdkroot " = " " ]; then
      echo "" >&2
      echo "*** ERROR: Bad Android configuration: DROID_SDK_ROOT missing." >&2
      echo "You must either use the --android-sdk-root=path option "
      echo "or define and export a DROID_SDK_ROOT shell variable." >&2
      echo "" >&2
      echo "The DROID_SDK_ROOT must refer to a directory that contains the" >&2
      echo "official Android SDK. It must at least contain the file \"platform-tools/adb\"." >&2
      exit 1
    fi
  
    # check if we can connect to a device (physical or emulated)
    adb=$droidsdkroot/platform-tools/adb
  
    echo -n "executing $adb shell ls -> " >&2
  
    $adb shell ls 2> /dev/null > /dev/null
  
    if [ $? = 0 ]; then
      echo "ok" >&2
    else
      echo "no" >&2
      echo "" >&2
      echo "*** ERROR: Cannot contact any connected Android device!" >&2
      echo "Connect a physical device to a USB port or spawn the emulator with" >&2
      echo "  $ $droidsdkroot/tools/android" >&2
      exit 1
    fi

    # Find a proper tmp on the phone
    if [ "$droidtmp " = " " ]; then
      for dir in /tmp /sdcard/tmp /mnt/sdcard/tmp /data/local/tmp; do
        if $autoconfdir/androidmkdir $adb $dir >&2; then
          droidtmp=$dir
          break
        fi
      done
    fi
  
    if [ "$droidtmp " = " " ]; then
      echo "" >&2
      echo "*** ERROR: Bad Android configuration: Cannot setup /tmp." >&2
      echo "You must specify a write/execute path with the --android-tmp=path option " >&2
     exit 1
    fi
  
    # Generate the adhoc shell wrapper
    hostsh=$pwd/arch/android/androidsh;
  
    cat $hostsh.in \
      | sed -e "s|@DROID_SDK_ROOT@|$droidsdkroot|" \
            -e "s|@DROID_TMP@|$droidtmp|" \
            -e "s|@DROID_ADB@|$adb|" \
      > $hostsh && chmod u+x $hostsh || exit 1

    # Use droid-gcc if no CC specified
    if [ "$cc " = " " ]; then
      cc=$pwd/arch/android/droid-gcc
  
      cat $cc.in \
        | sed -e "s|@DROID_SDK_ROOT@|$droidsdkroot|" \
              -e "s|@DROID_ROOT@|$droidroot|" \
              -e "s|@DROID_TARGET@|$droidtarget|" \
              -e "s|@DROID_TMP@|$droidtmp|" \
              -e "s|@DROID_ADB@|$adb|" \
        > $cc && chmod u+x $cc || exit 1
    fi
  
    # Add the correct cflags option
    cflags="$cflags -DBGL_ANDROID"
    # Use the multithreaded libbigloogc to close the other shared libraries
    sharedlibrarygcclosed='-l$(GCLIB)_fth-$(RELEASE)'
  
    ;;
esac
echo >> $configurelog

#*---------------------------------------------------------------------*/
#*    Configure bootstrap                                              */
#*---------------------------------------------------------------------*/
# COMMAND_MODE is required by bash to support echo -n (used by runtest.in)
COMMAND_MODE=legacy; export COMMAND_MODE

# First, generate an incomplete version of runtest that is used to grab 
# HOST info
$autoconfdir/mkruntest $autoconfdir/runtest \
   --autoconfdir=$autoconfdir \
   --log=$configurelog \
   --hostsh="$hostsh" \
   --hostos=$hostos \
   --user=""

# Grab the hostos info
if [ "$hostos " = " " ]; then
  hostos=`$autoconf os` || exit 1
fi

# Grab the hostcpu info
if [ "$hostcpu " = " " ]; then
  hostcpu=`$autoconf cpu` || exit 1
fi

# Grab the hostosversion info
if [ "$hostosversion " = " " ]; then
  hostosversion=`$autoconf osversion` || exit 1
fi

# Get the user info
if [ "$user " = " " ]; then
  user=`$autoconf user` || exit 1
fi

# Check the C compiler
# [flo/20090907] in theory we could try to use the hostos, etc to try to find a
#                cross compiler.
if [ "$cc " = " " ]; then
  for cc in "gcc cc"; do
     cc=`$autoconf cctest --cc=gcc` || exit 1
     if [ "$cc " != " " ]; then break; fi
  done

  if [ "$cc " = " " ]; then
    echo "Can't configure C compiler. Aborting (see configure.log)" >&2;
    exit 1;
  fi
else
  ncc=`$autoconf cctest --cc="$cc"` || exit 1
  if [ "$ncc " != "$cc " ]; then
    echo "C compiler \"$cc\" broken. Aborting (see configure.log)" >&2;
    exit 1;
  fi
fi

# Second, replace runtest by one that contains the host information.
$autoconfdir/mkruntest $autoconfdir/runtest \
   --autoconfdir=$autoconfdir \
   --log=$configurelog \
   --hostsh="$hostsh" \
   --hostos="$hostos" \
   --hostosversion="$hostosversion" \
   --hostcpu="$hostcpu" \
   --buildsh="$buildsh" \
   --tmp="$buildtmp" \
   --user="$user" \
   --cc="$cc" \
   --cflags="$cflags"

#*---------------------------------------------------------------------*/
#*    Cross Compilation                                                */
#*---------------------------------------------------------------------*/
#
# Grab the buildos info
if [ "$buildos " = " " ]; then
  buildos=`$autoconfdir/os --sh=""` || exit 1
fi

# Grab the buildcpu info
if [ "$buildcpu " = " " ]; then
  buildcpu=`$autoconfdir/cpu --sh=""` || exit 1
fi

# Grab the buildosversion info
if [ "$buildosversion " = " " ]; then
  buildosversion=`$autoconfdir/osversion --sh=""` || exit 1
fi

#*---------------------------------------------------------------------*/
#*    Autoconfigure hostos specific configuration                      */
#*---------------------------------------------------------------------*/
echo "+ Post host specific configuration ($hostos)..." >> $configurelog

dirsep="/"

case $hostos in
  cygwin)
    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'`
      if [ ! -d $cygwindospath ]; then
        echo "*** WARNING:Can't find cygwindospath \"$cygwindospath\""
      fi
      cygwindospath=`echo "$cygwindospath" | sed -e 's/\\\\/\\\\\\\\/g'`

      zipdir=`echo $zipdir | sed -e 's/\/cygdrive\/\([a-z]\)\//\1:\//'`
      zipdir=`echo $zipdir | sed -e "s/^\//$cygwindospath\\\\\\\\\\\\\\\\/"`
      zipdir=`echo $zipdir | sed -e 's/\//\\\\\\\\/g'`
      zipdir=`echo $zipdir | sed -e 's/\([^\\\\]\)\\\\\([^\\\\]\)/\1\\\\\\\\\2/g'`
      syszipdir=$zipdir
      syszipdirstr=`echo $syszipdir | sed -e 's|\\\\|\\\\\\\\|g'`

      dlldir=`echo $dlldir | sed -e 's/\/cygdrive\/\([a-z]\)\//\1:\//'`
      dlldir=`echo $dlldir | sed -e "s/^\//$cygwindospath\\\\\\\\\\\\\\\\/"`
      dlldir=`echo $dlldir | sed -e 's/\//\\\\\\\\/g'`
      dlldir=`echo $dlldir | sed -e 's/\([^\\\\]\)\\\\\([^\\\\]\)/\1\\\\\\\\\2/g'`
      sysdlldir=$dlldir
      sysdlldirstr=`echo $sysdlldir | sed -e 's|\\\\|\\\\\\\\|g'`
    fi

    jvmrecettebootpath="-classpath \".;../lib/$release/bigloo_s.zip;objs_jvm\""
    jvmapibootpath="\".;../../../../../lib/$release/bigloo_s.zip\""

    ldopt="no-share"

    if [ "$cygwindosjvm" = "yes" ]; then
      jshell="msdos"
    fi
    ;;

  mingw)
    exe=".exe"
    hostos="mingw"
    ld="gcc"
    ldlibs=""
    ldcomplibs=""
    ldflags="$ldflags -Wl,--enable-runtime-pseudo-reloc"
    ldopt=-shared
    havedlopen=1
    dlopen=""
    threadsupport=no;
    #cflags="$cflags -mthreads -D_MINGW_VER"
    cflags="$cflags -D_MINGW_VER"
    sharedsuffix="dll"
    sharedlibraryclosed=yes
    extralibs="$extralibs -Wl,--stack,8000000"
    extragclibs=""
    jshell="msdos"
    syszipdir=$zipdir
    syszipdirstr=$zipdir
    ;;

  darwin)
    sharedlibraryclosed=yes;
    if [ "$macosx " = "auto " ]; then
      macosx=`$autoconf macosx` || exit 1
    fi

    if [ "$macosx" = "yes" ]; then
      echo "* MacOS X tuning enabled"; >&2;
      if [ "$mode " != "benchmark " -a "$pthreadlibs " != "no " ]; then
        if [ "$threadsupport " = "no " ]; then
          threadsupport=no;
          pthreadlibs=no;
          ldcomplibs="\$(GCCLOSELIB) -lc";
        else
          customgclib=bigloogc_fth;
          extralibs="$extralibs $pthreadlibs";
          ldcomplibs="\$(GCCLOSELIB) $pthreadlibs -lc";
        fi
      fi
      if [ `dirname $bindir` != `dirname $libdir` ]; then
        echo "*** ERROR: on MacOS X, bindir and libdir must have a";
        echo "common parent directory. Please re-configure accordingly";
        exit 1;
      fi

      ldinstallname="-install_name";
      ldinstallnamedirroot="Frameworks";
      sharedsuffix="dylib";
      ldlibs="$ldlibs \$(GCCLOSELIB) -lc";
      sharedcompiler=yes;
      sharedbde=yes;
      ldflags="$ldflags -dynamiclib -single_module -Wl,-read_only_relocs,suppress";
      tuning="MacOS X"
    fi

    if [ "$tuning " = "MacOS X " ]; then
      if [ ! -d lib/bigloo ]; then
        (cd lib && ln -s . bigloo) || exit 3
        ln -s lib Frameworks || exit 3
      fi
    fi

    syszipdir=$zipdir
    syszipdirstr=$zipdir
    ;;

  win32)
    dirsep="\\"
    bindir=`echo $bindir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
    libdir=`echo $libdir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
    fildir=`echo $fildir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
    zipdir=`echo $zipdir | sed -e 's/\//\\\\\\\\/g' | sed -e 's/[.]//g'`
    dlldir=`echo $dlldir | 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'`
    ;;

  android)
    # Add the adhoc configure option for the collector
    gcconfigurethreadsopt="--enable-threads=posix";
  
    # Requires closed libraries
    sharedlibraryclosed=yes
    ;;

  *)
    syszipdir=$zipdir
    syszipdirstr=$zipdir
    sysdlldir=$dlldir
    sysdlldirstr=$dlldir
    ;;
esac
echo >> $configurelog

#*---------------------------------------------------------------------*/
#*    C tool chain                                                     */
#*---------------------------------------------------------------------*/
if [ "$hostos " != "$buildos " -o \
     "$hostcpu " != "$buildcpu " -o \
     "$hostosversion " != "$buildosversion " ]; then
  echo "Cross compilation detected..."

  # try to detect cross-tools
  tmp=`echo $cc | sed 's/-gcc$/-ar/'`;
  if [ "$ar " = " " -a "$tmp " != "$cc " -a -x "$tmp" ]; then
      ar="$tmp";
      echo "  Using ar=$ar";
  fi
  tmp=`echo $cc | sed 's/-gcc$/-as/'`;
  if [ "$as " = " " -a "$tmp " != "$cc " -a -x "$tmp" ]; then
      as="$tmp";
      echo "  Using as=$as";
  fi
  tmp=`echo $cc | sed 's/-gcc$/-strip/'`;
  if [ "$strip " = " " -a "$tmp " != "$cc " -a -x "$tmp" ]; then
      strip="$tmp";
      echo "  Using strip=$strip";
  fi
  tmp=`echo $cc | sed 's/-gcc$/-ranlib/'`;
  if [ "$ranlib " = " " -a "$tmp " != "$cc " -a -x "$tmp" ]; then
      ranlib="$tmp";
      echo "  Using ranlib=$ranlib";
  fi
fi

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

if [ $action = "all" -o $action = "bigloo_config_el" ]; then
  # ld
  if [ "$ld " = " " ]; then ld=$cc; fi

  # as
  if [ ! $as ]; then as="as"; fi
  as=`$autoconf ascpp --as="$as" --name=$name` || exit 1

  if [ "$as " = " " -o ! -f $name.o ]; then
    echo "Can't find assembly that invokes cpp. Set the as variable" >&2;
    exit 1;
  fi

  # ar
  if [ ! $ar ]; then ar="ar"; fi
  arflags=`$autoconf arflags --ar=$ar --name=$name` || exit 1

  echo " ar arflags -> $ar $arflags" >> $configurelog

  rm -f $name.s $name.o $name.a

  # ranlib
  if [ ! $ranlib ]; then ranlib="ranlib"; fi
  rl=`$autoconf ranlib --ranlib="$ranlib"` || exit 1

  if [ "$rl" = "yes " ]; then
    ranlib=true;
  fi

  if [ "$strip " = " " ]; then strip="strip"; fi
  strip=`$autoconf strip --strip=$strip` || exit 1
fi

#*---------------------------------------------------------------------*/
#*    Executable names                                                 */
#*---------------------------------------------------------------------*/
echo "+ checking executable names..." >> $configurelog
if [ "$aout " = " " ]; then
  case $hostos in
    cygwin|mingw)
      aout=a.exe;;
    *)
      aout=a.out;;
  esac
fi

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

echo "  -> aout=$aout, abat=$abat" >> $configurelog
echo >> $configurelog

#*---------------------------------------------------------------------*/
#*    Multi-threading                                                  */
#*---------------------------------------------------------------------*/
echo "* threadsupport=$threadsupport" >> $configurelog

if [ "$threadsupport " = "no " ]; then
   pthreadlibs=no;
   gcthread=no;
   pthreadhastls=0
elif [ $hostos = "mingw" ]; then
  # MinGW pre-test
  if [ "$threadsupport " = " " ]; then
     pthreadlibs=no;
     gcthread=no;
     pthreadhastls=0
  else
     echo "*** ERROR: MinGW does not support threads."
     echo" Disable multithreading and re-configure."
     exit 1
  fi
else
  # Does the system support threads
  if [ "$gcthread " = " "  ]; then
     gcthread=`$autoconf thread --cflags="$cgcfinalflags"` || exit 1;
  fi

  # find out the C library for posix threads
  if [ "$pthreadlibs " = " " ]; then
    pthreadlibs=`$autoconf pthread` || exit 1
  fi

  # pthread_mutex_timedlock
  if [ "$pthreadlibs" != "no" ]; then
    pthreadtimedlock=`$autoconf pthreadlock --lib="$pthreadlibs"` || exit 1;
  fi

  # pthread_timedjoin_np
  if [ "$pthreadlibs" != "no" ]; then
    pthreadtimedjoin=`$autoconf pthreadtimedjoin --lib="$pthreadlibs"` || exit 1;
  fi

  # pthread local storage
  if [ "$pthreadlibs" != "no" -a "$pthreadlocalstorage " = " " ]; then
    pthreadlocalstorage=`$autoconf pthreadlocalstorage --lib="$pthreadlibs"` || exit 1;
  fi

  # thread local storage
  if [ "$pthreadlocalstorage" = "yes" -a "$threadsupport " != "no " ]; then
    pthreaddecl=__thread
    pthreadhastls=1
    gcthread="$gcthread -DUSE_COMPILER_TLS"
  else
    pthreaddecl=
    pthreadhastls=0
  fi
fi

#*---------------------------------------------------------------------*/
#*    Java configuration                                               */
#*---------------------------------------------------------------------*/
echo "+ Java specific configuration ($hostos)..." >> $configurelog
jvmrecettebootpath="-classpath \".:../lib/$release/bigloo_s.zip:objs_jvm\""
jvmapibootpath="\".:../../../../../lib/$release/bigloo_s.zip\""
echo >> $configurelog

#*---------------------------------------------------------------------*/
#*    GC configuration                                                 */
#*---------------------------------------------------------------------*/
if [ "$action" != "bigloo_config_el" ]; then
  echo "+ GC configuration ($customgc)..." >> $configurelog
  
  cgcflags=`$autoconf gcflags --cflags="$cflags"` || exit 1
  
  # We check the standard GC if we have to use one
  if [ "$customgc " = "no " ]; then
    isgccustom=0
    gclib=
    if [ "$gclibdir " = " " ]; then
      gclibdir=/usr/lib;
    fi
    if [ "$gcincdir " = " " ]; then
      gcincdir=/usr/include/gc
    fi
    gclib=`$autoconf gcstd --cflags="$coflags $lflags" --gclib="$stdgclib" --gcincdir="$gcincdir" --gclibdir="$gclibdir" --dlopen=$dlopen` || exit 1
    if [ "$gclib " = " " ]; then
       echo "*** ERROR:configure:Standard GC. Aborting";
       echo "You are trying to configure Bigloo so that it uses an existing"
       echo "GC library. The configuration script is enable to make this"
       echo "library working properly."
       echo "Try to configure Bigloo with \"--customgc=yes\"."
       exit 1;
    fi
  else
    isgccustom=1
    gclib=$customgclib;
  
    gcincdir=$pwd/gc/$gccustom/include
  
    # detect if we are using maemo for an ARM emulation
    maemo=`$autoconf maemo.arm --cflags="$coflags"` || exit 1
    if [ "$maemo " = "yes " ]; then
      # This is required for compiling under QEMU (use to be the -DQEMU flag)
      cgcflags="$cgcflags -DNO_PROC_STAT"
      cflags="$cflags -DBGL_FORBID_GC_COLLECT"
    fi
  
    # android
    if [ $hostos = "android" ]; then
      cgcflags="-DPLATFORM_ANDROID"
    fi

    # configure directories
    gcconfiguredir="--prefix=$pwd/gc/preinst"
    # install the gc source code if needed
  
    if [ $actiongc = "install" ]; then
      if [ ! -d gc/$gccustom ]; then
        echo "+ Installing custom GC ($gccustom) source code."
  
        (cd gc \
         && GC="$gccustom"; export GC \
         && HOSTOS="$hostos"; export HOSTOS \
         && . ./install-$gccustom) || exit 1
      fi
  
      if [ -f gc/configure-$gccustom ]; then
        autoopts=`$autoconf gcconfigureopt --gc-dir="$pwd/gc/$gccustom"`
        gcconfigureopt="$autoopts $gcconfigureopt"
        gcconfigurethreadsopt="$gcconfigurethreadsopt"
        echo "+ Configuring custom GC..." && \
        (. ./gc/configure-$gccustom $configuregcextraopt) || exit 1
      fi
    fi
  fi
  
  # Check the version of the collector
  if [ "$gcversion " = " " ]; then
    gcversion=`$autoconf gcversion --gcincdir="$gcincdir" --cflags="$lflags"` || exit 1
  
    if [ "$gcversion" -le "000" ]; then
      doblocking=`$autoconf gchavedoblocking --gclib="$stdgclib" --gcincdir="$gcincdir" --gclibdir="$gclibdir" --cflags="$lflags" --tmp=$buildtmp` || exit 1
  
      if [ "$doblocking " = "yes " ]; then
        gchavedoblocking=1
        gcversion="700"
      else
        startblocking=`$autoconf gchavestartblocking --gclib="$stdgclib" --gcincdir="$gcincdir" --gclibdir="$gclibdir" --cflags="$lflags"` || exit 1
        if [ "$startblocking " = "yes " ]; then
          gchaveblocking=1
        else
          gcversion="680"
        fi
      fi
    else
      if [ "$hostos " != "win32" -a $hostos != "cygwin" ]; then
        if [ "$gcversion" -lt "700" ]; then
          gchaveblocking=1
          gcversion="680"
        fi
        if [ "$gcversion" -ge "700" ]; then
          gchavedoblocking=1
        fi
      fi
    fi
  fi
  
  # correct gchavedoblocking for win32
  if [ $hostos = "cygwin" ]; then
    gchaveblocking=0
  elif [ $hostos = "mingw" ]; then
     gchaveblocking=0
     gchavedoblocking=0
  fi
  echo >> $configurelog
fi

#*---------------------------------------------------------------------*/
#*    GMP configuration                                                */
#*---------------------------------------------------------------------*/
if [ "$customgmp " = "yes " ]; then
  echo ""
  echo "Preparing and configuring custom gmp ($gmpsrc)..."
  echo "+ gmp configuration ($gmpsrc)..." >> $configurelog

  gmpversion=`basename $gmpsrc .tar.gz`
  gmpversion=`basename $gmpversion .tgz`

  (cd gmp && GMP=$gmpsrc; export GC && . ./install-gmp) || exit 1
  (cd gmp; . ./configure-gmp) || exit 1
fi

#*---------------------------------------------------------------------*/
#*    Benchmark mode                                                   */
#*---------------------------------------------------------------------*/
if [ "$mode" = "benchmark" ]; then
  echo "* setting benchmark mode ($hardtune)..." >> $configurelog

  ccprefix="`echo $cc | sed 's/[0-9]*//g'`"  # remove version numbers
  case $hardtune in
    i586|i686)
      if [ "$ccprefix" = "gcc" ]; then
        coflags="$coflags -march=$hardtune -mcpu=$hardtune -mpreferred-stack-boundary=2 -fomit-frame-pointer -fschedule-insns2 -ffast-math";
      fi
      gcspecial=-DDONT_ADD_BYTE_AT_END;;

    pentium3|pentium4)
      if [ "$ccprefix" = "gcc" ]; then
        coflags="$coflags -march=$hardtune -mpreferred-stack-boundary=2 -fomit-frame-pointer -fschedule-insns2 -ffast-math";
      fi
      gcspecial="-DUSE_I686_PREFETCH -DDONT_ADD_BYTE_AT_END";;

    athlon|athlon-mp|athlon-tbird|athlon-xp)
      if [ "$ccprefix" = "gcc" ]; then
        coflags="$coflags -march=$hardtune -mpreferred-stack-boundary=2 -fomit-frame-pointer -fschedule-insns2 -ffast-math";
      fi
      gcspecial="-DUSE_3DNOW_PREFETCH -DDONT_ADD_BYTE_AT_END";;

    k6-2|k6-3)
      if [ "$ccprefix" = "gcc" ]; then
        coflags="$coflags -march=$hardtune -mpreferred-stack-boundary=2 -fomit-frame-pointer -fschedule-insns2 -ffast-math";
      fi
      gcspecial="-DUSE_3DNOW_PREFETCH -DDONT_ADD_BYTE_AT_END";;
  esac
fi

#*---------------------------------------------------------------------*/
#*    Testing stack size                                               */
#*---------------------------------------------------------------------*/
if [ $hostos != "cygwin" -a "$hostos" != "mingw" ]; then
  if [ ! "$stacksizerequired" = "0" ]; then
    s=`$autoconf stacksize --stacksize=$stacksizerequired` || exit 1
    if [ "$s " != "0 " ]; then
      echo "*** ERROR:configure:the execution stack is too small.";
      echo ""
      echo "Bigloo REQUIRES a larger stack (it needs a stack of about $stacksizerequired MB to compile).";
      echo "In general, it is possible to adjust the stack size by the means of";
      echo "a shell command.";
      echo "On most Unix systems, it is frequently called \"ulimit\" or \"unlimit\".";
      echo "For instance, with Bash you should try \"ulimit -s 4096\"."
      echo "With Zsh, try \"unlimit\"."
      echo ""
      echo "Another solution, if you know what you are doing,";
      echo "is to use the configure option \"--stack-check=no\". This will";
      echo "simply, disable stack size checking.";
      exit 1;
    fi
  fi
fi

#*---------------------------------------------------------------------*/
#*    OpenSSL                                                          */
#*---------------------------------------------------------------------*/
# find out the C library for openssl
if [ "$openssllibs " = " " ]; then
   openssllibs=`$autoconf openssl` || exit 1;
   if [ "$openssllibs " = "no " ]; then
     openssllibs=`$autoconf openssl --lib="-lcrypto -lssl"` || exit 1;
   fi
else
   openssllibs=`$autoconf openssl --lib="$openssllibs"` || exit 1;
fi

if [ "$openssllibs" != "no" ]; then
  openssldtls=`$autoconf openssl-dtls --lib="$openssllibs"` || exit 1;
  opensslv2=`$autoconf openssl-v2 --lib="$openssllibs"` || exit 1;
  opensslv23=`$autoconf openssl-v23 --lib="$openssllibs"` || exit 1;
fi

#*---------------------------------------------------------------------*/
#*    sqlite                                                           */
#*---------------------------------------------------------------------*/
# find out the C library for sqlite
if [ "$sqlite_is_enabled " = "yes " ]; then
  if [ "$sqlitelibs " = " " ]; then
    sqlitelibs=`$autoconf sqlite --cflags="$cflags"` || exit 1;
  fi
fi

#*---------------------------------------------------------------------*/
#*    dbus                                                             */
#*---------------------------------------------------------------------*/
# find out the C library for dbus
if [ "$dubs_is_enabled " = "yes " ]; then
  if [ "$dbuslibs " = " " ]; then
     dbuslibs=`$autoconf dbus --cflags="$cflags"` || exit 1;
  fi

  if [ "$dbuslibs " != " " ]; then
    dbusld=`echo $dbuslibs | awk -F "@" '{ print $1 }'`
    dbusincl=`echo $dbuslibs | awk -F "@" '{ print $2 }'`
  else
    dbusld=""
    dbusincl=""
  fi
else
  dbusld=""
fi

#*---------------------------------------------------------------------*/
#*    gstreamer                                                        */
#*---------------------------------------------------------------------*/
# find out the C library for gstreamer
pkg="gstreamer-@VERSION@ gstreamer-base-@VERSION@ gstreamer-plugins-base-@VERSION@"

if [ "$gstreamer " = " " ]; then
   gstreamer=`$autoconf gstreamer --cflags="$cflags" --pkg="$pkg"` || exit 1;
fi

if [ "$gstreamer " != " " ]; then
  pkgv=`echo $pkg | sed "s/@VERSION@/$gstreamer/g"`
  gstreamercflags="`$autoconf bgl-pkg-config --cflags $pkgv`"

  if [ "gstreamercflags " = " " ]; then
    echo "*** ERROR: Cannot configure gstreamer, cflags are empty";
    echo "Running the command \"pkg-config --cflags gstreamer-$gstreamer gstreamer-plugins-base-$gstreamer\" might help understanding what's wrong"
    exit 1;
  fi

  if [ "$gstreameraudio " = " " ]; then
    pkgaudio="$pkgv gstreamer-audio-$gstreamer"
    audioflags="`$autoconf bgl-pkg-config --cflags --libs $pkgaudio`"

    gstreameraudio=`$autoconf gstreameraudio --cflags="$audioflags"` || exit 1;
    if [ "$gstreameraudio " != " " ]; then
      gstaudio="#t"
      gsthaveaudio="1"
      gstreamerlibs="`$autoconf bgl-pkg-config --libs $pkgaudio`"
    else
      gstaudio="#f"
      gsthaveaudio="0"
      gstreamerlibs=`$autoconf bgl-pkg-config --libs $pkgv`
    fi
  fi
fi

#*---------------------------------------------------------------------*/
#*    alsa                                                             */
#*---------------------------------------------------------------------*/
# find out the C library for alsa
if [ "$alsa " = " " ]; then
   alsa=`$autoconf alsa --cflags="$cflags"` || exit 1;
fi

if [ "$alsa " != "no " ]; then
  alsacflags=`$autoconf bgl-pkg-config --cflags alsa`
  alsalibs="`$autoconf bgl-pkg-config --libs alsa`"

  if [ "alsacflags " = " " -o "alsalibs " = " " ]; then
    echo "*** ERROR: Cannot configure alsa, cflags are empty";
    echo "Running the command \"pkg-config --cflags alsa\" might help understanding what's wrong"
    exit 1;
  fi
fi

#*---------------------------------------------------------------------*/
#*    mpg123                                                           */
#*---------------------------------------------------------------------*/
# find out the C library for mpg123
if [ "$mpg123 " = " " ]; then
   mpg123libs=`$autoconf mpg123 --cflags="$cflags $mpg123cflags"` || exit 1;

   if [ "$mpg123libs " = "no " -a "$mpg123cflags " = " " ]; then
     mpg123cflags="-D_FILE_OFFSET_BITS=64"
     mpg123libs=`$autoconf mpg123 --cflags="$cflags $mpg123cflags"` || exit 1;
   fi
fi

#*---------------------------------------------------------------------*/
#*    flac                                                             */
#*---------------------------------------------------------------------*/
# find out the C library for flac
if [ "$flac " = " " ]; then
   flaclibs=`$autoconf flac --cflags="$cflags"` || exit 1;
fi

#*---------------------------------------------------------------------*/
#*    Multimedia                                                       */
#*---------------------------------------------------------------------*/
havemixer=`$autoconf mixer` || exit 1

#*---------------------------------------------------------------------*/
#*    Regexp                                                           */
#*---------------------------------------------------------------------*/
if [ "$regexp " = " " ]; then
  # find out the C library for pcre
  pcrelibs=`$autoconf pcre --cflags="$cflags"` || exit 1;

  if [ "$pcrelibs " != "no " ]; then
    featureflags="-srfi enable-pcre $featureflags";
    extralibs="-lpcre $extralibs"
    regexp=pcre
  else
    regexp=pregexp
  fi
fi

echo ";; generated file, don't edit" > runtime/Unsafe/regexp.scm
cat runtime/Unsafe/$regexp.scm >>  runtime/Unsafe/regexp.scm

if [ -f runtime/objs/obj_u/Unsafe/$regexp.c ]; then
  cp runtime/objs/obj_u/Unsafe/$regexp.c runtime/objs/obj_u/Unsafe/regexp.c;
fi

featureflags="-srfi enable-$regexp"

#*---------------------------------------------------------------------*/
#*    avahi                                                            */
#*---------------------------------------------------------------------*/
# find out the C library for avahi
if [ "$avahi " = " " ]; then
   avahilibs=`$autoconf bgl-pkg-config --libs avahi-client`
   avahicflags=`$autoconf bgl-pkg-config --cflags avahi-client`

   avahi=`$autoconf avahi --cflags="$avahicflags" --libs="$avahilibs"` || exit 1;
fi

#*---------------------------------------------------------------------*/
#*    phidget                                                          */
#*---------------------------------------------------------------------*/
# find out the C library for phidget
if [ "$phidget " = " " ]; then
   phidgetlibs=`$autoconf phidget --cflags=$phidgetcflags --version=$phidgetversion`

   if [ "$phidgetlibs " = " " ]; then
      phidget=no;
   else
      if [ "$phidgetlibdir " = " " ]; then
        phidgetlibdir=`$autoconf phidgetlibdir --version=$phidgetversion`
      fi
   fi
fi

#*---------------------------------------------------------------------*/
#*    bigloo_config.h / configure.java / configure.cs / ...            */
#*    -------------------------------------------------------------    */
#*    This part of the configure script produces the files             */
#*    runtime/Include/bigloo_config.h, runtime/Jlib/configure.java and */
#*    runtime/CSlib/configure.cs. These files contain all the machine- */
#*    dependant information used by Bigloo.                            */
#*---------------------------------------------------------------------*/
if [ $action = "all" -o $action = "bigloo_config" ]; then

  # Tell what we are doing
  echo ""
  echo "Configuring $bigloo_config_h, $bigloo_config_jvm, $bigloo_config_sch:"

  # The pointer alignment
  alignment=`$autoconf alignment` || exit 1

  # The -O C compiler options
  coflags=`$autoconf ccoptim --cflags="$coflags"` || exit 1

  # The -s C linker options
  if [ "$cstrip" != "no" ]; then
    csflags=`$autoconf ccstrip --cflags="$cstrip"` || exit 1;
  else
    csflags="";
  fi

  # errnoh
  errnoh=`$autoconf checkinclude '#include <errno.h>'` || exit 1

  # The -p C compiler options
  cpflags=`$autoconf ccprof` || exit 1

  # C compiler nan and infinity
  ccdiv0=`$autoconf ccdiv0` || exit 1

  # oscharset
  if [ "$oscharset " = " " ]; then
    oscharset=`$autoconf oscharset` || exit 1
  fi

  # The stack direction
  stackgrows=`$autoconf stackdown` || exit 1

  # stdint
  stdint=`$autoconf stdint` || exit 1
  if [ "$stdint" = "1" ]; then
    stdlibint=`$autoconf stdlibint` || exit 1
  fi

  # unistdint
  if [ "$unistdint " = " " ]; then
    unistdint=`$autoconf unistdint` || exit 1
  fi

  # getuid
  if [ "$getuid " = " " ]; then
    getuid=`$autoconf getuid` || exit 1
  fi

  # gecos
  if [ "$gecos " = " " ]; then
    gecos=`$autoconf gecos` || exit 1
  fi

  # getprotoent
  if [ "$getprotoent " = " " ]; then
    getprotoent=`$autoconf getprotoent` || exit 1
  fi

  # setjmp/longjmp
  if [ "$HOSTOS " = "cygwin " ]; then
    setjmpprefix="_";
  else
    setjmpprefix=`$autoconf setjmp` || exit 1
  fi

  setjmp="$setjmpprefix"setjmp
  longjmp="$setjmpprefix"longjmp

  if [ "$setjmpprefix" = "sig" ]; then
    # MS 10 dec 2010: used to be: setjmp="sigsetjmp(__jb,1)";
    # I don't think signal have to be saved/restore thus we switched
    # to not restoring them. Switching from 0 to 1 significantly improve
    # the performance of BIND-EXIT (and thus UNWIND-PROTECT). This 
    # dramatically impacts the performance of the new evaluator (BPS) on
    # benchmarks such as peval.scm
    setjmp="sigsetjmp(__jb,SIGSETJMP_SAVESIGS)";
    jmpbuf=sigjmp_buf
  else
    setjmp="$setjmp(__jb)";
    jmpbuf=jmp_buf
  fi

  # Does the system have bcopy?
  havebcopy=`$autoconf bcopy` || exit 1

  # The number of window register
  window=`$autoconf winreg` || exit 1

  # Does the system have sigpipe?
  sigpipe=`$autoconf sigpipe` || exit 1

  # Does the system have sigsetmask?
  sigsetmask=`$autoconf sigsetmask` || exit 1

  # Does the system have sigprocmask?
  sigprocmask=`$autoconf sigprocmask` || exit 1

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

  # Does the system have alloca?
  alloca=`$autoconf alloca` || exit 1
  if [ $alloca = "1" ]; then
    allocah=`$autoconf allocah` || exit 1
  fi

  # native mach_dep target
  nativemachdep=`$autoconf machdep` || exit 1

  # Does the system have mmap?
  mmap=`$autoconf mmap` || exit 1

  # Does the system have getcwd?
  getcwd=`$autoconf getcwd` || exit 1

  # Does the system have getwd?
  getwd=`$autoconf getwd` || exit 1

  # Is gmp available?
  if [ "$customgmp" != "no" ]; then
    havegmp=1;
    featureflags="-srfi enable-gmp $featureflags";
    extralibs="-lbigloogmp-$release $extralibs"
  elif [ "$gmpversion " = " " ]; then
    gmpversion=`$autoconf gmp` || exit 1

    if [ $gmpversion = "no" ]; then
      havegmp=0;
      if [ $gmpforce = "yes" ]; then
	echo "*** ERROR:configure:--enable-gmp. Cannot find GMP library."
	echo "Aborting";
 	exit 1;
      fi
      if [ "$srfi27force " = "yes " ]; then
	echo "*** ERROR:configure: Cannot find GMP library required by SRFI27."
        echo "Please install GMP first or re-configure with \"--disable-srfi27\"."
	echo "Aborting";
	exit 1;
      else
        echo "*** WARNING:configure: Gannot find GMP library required by SRFI27."
        echo "Disabling SRFI27."
        napis=;
        for a in $apis; do
           if [ $a != "srfi27" ]; then
             if [ "$napis " = " " ]; then
               napis="$a";
             else
               napis="$napis $a";
             fi
           fi
        done
        apis=$napis;
      fi
    else
      havegmp=1;
      featureflags="-srfi enable-gmp $featureflags";
      extralibs="-lgmp $extralibs"
    fi
  else
    havegmp=0;
  fi

  # Where to find the socket api
  socketlibs=`$autoconf socket --lib="$socketlibs"` || exit 1
  socklen=`$autoconf socklen --lib="$socketlibs"` || exit 1

  if [ "$socketlibs " != " " ]; then
     extralibs="$socketlibs $extralibs"
  fi

  tcpnodelay=`$autoconf setsockopt --lib="$socketlibs" --opt=TCP_NODELAY` || exit 1
  tcpcork=`$autoconf setsockopt --lib="$socketlibs" --opt=TCP_CORK` || exit 1
  tcpquickack=`$autoconf setsockopt --lib="$socketlibs" --opt=TCP_QUICKACK` || exit 1

  inet_aton=`$autoconf inet_aton --lib="$socketlibs"` || exit 1
  inet_pton=`$autoconf inet_pton --lib="$socketlibs"` || exit 1

  unix_socket=`$autoconf unixsocket --lib="$socketlibs"` || exit 1
  getaddrinfo=`$autoconf getaddrinfo --lib="$socketlibs"` || exit 1

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

  enforcedcnstalign=`$autoconf enforcedcnstalign` || exit 1
  if [ "$cnstalign" = "0" -a "$enforcedcnstalign" = "0" ]; then
    echo "*** ERROR:configure:illegal alignment."
    echo "It is then impossible install Bigloo on this architecture, sorry."
    exit 1
  fi

  # Endianness
  endian=`$autoconf bigendian` || exit 1

  # Does this system implement pipe?
  pipe=`$autoconf pipe` || exit 1

  # Does this system implement symlink?
  symlink=`$autoconf symlink` || exit 1

  # Does this compiler implement labs?
  # llabs=`$autoconfdir/labs --user=$user --tmp=$buildtmp --cc="$cc"`
  # SE: fix, 27 oct 2006
  labs=`$autoconf labs` || exit 1
  if [ "$labs " != " " ]; then
    have_labs=1
  else
    have_labs=0
    labs=abs
  fi

  # Does this compiler implement longlong?
  longlong=`$autoconf longlong --longlong="$longlong"` || exit 1

  echo "#undef BGL_LONGLONG_T" >> $bigloo_config_h
  if [ "$longlong " = " " ]; then
    echo "   long long: no"
    havelonglong=0

    have_strtoull=0
    longlong=long
    have_llabs=0
    llabs=abs
    have_strtoll=0
    strtoll=strtol
    strtoull=strtoull
  else
    havelonglong=1

    llabs=`$autoconf llabs --longlong="$longlong"` || exit 1
    strtoll=`$autoconf strtoll --longlong="$longlong"` || exit 1
    strtoull=`$autoconf strtoull --longlong="$longlong"` || exit 1

    if [ "$llabs " != " " ]; then
      have_llabs=1
    else
      have_llabs=0
    fi
    if [ "$strtoll " != " " ]; then
      have_strtoll=1
    else
      have_strtoll=0
      strtoll="bgl_strtoll"
    fi
    if [ "$strtoull " != " " ]; then
      have_strtoull=1
    else
      have_strtoull=0
      strtoull="bgl_strtoull"
    fi
  fi

  long_limbs=`$autoconf limbs --type="long" --cflags="-I$bootdir/lib/$release -L$bootdir/lib/$release"` || exit 1
  longlong_limbs=`$autoconf limbs --type="$longlong" --cflags="-I$bootdir/lib/$release -L$bootdir/lib/$release"` || exit 1

  long_sign_bit=`$autoconf signbit --type=long --alignment="$alignment"` || exit 1
  elong_sign_bit=`$autoconf signbit --type=long --alignment=0` || exit 1
  llong_sign_bit=`$autoconf signbit --type="$longlong" --alignment=0` || exit 1

  # Is sigchld available for us
  sigchld=`$autoconf sigchld` || exit 1

  # Is sigaction available
  sigaction=`$autoconf sigaction` || exit 1

  # Is setenv available for us
  setenv=`$autoconf setenv` || exit 1

  # Is select available
  select=`$autoconf select` || exit 1

  # Is fcntl available
  fcntl=`$autoconf fcntl` || exit 1

  # Is termio available
  termio=`$autoconf termio` || exit 1

  # Is termio available
  termios=`$autoconf termios` || exit 1

  # Does the system support posix-file-ops
  posixfileops=`$autoconf posixfileops` || exit 1

  # Does the system support sendfile
  sendfile=`$autoconf sendfile` || exit 1
  if [ "$sendfile" != "BGL_SENDFILE_NO" ]; then
    sendfile_rif=1;
    sendfile_ros=1;
  else
    sendfile_rif=0;
    sendfile_ros=0;
  fi

  # Does the system support nanosleep
  nanosleep=`$autoconf sleep --cflags="-DBGL_NANOSLEEP"` || exit 1
  # Does the system support normalsleep
  normalsleep=`$autoconf sleep --cflags="-DBGL_SLEEP"`

  # The timezone variable
  timezone=`$autoconf timezone --cflags="$coflags"` || exit 1
  # The timeval variable
  timeval=`$autoconf timeval --cflags="$coflags"` || exit 1

  # The -pic C compiler options
  if [ "$cpicflags" = "no" ]; then
    cpicflags=""
  else
    if [ "$ldopt" != "no-share" ]; then
      if [ "$cpicflags" = "demanded" -o "$cpicflags " = " " ]; then
        cpicflags=`$autoconf ccpic --cflags="$cpicflags"` || exit 1
      fi
    else
      cpicflags=""
    fi
  fi

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

  # ld option
  lflags=`$autoconf ldextraopt --lflags="$lflags"` || exit 1
  if [ "$hostos " != "mingw " ]; then
    rflags=`$autoconf rdynamic --rflags="-rdynamic"` || exit 1
  fi

  # shared link additional soname option
  if [ "$ldsoname" = "blank" ]; then
    ldsoname=""
  else
    ldsoname=`$autoconf ldsoname $libdir --ld="$ld" --soname="$ldsoname"` || exit 1
  fi

  # The shared libraries
  if [ "$ldopt" = "no-share" ]; then
    echo "   shared library: no"
    haveshlib=0
  else
    ldlibs=-lc

    if [ "$hostos" = "mingw" ]; then
      ldlibs=""
    fi
    
    ldopt=`$autoconf ldshare --ld="$ld" --ldopt="$ldopt" --ldlibs="$ldlibs" --cflags="$cpicflags" --sharedsuffix="$sharedsuffix"` || exit 1
    if [ "$ldopt" = "no-share" ]; then
      ldopt=`$autoconf ldshare --ld="ld" --ldopt="$ldopt" --ldlibs="$ldlibs" --cflags="$cpicflags" --sharedsuffix="$sharedsuffix"` || exit 1
    fi

    if [ "$ldopt" = "no-share" ]; then
      haveshlib=0
      cpicflags="-DBGL_NO_PIC"
    else
      haveshlib=1
      ldpreload=`$autoconf ldpreload --ld="$ld" --ldlibs="-lc" --ldopt="$ldopt"` || exit 1
    fi
  fi

  # Does the system have dlopen?
  if [ "$ldopt " != "no-share" ]; then
    if [ "$hostos" = "mingw" ]; then
      havedlopen=1
      dlopen=""
    else
     dlopen=`$autoconf dlopen --dlopt="$dlopenopt"` || exit 1
     if [ "$dlopen" != "0" ]; then
       havedlopen=1
       dlopen=$dlopen
       extralibs="$dlopen $extralibs"
     else
       havedlopen=0
       dlopen=""
     fi
    fi
  else
    havedlopen=0
    dlopen=""
  fi

  # for now only the port is Unix
  $autoconf unix >> $bigloo_config_h || exit 1

  # which shell to use
  `$shell -c "ls -l > /dev/null"` || exit 1

  # the C beautifier
  id=`$autoconf indent --cflags="$cflags" --indent="$indent"` || exit 1
  if [ "$id " != "1 " ]; then
    indent=
  fi

  # the dirname command
  dirname=`$autoconf dirname --cflags="$cflags" --dirname="$dirname"` || exit 1

  # double precision
  prec=`$autoconf doubleprec` || exit 1

  # static link additional option
  ldstaticopt=`$autoconf ldstaticopt` || exit 1

  if [ "$hostos " = "mingw " -a "$pthreadlibs" != "no"  ]; then
    ldstaticopt="$ldstaticopt $pthreadlibs"
  fi

  # shared link additional option
  ldsharedopt=`$autoconf ldsharedopt` || exit 1

  # bdb configuration
  if [ "$bee" = "partial" ]; then
    havebdb=0
  else
    havebdb=1
  fi

  # 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 [ "$HOSTOS " = "cygwin " -a "$cygwindosjvm" = "yes" ]; then
      cpsep=";";
    elif [ "$HOSTOS " = "mingw " ]; then
      cpsep=";";
    else
      cpsep=":";
     fi

    jtest=`$autoconf javatest --java=$java \
                              --jflags=$jflags \
                              --jvflags=$jvflags \
                              --javac=$javac \
                              --jcflags=$jcflags \
                              --cpsep="$cpsep"` || exit 1

    if [ $jtest != 0 ]; then
      echo "*** ERROR:configure:Can't configure Java (see $configurelog for details)."
      exit 1
    else
      java_configured=yes
    fi

    java_version=`$javac -version 2>&1 | head -n 1` || exit 1
    if echo "$java_version" | grep "1.7" > /dev/null
      then java_version=1.7
    elif echo "$java_version" | grep "1.6" > /dev/null
      then java_version=1.6
    elif echo "$java_version" | grep "1.5" > /dev/null
      then java_version=1.5
    elif echo "$java_version" | grep "1.4" > /dev/null
      then java_version=1.4
    else
      jvmversion=`$java -version 2>&1 | head -n 1`
      if echo "$jvmversion" | grep "1.4" > /dev/null
        then java_version=1.4
      else
        java_version=1.3
      fi
    fi
  else
    java=java
    jflags=
    jvflags=
    jshell=sh
    jar=
  fi

  # Posix Os
  case $hostos in
    mingw)
      osclass="mingw"
      pathseparator=";"
      fileseparator="/"
      ostmp="$tmpdir"
      staticlibsuf="a"
      ucs2displayable=0;;

    unknown)
      ostmp="/tmp"
      fileseparator="/"
      pathseparator=":"
      staticlibsuf="a"
      ucs2displayable=0;;

    *)
      osclass="unix"
      pathseparator=":"
      fileseparator="/"
      ostmp="$tmpdir"
      staticlibsuf="a"
      ucs2displayable=0;;
  esac

  if [ "$ostmp " = " " ]; then
    ostmp=/tmp
  fi

  # bigloo_config_h, bigloo_config_jvm, bigloo_config_sch
  for p in $bigloo_config_h $bigloo_config_jvm $bigloo_config_sch; do
    if [ "$p " != " " ]; then
      rm -f $p 2> /dev/null
      rel=`echo $release | sed -e "s|[.]|_|"`;
      
      cat autoconf/`basename $p`.in \
        | sed -e "s|@CONFIGURE@|Automatically generated file (don't edit), `date`|" \
              -e "s|@BGL_RELEASE@|BGL_$rel|" \
              -e "s|@BGL_RELEASE_NUMBER@|$release|" \
              -e "s|@BGL_RELEASE_BRANCH@|$branch|" \
              -e "s|@BGL_HOMEURL@|$bigloourl|" \
              -e "s|@BGL_SPECIFIC_VERSION@|$specific|" \
              -e "s|@GC_VERSION@|$gcversion|" \
              -e "s|@BGL_DEFAULT_BACK_END@|$defaultbackend|" \
              -e "s|@BGL_DEFAULT_A_OUT@|$aout|" \
              -e "s|@BGL_DEFAULT_A_BAT@|$abat|" \
              -e "s|@STACK_GROWS_DOWN@|$stackgrows|" \
              -e "s|@PTR_ALIGNMENT@|$alignment|" \
              -e "s|@BGL_ISOC99@|$isoc99|" \
              -e "s|@BGL_HAS_ERRNOH@|$errnoh|" \
              -e "s|@BGL_CCDIV0@|$ccdiv0|" \
              -e "s|@HAVE_STDINT@|$stdint|" \
              -e "s|@HAVE_STDLIBINT@|$stdlibint|" \
              -e "s|@HAVE_UNISTDINT@|$unistdint|" \
              -e "s|@HAVE_GETUID@|$getuid|" \
              -e "s|@HAVE_GECOS@|$gecos|" \
              -e "s|@HAVE_GETPROTOENT@|$getprotoent|" \
              -e "s|@SETJMP@|$setjmp|" \
              -e "s|@JMP_BUF@|$jmpbuf|" \
              -e "s|@LONGJMP@|$longjmp|" \
              -e "s|@HAVE_BCOPY@|$havebcopy|" \
              -e "s|@NB_WINDOW_REGISTER@|$window|" \
              -e "s|@HAVE_SIGPIPE@|$sigpipe|" \
              -e "s|@HAVE_SIGSETMASK@|$sigsetmask|" \
              -e "s|@HAVE_SIGPROCMASK@|$sigprocmask|" \
              -e "s|@HAVE_ALLOCA@|$alloca|" \
              -e "s|@HAVE_ALLOCAH@|$allocah|" \
              -e "s|@HAVE_MMAP@|$mmap|" \
              -e "s|@HAVE_GETCWD@|$getcwd|" \
              -e "s|@HAVE_GETWD@|$getwd|" \
              -e "s|@CONSTANT_ALIGNED@|$cnstalign|" \
              -e "s|@BGL_BIG_ENDIAN@|$endian|" \
              -e "s|@HAVE_PIPE@|$pipe|" \
              -e "s|@HAVE_SYMLINK@|$symlink|" \
              -e "s|@BGL_LONGLONG_T@|$longlong|" \
              -e "s|@BGL_HAVE_LONGLONG@|$havelonglong|" \
              -e "s|@BGL_LONG_LIMBS@|$long_limbs|" \
              -e "s|@BGL_LONGLONG_LIMBS@|$longlong_limbs|" \
              -e "s|@C_LONG_SIGN_BIT@|$long_sign_bit|" \
              -e "s|@C_ELONG_SIGN_BIT@|$elong_sign_bit|" \
              -e "s|@C_LLONG_SIGN_BIT@|$llong_sign_bit|" \
              -e "s|@BGL_HAVE_LABS@|$have_labs|" \
              -e "s|@BGL_LABS@|$labs|" \
              -e "s|@BGL_HAVE_LLABS@|$have_llabs|" \
              -e "s|@BGL_LLABS@|$llabs|" \
              -e "s|@BGL_HAVE_STRTOLL@|$have_strtoll|" \
              -e "s|@BGL_STRTOLL@|$strtoll|" \
              -e "s|@BGL_HAVE_STRTOULL@|$have_strtoull|" \
              -e "s|@BGL_STRTOULL@|$strtoull|" \
              -e "s|@BGL_HAVE_GMP@|$havegmp|" \
              -e "s|@HAVE_SIGCHLD@|$sigchld|" \
              -e "s|@HAVE_SETENV@|$setenv|" \
              -e "s|@HAVE_SIGACTION@|$sigaction|" \
              -e "s|@BGL_HAVE_SELECT@|$select|" \
              -e "s|@BGL_HAVE_FCNTL@|$fcntl|" \
              -e "s|@HAVE_TERMIO@|$termio|" \
              -e "s|@HAVE_TERMIOS@|$termios|" \
              -e "s|@POSIX_FILE_OPS@|$posixfileops|" \
              -e "s|@BGL_SENDFILE_BRAND@|$sendfile|" \
              -e "s|@BGL_SENDFILE_REQUIRE_INPUT_FILE@|$sendfile_rif|" \
              -e "s|@BGL_SENDFILE_REQUIRE_OUTPUT_SOCKET@|$sendfile_ros|" \
              -e "s|@BGL_NANOSLEEP@|$nanosleep|" \
              -e "s|@BGL_SLEEP@|$normalsleep|" \
              -e "s|@BGL_TIMEZONE@|$timezone|" \
              -e "s|@BGL_HAVE_TIMEVAL@|$timeval|" \
              -e "s|@HAVE_SHARED_LIBRARY@|$haveshlib|" \
              -e "s|@HAVE_DLOPEN@|$havedlopen|" \
              -e "s|@DLOPEN_LD_OPT@|$dlopen|" \
              -e "s|@HAVE_SOCKLEN@|$socklen|" \
              -e "s|@BGL_HAVE_SOCKET_TCP_NODELAY@|$tcpnodelay|" \
              -e "s|@BGL_HAVE_SOCKET_TCP_CORK@|$tcpcork|" \
              -e "s|@BGL_HAVE_SOCKET_TCP_QUICKACK@|$tcpquickack|" \
              -e "s|@BGL_HAVE_INET_ATON@|$inet_aton|" \
              -e "s|@BGL_HAVE_INET_PTON@|$inet_pton|" \
              -e "s|@BGL_HAVE_UNIX_SOCKET@|$unix_socket|" \
              -e "s|@BGL_HAVE_GETADDRINFO@|$getaddrinfo|" \
              -e "s|@BGL_AUTO_FINALIZER@|$gcfinalizer|" \
              -e "s|@SHELL@|$shell|" \
              -e "s|@SHELL_MV@|$bgl_shell_mv|" \
              -e "s|@SHELL_RM@|$bgl_shell_rm|" \
              -e "s|@C_COMPILER_STYLE@|$ccstyle|" \
              -e "s|@C_COMPILER@|$cc|" \
              -e "s|@C_FLAGS@|$cflags|" \
              -e "s|@C_COMPILER_O_OPTION@|-o |" \
              -e "s|@C_COMPILER_DEBUG_OPTION@|-g|" \
              -e "s|@C_OBJECT_FILE_EXTENSION@|$cobj|" \
              -e "s|@C_COMPILER_OPTIM_FLAGS@|$coflags $cflags|" \
              -e "s|@C_STRIP_FLAGS@|$csflags|" \
              -e "s|@C_LINKER_STYLE@|$ldstyle|" \
              -e "s|@C_LINKER_O_OPTION@|-o |" \
              -e "s|@C_LINKER_DEBUG_OPTION@|-g |" \
              -e "s|@C_LINKER_OPTIM_FLAGS@||" \
              -e "s|@C_PROFILE_FLAGS@|$cpflags $cflags|" \
              -e "s|@C_STRING_SPLIT@|$stringsplit|" \
              -e "s|@BGL_LD_LIBRARY_DIR@|$libdir|" \
              -e "s|@BGL_NON_CUSTOM_GC_DIR@|$gclibdir|" \
              -e "s|@LIBRARY_DIRECTORY@|$libdir$dirsep$fildir|" \
              -e "s|@BGL_GC_LIBRARY@|$gclib|" \
              -e "s|@BGL_GC_CUSTOM@|$isgccustom|" \
              -e "s|@ZIP_DIRECTORY@|$syszipdirstr|" \
              -e "s|@DLL_DIRECTORY@|$sysdlldirstr|" \
              -e "s|@DNS_CACHE@|$dnscache|" \
          | sed \
              -e "s|@USER_LIBRARIES@|$extralibs|" \
              -e "s|@C_BEAUTIFIER@|$indent|" \
              -e "s|@DIRNAME_CMD@|$dirname|" \
              -e "s|@LIBRARY_BASE_NAME@|$libraryname|" \
              -e "s|@DOUBLE_PRECISION@|$prec|" \
              -e "s|@ADDITIONAL_STATIC_LINK_OPTION@|$ldstaticopt|" \
              -e "s|@ADDITIONAL_SHARED_LINK_OPTION@|$ldsharedopt|" \
              -e "s|@BGL_HAVE_BIGLOO_ABORT@|0|" \
              -e "s|@BGL_HAVE_BDB@|$havebdb|" \
              -e "s|@BGL_JAVA@|$java|" \
              -e "s|@BGL_JAVA_OPT@|$jflags|" \
              -e "s|@BGL_JAVA_VOPT@|$jvflags|" \
              -e "s|@BGL_JAR@|$jar|" \
              -e "s|@BGL_JAVA_SHELL@|$jshell|" \
              -e "s|@BGL_IMPORT@|extern|" \
              -e "s|@BGL_EXPORTED_DECL@|extern|" \
              -e "s|@BGL_EXPORTED_DEF@||" \
              -e "s|@BGL_RUNTIME_DECL@|extern|" \
              -e "s|@BGL_RUNTIME_DEF@||" \
              -e "s|@OS_CLASS@|$osclass|" \
              -e "s|@OS_NAME@|$hostos|" \
              -e "s|@OS_ARCH@|$hostcpu|" \
              -e "s|@OS_VERSION@|$hostosversion|" \
              -e "s|@OS_TMP@|$ostmp|" \
              -e "s|@OS_CHARSET@|$oscharset|" \
              -e "s|@FILE_SEPARATOR@|$fileseparator|" \
              -e "s|@PATH_SEPARATOR@|$pathseparator|" \
              -e "s|@STATIC_LIB_SUFFIX@|$staticlibsuf|" \
              -e "s|@SHARED_LIB_SUFFIX@|$sharedsuffix|" \
              -e "s|@UCS2_DISPLAYABLE@|$ucs2displayable|" \
              -e "s|@GC_HAVE_BLOCKING@|$gchaveblocking|" \
              -e "s|@GC_HAVE_DO_BLOCKING@|$gchavedoblocking|" \
              -e "s|@PTHREAD_HAVE_TIMEDLOCK@|$pthreadtimedlock|" \
              -e "s|@PTHREAD_HAVE_TIMEDJOIN@|$pthreadtimedjoin|" \
              -e "s|@BGL_PTHREAD_TERM_SIG@|$pthreadtermsig|" \
              -e "s|@BGL_HAS_THREAD_LOCALSTORAGE@|$pthreadhastls|" \
              -e "s|@BGL_THREAD_DECL@|$pthreaddecl|" \
              -e "s|@BGL_HEAP_DEBUG_COPT@||" \
              -e "s|@BGL_HAVE_MIXER@|$havemixer|" \
              -e "s|@BGL_REGEXP_FAMILY@|$regexp|" \
        > $p
    fi
  done

  # bigloo_h
  cp runtime/Include/`basename $bigloo_h` $bigloo_h
fi

#*---------------------------------------------------------------------*/
#*    bigloo_gc.h                                                      */
#*---------------------------------------------------------------------*/
if [ $action = "all" -o $action = "bigloo_gc" ]; then
  echo "/* Generated file, don't edit */" > $bigloo_gc_h
  cat autoconf/bigloo_gc.h.in \
     | sed -e "s|@GC_VERSION@|$gcversion|" >> $bigloo_gc_h
fi

#*---------------------------------------------------------------------*/
#*    bigloo_config.el                                                 */
#*---------------------------------------------------------------------*/
if [ $action = "all" -o $action = "bigloo_config_el" ]; then
  echo ""
  echo "Configuring $bigloo_config_el:"

  if [ "$emacs " = " " ]; then
    emacs=emacs
    emacsversion=`$autoconf emacsbrand --emacs=emacs` || exit 1
    if [ "$emacsversion" = "false" ]; then
      emacs=xemacs
      emacsversion=`$autoconf emacsbrand --emacs=xemacs` || exit 1
    fi
  else
    emacsversion=`$autoconf emacsbrand --emacs=$emacs` || exit 1
  fi

  if [ "$emacsversion" != "false" ]; then
    if [ "$lispdir " = " " ]; then
      emacslisppath=`$autoconf emacslisppath --emacs=$emacs` || exit 1
    else
      emacslisppath=`$autoconf emacslisppath --emacs=$emacs --path=$lispdir` || exit 1
    fi
    if [ "$emacslisppath" = "" ]; then
      emacsversion="false";
    fi
  else
    emacslisppath=""
  fi

  rm -f $bigloo_config_el 2> /dev/null

  echo ";; Automatically generated file (don't edit) */" > $bigloo_config_el
  echo ";; `date`" >> $bigloo_config_el
  echo "" >> $bigloo_config_el
  echo "(provide 'bmacs-config)" >> $bigloo_config_el
  echo "(defvar bmacs-docdir \"$docdir\")" >> $bigloo_config_el
  echo "(defvar bmacs-lispdir \"$emacslisppath\")" >> $bigloo_config_el
fi


#*---------------------------------------------------------------------*/
#*    texinfo                                                          */
#*---------------------------------------------------------------------*/
if [ "$configureinfo" = "yes" ]; then
  echo ""
  echo "Configuring texinfo:"

  infoinfo=`$autoconf info --makeinfo="$makeinfo" \
                           --texi2dvi="$texi2dvi" \
                           --texi2dviopt="$texi2dviopt" \
                           --texi2pdf="$texi2pdf" \
                           --texi2html="$texi2html" \
                           --texi2htmlopt="$texi2htmlopt"` || exit 1

  if [ "$infoinfo " != " " ]; 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
  else
     makeinfo=no
     makeinfoopt=
     texi2dvi=
     texi2dviopt=
     texi2html=
     texi2htmlopt=
     texi2pdf=
  fi

  if [ "$iinfo " = " " ]; then
    installinfo=`$autoconf installinfo --exe=$exe` || exit 1
  else
    installinfo=`$autoconf installinfo --installinfo=$iinfo --exe=$exe` || exit 1
  fi
  if [ "$installinfo " != " " ]; then
    installinfodir=`$autoconf installinfodir --installinfo=$installinfo --exe=$exe` || exit 1
  fi
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
  # We create an unexisting temporary file name
  name=$buildtmp/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
  echo "# automatically generated, don't edit" > $makefile_cfg
  echo "# `date`" >> $makefile_cfg
  echo "" >> $makefile_cfg

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

  # The repository
  echo "BIGLOOSVN=$bigloosvn" >> $makefile_cfg
  echo >> $makefile_cfg

  # The tools
  echo "AFILE_EXE=$afile" >> $makefile_cfg
  echo "JFILE_EXE=$jfile" >> $makefile_cfg
  echo "BTAGS_EXE=$btags" >> $makefile_cfg
  echo "BDEPEND_EXE=$bdepend" >> $makefile_cfg
  echo "BMAKE_EXE=$bmake" >> $makefile_cfg
  echo "BPP_EXE=$bpp" >> $makefile_cfg
  echo "BPROF_EXE=$bprof" >> $makefile_cfg
  echo "MCO_EXE=$mco" >> $makefile_cfg
  echo "JAS_EXE=$jas" >> $makefile_cfg
  echo "BMEM_EXE=$bmem" >> $makefile_cfg
  echo "BMEMRUN_EXE=$bmemrun" >> $makefile_cfg
  echo "BDB_EXE=$bdb" >> $makefile_cfg
  echo "BGLPKG_EXE=$bglpkg" >> $makefile_cfg
  echo >> $makefile_cfg

  # The OS
  echo "HOSTOS=$hostos" >> $makefile_cfg
  echo >> $makefile_cfg

  # The rm command
  echo "RM=$shell_rm" >> $makefile_cfg
  echo >> $makefile_cfg

  # The ln -s command
  echo "LN_S=${ln_s}" >> $makefile_cfg
  echo >> $makefile_cfg

  # The bee support
  echo "INSTALLBEE=$bee" >> $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

  # The Buildbin directory
  if [ "$buildbindir " = " " ]; then
      echo "BGLBUILDBINDIR=$bootdir/bin" >> $makefile_cfg
      echo "BGLBUILDLIBDIR=$bootdir/lib/$release" >> $makefile_cfg
  else
      buildlibdir=`$buildbindir/bigloo -eval '(begin (print *default-lib-dir*) (exit 0))'`
      echo "BGLBUILDBINDIR=$buildbindir" >> $makefile_cfg
      echo "BGLBUILDLIBDIR=$buildlibdir" >> $makefile_cfg
  fi
  # build bigloo
  if [ "$bigloo " = " " ]; then
    echo "BGLBUILDBIGLOO=$""(BGLBUILDBINDIR)/bigloo" >> $makefile_cfg
  else
    echo "BGLBUILDBIGLOO=$bigloo" >> $makefile_cfg
  fi
  echo >> $makefile_cfg

  # Directories
  echo "DESTDIR=" >> $makefile_cfg
  echo "BINDIR=$bindir" >> $makefile_cfg
  echo 'LIBDIR=$(DESTDIR)'"$libdir" >> $makefile_cfg
  echo "FILDIR=$fildir" >> $makefile_cfg
  echo 'ZIPDIR=$(DESTDIR)'"$zipdir" >> $makefile_cfg
  echo 'SYSZIPDIR=$(DESTDIR)'"$syszipdir" >> $makefile_cfg
  echo 'DLLDIR=$(DESTDIR)'"$dlldir" >> $makefile_cfg
  echo 'SYSDLLDIR=$(DESTDIR)'"$sysdlldir" >> $makefile_cfg
  echo 'MANDIR=$(DESTDIR)'"$mandir" >> $makefile_cfg
  echo 'INFODIR=$(DESTDIR)'"$infodir" >> $makefile_cfg
  echo 'DOCDIR=$(DESTDIR)'"$docdir" >> $makefile_cfg
  echo "TMP=$buildtmp" >> $makefile_cfg
  echo >> $makefile_cfg

  # Native backend
  echo "NATIVEBACKEND=$nativebackend" >> $makefile_cfg
  echo "NATIVE_MACHDEP=$nativemachdep" >> $makefile_cfg
  echo >> $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 $cgcfinalflags $gcspecial -I$""(BOOTLIBDIR) $""(CPICFLAGS)" >> $makefile_cfg
  echo "EXTRALIBS=$extralibs" >> $makefile_cfg
  echo "EXTRAGCLIBS=$extragclibs" >> $makefile_cfg
  echo "CLOSELIBS= # always empty, does not contain GC, override by makefiles" >> $makefile_cfg
  echo >> $makefile_cfg

  # The GC library
  echo "CUSTOMGC=$gccustom" >> $makefile_cfg
  echo "GCLIB=$gclib" >> $makefile_cfg
  if [ $customgc = "yes" ]; then
     echo "GCCUSTOM=yes" >> $makefile_cfg
     echo "GCINCLUDE=-I$""(BOOTDIR)/gc/$""(CUSTOMGC)/include" >> $makefile_cfg
     echo "GCCLOSELIB=$sharedlibrarygcclosed" >> $makefile_cfg
     echo "GCSTDOBJ=" >> $makefile_cfg
  else
     echo "GCCUSTOM=no" >> $makefile_cfg
     echo "GCINCLUDE=-I$gcincdir" >> $makefile_cfg
     echo 'GCCLOSELIB=-l$(GCLIB)' >> $makefile_cfg
     echo "GCSTDOBJ=Clib/non_inline_alloc.o" >> $makefile_cfg
     echo "GCLIBDIR=$gclibdir" >>  $makefile_cfg
  fi
  echo >> $makefile_cfg

  # The GMP library
  if [ "$customgmp " = "yes " ]; then
    echo "GMPCUSTOM=yes" >> $makefile_cfg
    echo "CUSTOMGMP=$gmpversion" >> $makefile_cfg
  else
    echo "GMPCUSTOM=no" >> $makefile_cfg
  fi

  # additional bigloo compiler link flags (some architecture such as AIX
  # require a special to link huge executable)
  echo "EXTRA_LD_OPT=$lflags $rflags" >> $makefile_cfg
  if [ $sharedcompiler = "yes" ]; then
     echo "SHRD_COMP=yes" >> $makefile_cfg;
  else
     echo "SHRD_COMP=no" >> $makefile_cfg;
  fi

  if [ $sharedbde = "yes" ]; then
     echo "SHRD_BDE_OPT=" >> $makefile_cfg;
  else
     echo "SHRD_BDE_OPT=-static-bigloo" >> $makefile_cfg;
  fi

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

  # The assembler
  echo "AS=$as" >> $makefile_cfg
  echo >> $makefile_cfg

  # Ar checking
  echo "AR=$ar" >> $makefile_cfg
  echo "ARFLAGS=$arflags" >> $makefile_cfg

  # Does the system require ranlib?
  echo "RANLIB=$ranlib" >> $makefile_cfg

  # The shared libraries
  if [ "$ldopt" = "no-share" ]; then
    echo "SHAREDLIBRARYSUPPORT=no" >> $makefile_cfg
    echo "LD=true# (true means no dynamic library)" >> $makefile_cfg
    echo "LDPRELOADSUPPORT=no" >> $makefile_cfg

    echo "LDSONAME=" >> $makefile_cfg
    echo "LDINSTALLNAME=$ldinstallname" >> $makefile_cfg
    echo "LDINSTALLNAMEDIRROOT=$ldinstallnamedirroot" >> $makefile_cfg
  else
    echo "SHAREDLIBRARYSUPPORT=yes" >> $makefile_cfg
    echo "SHAREDLIBRARYCLOSED=$sharedlibraryclosed" >> $makefile_cfg
    echo "LD=$ld $ldopt" >> $makefile_cfg
    echo "LDFLAGS=$ldflags" >> $makefile_cfg
    echo "LDLIBS=$ldlibs" >> $makefile_cfg
    echo "LDCOMPLIBS=$ldcomplibs" >> $makefile_cfg
    echo "LDPRELOADSUPPORT=$ldpreload" >> $makefile_cfg

    echo "LDSONAME=$ldsoname" >> $makefile_cfg
    echo "LDINSTALLNAME=$ldinstallname" >> $makefile_cfg
    echo "LDINSTALLNAMEDIRROOT=$ldinstallnamedirroot" >> $makefile_cfg
  fi
  echo >> $makefile_cfg

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

  # The dlopen facility
  if [ "$dlopen" != "0" ]; then
    echo "DLOPENSUPPORT=yes" >> $makefile_cfg
  else
    echo "DLOPENSUPPORT=no" >> $makefile_cfg
  fi

  echo >> $makefile_cfg
  # Does the system support threads
  if [ "$gcthread" != "no" ]; then
    echo "GCTHREADSUPPORT=yes" >> $makefile_cfg
    echo "CGCTHREADFLAGS=$gcthread -DBGL_GC_THREADS" >> $makefile_cfg
  else
    echo "GCTHREADSUPPORT=no" >> $makefile_cfg
    echo "CGCTHREADFLAGS=" >> $makefile_cfg
  fi

  # find out the C library for posix threads
  echo "PTHREADLIBS=$pthreadlibs" >> $makefile_cfg

  # Patch the code of the thread when using non custom GC
  if [ "$pthreadlibs" != "no" ]; then
    # the default gc on mingw is built with thread support.
    # there is no need to link with a special version of gc library
    if [ $isgccustom = "0" ]; then
      gclibth=$stdgclib
    else
      if [ "$hostos " = "mingw " ]; then
        gclibth=bigloogc
      else
        gclibth=bigloogc_fth
      fi
    fi

    if [ "$pthreadtimedjoin " = "1 " ]; then
       srfitimedjoin=pthread-timedjoin;
    fi

    cat api/fthread/src/Misc/fthread.init.in \
        | sed -e "s|@BIGLOOGC_FTH@|$gclibth|g" \
        | sed -e "s|@PTHREADLIBS@|$pthreadlibs|g" \
        >  api/fthread/src/Misc/fthread.init
    cat api/pthread/src/Misc/pthread.init.in \
        | sed -e "s|@BIGLOOGC_PTH@|$gclibth|g" \
        | sed -e "s|@PTHREADLIBS@|$pthreadlibs|g" \
        | sed -e "s|@PTHREADLIBS@|$pthreadlibs|g" \
        | sed -e "s|@PTHREAD_TIMEDJOIN@|$srfitimedjoin|g" \
        >  api/pthread/src/Misc/pthread.init
  else
    napis=;
    for a in $apis; do
      if [ "pthread" != "$a" -a "fthread" != "$a" -a "gstreamer" != "$a" ]; then
        if [ "$napis " = " " ]; then
          napis="$a";
        else
          napis="$napis $a";
        fi
      fi
    done
    apis=$napis;
  fi

  # SSL
  if [ "$openssllibs" != "no" ]; then
    echo "OPENSSLLIBS=$openssllibs" >> $makefile_cfg
    echo ";; automatically generated. Don't edit" > api/ssl/src/Misc/ssl.init
    cat api/ssl/src/Misc/ssl.init.in \
        | sed -e "s|@OPENSSLLIBS@|$openssllibs|g" \
        >>  api/ssl/src/Misc/ssl.init

    dtls=1
    sslv2=1
    sslv23=1
    if [ "$openssldtls" = "no" ]; then
      dtls=0;
    fi
    if [ "$opensslv2" = "no" ]; then
      sslv2=0;
    fi
    if [ "$opensslv23" = "no" ]; then
      sslv23=0;
    fi

    echo "/* automatically generated, Don't edit */" >  api/ssl/src/C/bglssl.h
    cat api/ssl/src/C/bglssl.h.in \
      | sed -e "s|@HAVEDTLS@|$dtls|g" \
            -e "s|@HAVEV2@|$sslv2|g" \
            -e "s|@HAVEV23@|$sslv23|g" \
        >>  api/ssl/src/C/bglssl.h
  else
    napis=;
    for a in $apis; do
       if [ "ssl" != $a ]; then
         if [ "$napis " = " " ]; then
           napis="$a";
         else
           napis="$napis $a";
         fi
       fi
    done
    apis=$napis;
    echo "OPENSSLLIBS=" >> $makefile_cfg
  fi

  # SQLITE
  echo "SQLITELIBS=$sqlitelibs" >> $makefile_cfg
  if [ "$sqlitelibs " = " " ]; then
    sqlitesrfi=sqltiny;
    echo "SQLITESRFI=sqltiny" >> $makefile_cfg
  else
    sqlitesrfi=sqlite;
    echo "SQLITESRFI=sqlite" >> $makefile_cfg
  fi

  echo ";; automatically generated. Don't edit" > api/sqlite/src/Misc/sqlite.init
  cat api/sqlite/src/Misc/sqlite.init.in \
      | sed -e "s|@SQLITELIBS@|$sqlitelibs|g" \
      | sed -e "s|@SQLITESRFI@|$sqlitesrfi|g" \
      >>  api/sqlite/src/Misc/sqlite.init

  # GSTREAMER
  if [ "$gstreamer " != " " ]; then
    echo "GSTREAMER=$gstreamer" >> $makefile_cfg
    echo "GSTREAMERLIBS=$gstreamerlibs" >> $makefile_cfg
    echo "GSTREAMERCFLAGS=$gstreamercflags" >> $makefile_cfg

    # Patch the code of the GSTREAMER init file
    echo ";; automatically generated. Don't edit" >  api/gstreamer/src/Misc/gstreamer.init
    cat api/gstreamer/src/Misc/gstreamer.init.in \
      | sed -e "s|@GSTREAMERLIBS@|$gstreamerlibs|g" \
            -e "s|@GSTREAMERCFLAGS@|$gstreamercflags|g" \
            -e "s|@GSTREAMERAUDIO@|$gstaudio|g" \
      >>  api/gstreamer/src/Misc/gstreamer.init

    # Produce the bglgst_config.h file
    cat api/gstreamer/src/Clib/bglgst_config.h.in \
      | sed -e "s|@CONFIGURE@|Automatically generated file (don't edit), `date`|" \
            -e "s|@GSTREAMER_VERSION@|$gstreamer|g" \
            -e "s|@GSTREAMER_USE_THREADS@|$gstusethread|g" \
            -e "s|@GSTREAMER_HAVE_AUDIO@|$gsthaveaudio|g" \
      >  api/gstreamer/src/Clib/bglgst_config.h

  else
    napis=;
    for a in $apis; do
       if [ "gstreamer" != $a ]; then
         if [ "$napis " = " " ]; then
           napis="$a";
         else
           napis="$napis $a";
         fi
       fi
    done
    apis=$napis;
    echo "GSTREAMER=" >> $makefile_cfg
    echo "GSTREAMERLIBS=" >> $makefile_cfg
    echo "GSTREAMERFLAGS=" >> $makefile_cfg
  fi

  # ALSA
  if [ "$alsa " != "no " ]; then
    echo "ALSA=$alsa" >> $makefile_cfg
    echo "ALSALIBS=$alsalibs" >> $makefile_cfg
    echo "ALSACFLAGS=$alsacflags" >> $makefile_cfg

    # Patch the code of the ALSA init file
    echo ";; automatically generated. Don't edit" >  api/alsa/src/Misc/alsa.init
    cat api/alsa/src/Misc/alsa.init.in \
      | sed -e "s|@ALSALIBS@|$alsalibs|g" \
            -e "s|@ALSACFLAGS@|$alsacflags|g" \
      >>  api/alsa/src/Misc/alsa.init
  else
    napis=;
    for a in $apis; do
       if [ "alsa" != $a ]; then
         if [ "$napis " = " " ]; then
           napis="$a";
         else
           napis="$napis $a";
         fi
       fi
    done
    apis=$napis;
    echo "ALSA=" >> $makefile_cfg
    echo "ALSALIBS=" >> $makefile_cfg
    echo "ALSAFLAGS=" >> $makefile_cfg
  fi

  # MPG123
  if [ "$mpg123libs " != "no " ]; then
    echo "MPG123=$mpg123" >> $makefile_cfg
    echo "MPG123LIBS=$mpg123libs" >> $makefile_cfg
    echo "MPG123CFLAGS=$mpg123cflags" >> $makefile_cfg

    # Patch the code of the MPG123 init file
    echo ";; automatically generated. Don't edit" >  api/mpg123/src/Misc/mpg123.init
    cat api/mpg123/src/Misc/mpg123.init.in \
      | sed -e "s|@MPG123LIBS@|$mpg123libs|g" \
            -e "s|@MPG123CFLAGS@|$mpg123cflags|g" \
      >>  api/mpg123/src/Misc/mpg123.init
  else
    napis=;
    for a in $apis; do
       if [ "mpg123" != $a ]; then
         if [ "$napis " = " " ]; then
           napis="$a";
         else
           napis="$napis $a";
         fi
       fi
    done
    apis=$napis;
    echo "MPG123=" >> $makefile_cfg
    echo "MPG123LIBS=" >> $makefile_cfg
    echo "MPG123FLAGS=" >> $makefile_cfg
  fi

  # FLAC
  if [ "$flaclibs " != "no " ]; then
    echo "FLAC=$flac" >> $makefile_cfg
    echo "FLACLIBS=$flaclibs" >> $makefile_cfg

    # Patch the code of the FLAC init file
    echo ";; automatically generated. Don't edit" >  api/flac/src/Misc/flac.init
    cat api/flac/src/Misc/flac.init.in \
      | sed -e "s|@FLACLIBS@|$flaclibs|g" \
            -e "s|@FLACCFLAGS@|$flaccflags|g" \
      >>  api/flac/src/Misc/flac.init
  else
    napis=;
    for a in $apis; do
       if [ "flac" != $a ]; then
         if [ "$napis " = " " ]; then
           napis="$a";
         else
           napis="$napis $a";
         fi
       fi
    done
    apis=$napis;
    echo "FLAC=" >> $makefile_cfg
    echo "FLACLIBS=" >> $makefile_cfg
    echo "FLACCFLAGS=" >> $makefile_cfg
  fi

  # AVAHI
  echo "AVAHI=$avahi" >> $makefile_cfg
  if [ "$avahi " != "no " ]; then
    echo "AVAHILIBS=$avahilibs" >> $makefile_cfg
    echo "AVAHICFLAGS=$avahicflags" >> $makefile_cfg

    # Patch the code of the AVAHI init file
    echo ";; automatically generated. Don't edit" >  api/avahi/src/Misc/avahi.init
    cat api/avahi/src/Misc/avahi.init.in \
      | sed -e "s|@AVAHILIBS@|$avahilibs|g" \
            -e "s|@AVAHICFLAGS@|$avahicflags|g" \
      >>  api/avahi/src/Misc/avahi.init
  else
    napis=;
    for a in $apis; do
       if [ "avahi" != $a ]; then
         if [ "$napis " = " " ]; then
           napis="$a";
         else
           napis="$napis $a";
         fi
       fi
    done
    apis=$napis;
    echo "AVAHILIBS=" >> $makefile_cfg
    echo "AVAHICFLAGS=" >> $makefile_cfg
  fi

  # PHIDGET
  echo "PHIDGET=$phidget" >> $makefile_cfg
  if [ "$phidget " != "no " ]; then
    echo "PHIDGETLIBS=$phidgetlibs" >> $makefile_cfg
    echo "PHIDGETCFLAGS=$phidgetcflags" >> $makefile_cfg
    echo "PHIDGETLIBDIR=$phidgetlibdir" >> $makefile_cfg

    # Patch the code of the PHIDGET init file
    echo ";; automatically generated. Don't edit" >  api/phidget/src/Misc/phidget.init
    cat api/phidget/src/Misc/phidget.init.in \
      | sed -e "s|@PHIDGETLIBS@|$phidgetlibs|g" \
            -e "s|@PHIDGETCFLAGS@|$phidgetcflags|g" \
            -e "s|@PHIDGETVERSION@|$phidgetversion|g" \
            -e "s|@PHIDGETLIBDIR@|$phidgetlibdir|g" \
      >>  api/phidget/src/Misc/phidget.init

    # Patch the code of the bgphidget_config.h file
    echo "/* automatically generated. Don't edit */" >  api/phidget/src/Clib/bglphidget_config.h
    cat api/phidget/src/Clib/bglphidget_config.h.in \
      | sed -e "s|@PHIDGETLIBS@|$phidgetlibs|g" \
            -e "s|@PHIDGETCFLAGS@|$phidgetcflags|g" \
            -e "s|@PHIDGETVERSION@|$phidgetversion|g" \
            -e "s|@PHIDGETLIBDIR@|$phidgetlibdir|g" \
      >>  api/phidget/src/Clib/bglphidget_config.h
  else
    napis=;
    for a in $apis; do
       if [ "phidget" != $a ]; then
         if [ "$napis " = " " ]; then
           napis="$a";
         else
           napis="$napis $a";
         fi
       fi
    done
    apis=$napis;
    echo "PHIDGETLIBS=" >> $makefile_cfg
    echo "PHIDGETCFLAGS=" >> $makefile_cfg
    echo "PHIDGETLIBDIR=" >> $makefile_cfg
  fi

  # DBUS
  if [ "$dbusld " != " " ]; then
    echo ";; automatically generated. Don't edit" >  api/dbus/src/Misc/dbus.init
    cat api/dbus/src/Misc/dbus.init.in \
        | sed -e "s|@DBUSLIBS@|$dbusld|g" \
              -e "s|@DBUSCFLAGS@|$dbusincl|g" \
        >>  api/dbus/src/Misc/dbus.init
    echo "CDBUSFLAGS=$dbusincl" >> $makefile_cfg
  else
    napis=;
    for a in $apis; do
       if [ "dbus" != $a ]; then
         if [ "$napis " = " " ]; then
           napis="$a";
         else
           napis="$napis $a";
         fi
       fi
    done
    apis=$napis;
  fi

  # CSV
  echo ";; automatically generated. Don't edit" > api/csv/src/Misc/csv.init
  cat api/csv/src/Misc/csv.init.in \
      >>  api/csv/src/Misc/csv.init
  cat api/csv/src/Llib/csv.sch \
      >>  api/csv/src/Misc/csv.init

  # SCMPKG
  configure=api/pkgcomp/src/Llib/configure.scm
  rm -f $configure
  echo ";; automatically generated. Don't edit" >  $configure
  cat $configure.in \
    | sed -e "s|@PKGCOMPVERSION@|$scmpkgversion|g" \
    >>  $configure
  chmod a-w $configure

  # pkgcomp.init
  pkgcomp_init=api/pkgcomp/src/Misc/pkgcomp.init
  rm -f $pkgcomp_init
  echo ";; automatically generated. Don't edit" >  $pkgcomp_init
  cat api/pkgcomp/src/Misc/pkgcomp.init.in \
      | sed -e "s|@PKGCOMPVERSION@|$scmpkgversion|g" \
      >>  $pkgcomp_init
  echo "" >> $pkgcomp_init

  for p in srfi89.sch interface.sch expanders.sch class.sch configure.sch; do
    cat api/pkgcomp/src/Llib/$p >> $pkgcomp_init
    echo "" >> $pkgcomp_init
  done

  # pkgcomp startup
  echo "(cond-expand ((not bigloo-@expanders) (@install-expanders!)))" \
     >> $pkgcomp_init

  # bglpkg
  configure=bglpkg/configure.scm
  rm -f $configure
  echo ";; automatically generated. Don't edit" >  $configure
  cat $configure.in \
       | sed -e "s|@BGLPKGVERSION@|$release|g" \
             -e "s|@BGLPKGNAME@|$bglpkg|g" \
       >>  $configure
  chmod a-w $configure
  echo "ENABLE_BGLPKG=$enable_bglpkg" >> $makefile_cfg
  echo "" >> $makefile_cfg

  # Does the system support strip
  echo "STRIP=$strip" >> $makefile_cfg
  echo "" >> $makefile_cfg

  # Display emacs
  echo "EMACS=$emacs" >> $makefile_cfg
  echo "EMACSDIR=$emacslisppath" >>  $makefile_cfg
  echo "EMACSBRAND=$emacsversion" >> $makefile_cfg
  echo "EWARN=$emacswarning" >> $makefile_cfg
  echo >> $makefile_cfg

  # bmask
  echo "BMASK=$bmask" >> $makefile_cfg
  echo "MODEXE=$modexe" >> $makefile_cfg
  echo "MODFILE=$modfile" >> $makefile_cfg
  echo "MODDIR=$moddir" >> $makefile_cfg
  echo >> $makefile_cfg

  # The info version
  if [ "$configureinfo" = "yes" ]; then
    if [ "$infoinfo " != " " ]; then
       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=" >> $makefile_cfg
    fi
  fi

  # The info installation
  if [ "$installinfo " = " " ]; then
     echo "INSTALLINFO=\"\"" >> $makefile_cfg
  else
     echo "INSTALLINFO=$installinfo" >> $makefile_cfg
     echo "INSTALLINFODIROPT=$installinfodir" >> $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 --tmp=$buildtmp

      if [ $? != 0 ]; then
        echo "*** ERROR:configure:Can't find zip needed for the JVM back-end"
        exit 3
      fi

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

      if [ $? != 0 ]; then
        echo "*** ERROR:configure:Can't find jar nedded for the 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 --tmp=$buildtmp

        if [ $? != 0 ]; then
          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 "JAVA_VERSION=$java_version" >> $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

    echo "JVMRECETTEBOOTPATH=$jvmrecettebootpath" >> $makefile_cfg
    echo "JVMAPIBOOTPATH=$jvmapibootpath" >> $makefile_cfg

    # Cygwin prefix
    if [ "$hostos" = "cygwin" ]; then
      echo "" >> $makefile_cfg
      echo CYGWINPREFIX=`echo "$cygwindospath" | sed -e 's/\\\\/\\\\\\\\/g'` >> $makefile_cfg
      bigloozip=$bootdir/lib/$release
      bigloozip=`echo $bigloozip | sed -e 's/\/cygdrive\/\([a-z]\)\//\1:\//'`        # corrects pathes like /cygdrive/...
      bigloozip=`echo $bigloozip | sed -e "s/^\//$cygwindospath\\\\\\\\\\\\\\\\/"`   # corrects pathes like /usr...
      echo "CYGWINJVMPATH=-classpath \".;"`echo $bigloozip | sed -e 's/\//\\\\\\\\/g'`"\\\\bigloo_s.zip\"" >> $makefile_cfg
    else
      echo "CYGWINJVMPATH=" >> $makefile_cfg
    fi

    echo "JVMCLASSPATHSEP=\"$cpsep\"" >> $makefile_cfg
  else
    echo "" >> $makefile_cfg
    echo "JVMBACKEND=no" >> $makefile_cfg
  fi

fi

# Bigloo compilation flags
echo "" >> $makefile_cfg
echo "BFLAGS=$bflags" >> $makefile_cfg
echo "BOOTFLAGS=$bootflags" >> $makefile_cfg
echo "BFEATUREFLAGS=$featureflags" >> $makefile_cfg
if [ "$csflags " = " " ]; then
  echo "LDSTRIPFLAGS=" >> $makefile_cfg
else
  echo "LDSTRIPFLAGS=-ldopt $csflags" >> $makefile_cfg
fi

# script extension
echo "" >> $makefile_cfg
case $hostos in
  cygwin)
    echo "SCRIPTEXTENSION=.bat" >> $makefile_cfg;;
  *)
   echo "SCRIPTEXTENSION=" >> $makefile_cfg;;
esac

# C Object suffix
echo "C_OBJ_EXTENSION=$cobj" >> $makefile_cfg
echo >> $makefile_cfg

# APIs
echo "APIS=$apis" >> $makefile_cfg
echo "NOAPIS=" >> $makefile_cfg
echo >> $makefile_cfg

# Android specific
if [ "$hostos " = "android " ]; then
  echo "DROIDROOT=$droidroot" >> $makefile_cfg
  echo "DROIDSDKROOT=$droidsdkroot" >> $makefile_cfg
  echo >> $makefile_cfg
fi

#*---------------------------------------------------------------------*/
#*    Ok, we are done now                                              */
#*---------------------------------------------------------------------*/
bcke="native:yes"
if [ "$jvmbackend" = "yes" -o "$jvmbackend" = "force" ]; then
  bcke="$bcke JVM:yes"
else
  bcke="$bcke JVM:no"
fi
echo  >> $configurelog
echo  >> $configurelog
echo "** Configuration summary **" >> $configurelog
echo  >> $configurelog
echo "Release features:" >> $configurelog
echo "  Bigloo release number................. $release" >> $configurelog
echo "  Bigloo supported backends............. $bcke" >> $configurelog
echo "  Bigloo default backend................ $defaultbackend" >> $configurelog
echo "  APIs.................................. $apis" >> $configurelog
if [ $customgc = "yes" ];then
   echo "  Bigloo gc............................. custom ($gclib $gcversion)" >> $configurelog
else
   echo "  Bigloo gc............................. standard ($gclib $gcversion, $gcincdir, $gclibdir)" >> $configurelog
fi
if [ "$pthreadlibs" = "no" ]; then
  echo "  support for native threads............ no" >> $configurelog
else
  echo "  support for native threads............ yes" >> $configurelog
  if [ "$pthreadhastls " = "1 " ]; then
    echo "  support for thread local storage ..... yes" >> $configurelog
  else
    echo "  support for thread local storage ..... no" >> $configurelog
  fi
fi
if [ "$openssllibs" = "no" ]; then
  echo "  Open SSL support...................... no" >> $configurelog
else
  echo "  Open SSL support...................... yes (dtls:$openssldtls, v2:$opensslv2, v23:$opensslv23)" >> $configurelog
fi
if [ "$sqlitelibs " = " " ]; then
  echo "  Sqlite ............................... sqltiny" >> $configurelog
else
  echo "  Sqlite ............................... sqltiny + sqlite" >> $configurelog
fi
if [ "$ldopt" = "no-share" ]; then
  echo "  support for dynamic libraries......... no" >> $configurelog
else
  echo "  support for dynamic libraries......... yes" >> $configurelog
fi
echo "  Bee support........................... $bee" >> $configurelog
echo >> $configurelog
echo "Directories where Bigloo will be installed:" >> $configurelog
echo "  binaries.............................. $bindir" >> $configurelog
echo "  libraries............................. $libdir" >> $configurelog
echo "  files directory....................... $fildir" >> $configurelog
echo "  standard zip.......................... $zipdir" >> $configurelog
if [ "$syszipdir " != "$zipdir " ]; then
  echo "  standard zip (os dependent)........... $syszipdir" >> $configurelog
fi
echo "  standard dll.......................... $dlldir" >> $configurelog
if [ "$sysdlldir " != "$dlldir " ]; then
  echo "  standard dll (os dependent)........... $sysdlldir" >> $configurelog
fi
echo "  manual pages.......................... $mandir" >> $configurelog
echo "  info documentation.................... $infodir" >> $configurelog
echo "  lisp files............................ $lispdir" >> $configurelog
echo "  temporary dir......................... $buildtmp" >> $configurelog
echo >> $configurelog
echo "Compilers and linkers:" >> $configurelog
echo "  C compiler used....................... $cc" >> $configurelog
echo "  options for compiling................. $cflags" >> $configurelog
echo "  options for optimizing................ $coflags" >> $configurelog
echo "  options for stripping................. $csflags" >> $configurelog
echo "  options for PIC code.................. $cpicflags" >> $configurelog
echo "  options for profiling................. $cpflags" >> $configurelog
echo "  options for linking................... $extralibs" >> $configurelog
echo "  assembly.............................. $as" >> $configurelog
echo "  static library builder................ $ar" >> $configurelog
echo "  shared library builder................ $ld" >> $configurelog
echo "  options for building static libs...... $arflags" >> $configurelog
echo "  socket libraries...................... $socketlibs" >> $configurelog
echo "  gmp version........................... $gmpversion" >> $configurelog
echo "  pthread libraries..................... $pthreadlibs" >> $configurelog
echo "  openssl libraries..................... $openssllibs" >> $configurelog
echo "  sqlite libraries...................... $sqlitelibs" >> $configurelog
if [ "$ldopt" != "no-share" ]; then
  echo "  suffix of shared libraries............ $sharedsuffix" >> $configurelog
  echo "  options for linking with shared libs.. $ldopt" >> $configurelog
fi
echo "  dynamically linked compiler........... $sharedcompiler" >> $configurelog
echo "  dynamically linked bde tools.......... $sharedbde" >> $configurelog
echo >> $configurelog
if [ "$jvmbackend" = "yes" -o "$jvmbackend" = "force" ]; then
  echo "JVM:" >> $configurelog
  if [ "$hostos" = "cygwin" ]; then
    echo "  Cygwin dos path....................... $cygwindospath" >> $configurelog
  fi
  echo "  java default shell.................... $jshell" >> $configurelog
  echo "  javac................................. $javac" >> $configurelog
  echo "  options for compiling java............ $jcflags" >> $configurelog
  echo "  java.................................. $java" >> $configurelog
  echo "  options for running java.............. $jflags" >> $configurelog
  echo "  options no byte code verification..... $jvflags" >> $configurelog
  echo "  zip................................... $zip" >> $configurelog
  echo "  zip flags............................. $zflags" >> $configurelog
  echo "  jar................................... $jar" >> $configurelog
fi
echo >> $configurelog
echo "GC configuration:" >> $configurelog
if [ $customgc = "yes" ]; then
  echo "  options for compiling the collector... $cgcflags $cgcfinalflags $gcspecial" >> $configurelog
  echo "  options for compiling with threads.... $gcthread" >> $configurelog
else
  echo "  pre-installed standard GC............. $gclib" >> $configurelog
fi
echo >> $configurelog
echo "Emacs configuration:" >> $configurelog
echo "  emacs................................. $emacs" >> $configurelog
echo "  emacs brand........................... $emacsversion" >> $configurelog
if [ $emacsversion = "generic" ]; then
  echo "  lisp directory........................ no support (update emacs)" >> $configurelog
else
  echo "  lisp directory........................ $emacslisppath" >> $configurelog
fi
echo >> $configurelog
echo "Misc configuration:" >> $configurelog
echo "  mask for installed files.............. $modfile" >> $configurelog
echo "  mask for installed executable......... $modexe" >> $configurelog
echo "  mask for installed directories........ $moddir" >> $configurelog
echo  >> $configurelog
echo "System configuration:" >> $configurelog
echo "  hardware tuning....................... $hardtune" >> $configurelog
echo "  operating system...................... $hostos" >> $configurelog
echo "  default executable name............... $aout" >> $configurelog
echo  >> $configurelog

#*---------------------------------------------------------------------*/
#*    Post configure                                                   */
#*---------------------------------------------------------------------*/
if [ -x configure.postcmd ]; then
  echo "Post configuration setup...";
fi

#*---------------------------------------------------------------------*/
#*    Generate the config.status file for debian packages              */
#*---------------------------------------------------------------------*/
echo "configuration completed" > config.status

#*---------------------------------------------------------------------*/
#*    Ok, we are done now                                              */
#*---------------------------------------------------------------------*/
if [ "$summary" = "yes" ]; then
  echo
  echo
  echo "** Configuration summary **"
  echo
  echo "Release features:"
  echo "  release number.............. $release"
  echo "  supported backends.......... $bcke"
  echo "  default backend............. $defaultbackend"
  echo "  APIs........................ $apis"
  if [ "$pthreadlibs" = "no" ]; then
    echo "  native threads support...... no"
  else
    echo "  native threads support...... yes"
  fi
  if [ "$openssllibs" = "no" ]; then
    echo "  openssl support............. no"
  else
    echo "  openssl support............. yes (dtls:$openssldtls, v2:$opensslv2, v23:$opensslv23)"
  fi
  if [ "$sqlitelibs " = " " ]; then
    echo "  sqlite support ............. sqltiny"
  else
    echo "  sqlite support.............. sqltiny + sqlite"
  fi
  if [ "$ldopt" = "no-share" ]; then
    echo "  dynamic libraries support... no"
  else
    echo "  dynamic libraries support... yes"
  fi
  echo
  echo "Bee configuration:"
  echo "  bee support................. $bee"
  echo "  emacs....................... $emacs"
  echo "  emacs brand................. $emacsversion"
  echo
  echo "Implementation details:"
  echo "  tuning...................... $mode $tuning"
  echo "  cc.......................... $cc"
  if [ $customgc = "yes" ];then
     echo "  gc.......................... custom ($gclib-$release, v$gcversion)"
  else
     echo "  gc.......................... standard ($gclib, $gcincdir, v$gcversion)"
  fi
  if [ "$java_configured " = "yes " ]; then
    echo "  Java version................ $java_version"
  fi
  if [ "$gmpversion" = "no" ]; then
    echo "  bignum support.............. scheme implementation"
  else
    echo "  bignum support.............. gmp ($gmpversion)"
  fi
  echo
  echo "Directories where Bigloo will be installed:"
  echo "  binaries.................... $bindir"
  echo "  libraries................... $libdir"
  echo "  files directory............. $fildir"
  echo "  standard zip................ $zipdir"
  if [ "$syszipdir " != "$zipdir " ]; then
    echo "  standard zip (os dependent). $syszipdir"
  fi
  echo "  standard dll................ $dlldir"
  if [ "$sysdlldir " != "$dlldir " ]; then
    echo "  standard dll (os dependent). $sysdlldir"
  fi
  echo "  manual pages................ $mandir"
  echo "  info documentation.......... $infodir"
  echo "  lisp files.................. $lispdir"
  echo "  temporary build dir......... $buildtmp"
  echo
fi
