#!/bin/sh
#*=====================================================================*/
#*    serrano/prgm/project/bigloo/autoconf/gcflags                     */
#*    -------------------------------------------------------------    */
#*    Author      :  Manuel Serrano                                    */
#*    Creation    :  Thu Jan 14 10:31:33 1999                          */
#*    Last change :  Wed Jun  8 14:48:05 2005 (serrano)                */
#*    -------------------------------------------------------------    */
#*    Checking GC compilation flags                                    */
#*=====================================================================*/

#*---------------------------------------------------------------------*/
#*    flags                                                            */
#*---------------------------------------------------------------------*/
cc=gcc
cflags=""
tmp=/tmp
user=bigloo
posixos="unix"
cgcflags="-DSILENT -DNO_SIGNALS -DNO_DEBUGGING -Iinclude"

#*---------------------------------------------------------------------*/
#*    We parse the arguments                                           */
#*---------------------------------------------------------------------*/
while : ; do
  case $1 in
    "")
      break;;

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

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

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

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

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

    -*)
      echo "Unknown option \"$1\", ignored" >&2;;
  esac
  shift
done

#*---------------------------------------------------------------------*/
#*    On some archiecture (e.g., alpha, Mac PPC, etc.) cc -O3 option   */
#*    cannot be used otherwise call/cc crashes. I will have to figure  */
#*    out why. In the mean time, I use an ad-hoc configuration scheme. */
#*---------------------------------------------------------------------*/
case $posixos in
   linux)
     echo $cgcflags;;

   cygwin)
     echo $cgcflags;;

   mingw)
     echo "$cgcflags -DGC_BUILD -DGC_DLL -DGC_WIN32_THREADS -DNO_EXECUTE_PERMISSION -DALLINTERIOR_POINTERS -DATOMIC_UNCOLLECTABLE -D_REENTRANT ";;

   unix)
     case `uname -s` in
       Darwin*|darwin*)
         echo "$cgcflags -DGC_DARWIN_THREADS";;

       *)
         echo $cgcflags;;
     esac;;

   *)
     echo $cgcflags;;
esac

exit 0
