#! /bin/sh

#
# Retrieve configuration parameters
#
# $Id: gauche-config.in,v 1.22 2003/10/04 21:29:36 shirok Exp $
#

prefix=${prefix:-/usr}
exec_prefix=${prefix}

cc="gcc"

datadir=${prefix}/share/gauche
archdir=${exec_prefix}/lib/gauche

gauche_incdir="$archdir/0.8.3/include"
gauche_libdir="$datadir/0.8.3/lib"
gauche_aclocaldir="$datadir/0.8.3/"
gauche_archdir="$archdir/0.8.3/arm-unknown-linux-gnu"
gauche_siteincdir="$archdir/site/include"
gauche_sitelibdir="$datadir/site/lib"
gauche_sitearchdir="$archdir/site/0.8.3/arm-unknown-linux-gnu"
gauche_mandir="${prefix}/share/man"
gauche_infodir="${prefix}/share/info"
gauche_version="0.8.3"
gauche_libs="-ldl -lcrypt -lutil -lm  -lpthread"
gauche_configure_args="'--host=arm-linux' '--build=arm-linux' '--prefix=/usr' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--enable-multibyte=utf-8' '--enable-ipv6' '--enable-threads=pthreads' '--with-slib=/usr/share/slib' 'CC=gcc' 'build_alias=arm-linux' 'host_alias=arm-linux'"
arch="arm-unknown-linux-gnu"

local_incdir=""
local_libdir=""

default_cflags="-g -O2"

object_suffix="o"
executable_suffix=""
shlib_so_suffix="so"
shlib_so_cflags="-fPIC"
shlib_so_ldflags=" -shared -o"
shlib_so_libs=""
shlib_dylib_suffix="so"
shlib_dylib_ldflags=" -shared -o"
shlib_main_ldflags="-rdynamic"
libgauche_so="libgauche.so"

usage () {
    cat <<EOF
Usage: gauche-config [option]

General parameter
  -V   the current gauche version

Parameters to compile an application using Gauche
  -I   include paths required to compile programs using gauche
  -L   library paths required to link programs using gauche
  -l   libraries required to link programs using gauche
  --cc name of the compiler
  --ac directory that contains Gauche specific autoconf macro
  --reconfigure
       prints the command line used to configure the current
       installation.
  --arch
       prints the architecture signature

Parameters to install files
  --syslibdir/--sitelibdir
       directories where system/site scheme files go
  --sysarchdir/--sitearchdir
       directories where system/site DSO files go
  --sysincdir/--siteincdir
       directories where system/site header files of extensions go
  --mandir/--infodir
       directories where gauche manpage and info docs are installed

Parameters to help building extensions
  --object-suffix
       Returns extension of the compiled objects (e.g. "o")
  --executable-suffix
       Returns extension of the executable (mostly empty, sometimes ".exe")
  --so-suffix
       Suffix for dynamically loadable (dlopen-able) modules
  --so-cflags
       CFLAGS to create dynamically loadable modules
  --so-ldflags
       LDFLAGS to create dynamically loadable modules
  --so-libs
       Required libraries to create dynamically loadable modules
  --dylib-suffix
       Suffix for dynamically linked libraries
  --dylib-ldflags
       LDFLAGS to create dynamically linked libraries
  --fixup-extension FILE [MODULE]
       creates FILE_head.c and FILE_tail.c.  They are required for GC
       to work properly on some platforms.  MODULE must be the extension
       module's name, and has to match the name given to the
       SCM_INIT_EXTENSION macro in the extension initialization code. 
       If MODULE is omitted, FILE is used as the module's name.
EOF
    exit 1
}

case $1 in
  -V) echo $gauche_version;;
  -I) echo "-I$gauche_incdir $local_incdir";;
  -L) echo "-L$gauche_archdir $local_libdir";;
  -l) echo "-lgauche $gauche_libs";;
  --cc) echo $cc;;
  --ac) echo $gauche_aclocaldir;;
  --reconfigure) echo ./configure $gauche_configure_args;;

  --sysincdir)   echo $gauche_incdir;;
  --siteincdir)  echo $gauche_siteincdir;;
  --syslibdir)   echo $gauche_libdir;;
  --sitelibdir)  echo $gauche_sitelibdir;;
  --sysarchdir)  echo $gauche_archdir;;
  --sitearchdir) echo $gauche_sitearchdir;;
  --mandir)      echo $gauche_mandir;;
  --infodir)     echo $gauche_infodir;;
  --arch)        echo $arch;;

  --local-incdir) echo $local_incdir;;
  --local-libdir) echo $local_libdir;;

  --default-cflags) echo $default_cflags;;

  --object-suffix) echo "$object_suffix";;
  --executable-suffix) echo "$executable_suffix";;
  --so-suffix) echo $shlib_so_suffix;;
  --so-cflags) echo $shlib_so_cflags;;
  --so-ldflags) echo $shlib_so_ldflags;;
  --so-libs)    echo $shlib_so_libs;;
  --dylib-suffix) echo $shlib_dylib_suffix;;
  --dylib-ldflags) echo $shlib_dylib_ldflags;;
  --libgauche-so) echo $libgauche_so;;

  --fixup-extension)
     file=$2
     module=$3
     if test X$file = X; then usage; fi
     if test X$module = X; then module=`echo $file | tr -c "\012A-Za-z0-9" "_"`; fi
     echo "void *Scm__datastart_$module = (void*)&Scm__datastart_$module;" > ${file}_head.c
     echo "void *Scm__bssstart_$module;" >> ${file}_head.c
     echo "void *Scm__dataend_$module = (void*)&Scm__dataend_$module;" > ${file}_tail.c
     echo "void *Scm__bssend_$module;" >> ${file}_tail.c
     ;;
  *)  usage;;
esac

# Local variables:
# mode: shell-script
# end:
