dnl  ********************************************************************
dnl BEGIN LICENSE BLOCK
dnl Version: CMPL 1.1
dnl
dnl The contents of this file are subject to the Cisco-style Mozilla Public
dnl License Version 1.1 (the "License"); you may not use this file except
dnl in compliance with the License.  You may obtain a copy of the License
dnl at www.eclipse-clp.org/license.
dnl 
dnl Software distributed under the License is distributed on an "AS IS"
dnl basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
dnl the License for the specific language governing rights and limitations
dnl under the License. 
dnl 
dnl The Original Code is  The ECLiPSe Constraint Logic Programming System. 
dnl The Initial Developer of the Original Code is  Cisco Systems, Inc. 
dnl Portions created by the Initial Developer are
dnl Copyright (C) 1994-2006 Cisco Systems, Inc.  All Rights Reserved.
dnl 
dnl Contributor(s): Kees Schuerman, ECRC
dnl 
dnl END LICENSE BLOCK
dnl  ********************************************************************
dnl       System: Parallel Distributed System
dnl         File: configure.in
dnl       Author: Kees Schuerman
dnl       SccsId: "@(#)configure.in	1.31 24 Nov 1995"
dnl  Description: Configuration
dnl		  Process this file with autoconf to produce a configure
dnl		  script.
dnl  ********************************************************************

if test -z "$ARCH" || test "$ARCH" = "unknown"; then
    echo please set the environment variable ARCH
    exit
fi

AC_INIT(pds_env.c)
AC_CONFIG_HEADER(machine.h)

unset PROJECTDIR
if test -z "$SYS_DIR"; then
    SYS_DIR="`pwd`/../.."
fi
if test -z "$SHM_DIR"; then
    SHM_DIR="`pwd`/../../sepia"
fi
if test -z "$USC_DIR"; then
    USC_DIR="`pwd`/../../usc"
fi
if test -z "$ALOG_DIR"; then
    ALOG_DIR="`pwd`/../../alog"
fi



#
# UNIX variants
#
CC=cc
DFLAGS="-DTRUSTED -DNDEBUG -DINTERRUPT_SAFE -DBMSGLOG -DAMSGLOG -DALOG_TRACE"
CFLAGS="-O"
case "$ARCH" in
 sun3)
    ;;
 sun4)
    ;;
 supersparc_sunos4)
    CC=gcc
    CFLAGS="-msupersparc -O2"
    ;;
 sparc_svr4)
    LIBS="-lsocket -lnsl $LIBS"
    ;;
 sparc_sunos5)
    CC=gcc
    CFLAGS="-O2"
    LIBS="-lsocket -lnsl $LIBS"
    ;;
 sparc_sunos5_cc)
    ;;
 supersparc_sunos5)
    CC=gcc
    CFLAGS="-msupersparc -O2"
    LIBS="-lsocket -lnsl $LIBS"
    ;;
 i386_sunos5)
    LIBS="-lsocket -lnsl $LIBS"
    ;;
 i386_linux)
    LIBS="-lieee $LIBS"
    ;;
 rs_aix32)
    CC=gcc
    CFLAGS="-fsigned-char -O2"
    ;;
 rs_aix32_cc)
    CC=cc
    CFLAGS="-qchars=signed -O"
    ;;
 rs_aix41)
    CC=gcc
    CFLAGS="-fsigned-char -O2"
    ;;
 hp700_ux90)
    CC=gcc
    CFLAGS="-O2"
    ;;
 spp_ux90)
    CC=gcc
    CFLAGS="-O2"
    ;;
 sgi_irix52)
    CFLAGS="-signed -O -mips2"
    ;;
 m88k_svr4)
    LIBS="-lsocket -lnsl $LIBS"
    ;;
 alpha_osf32)
    CC=cc
    CFLAGS="-O2 -taso"
    ;;
 alpha_linux)
    CC=gcc
    CFLAGS="-mieee -O2"
    ;;
 *)
    echo Unknown architecture
    exit
    ;;
esac



#
# Compiler characteristics
#
dnl Check for const
AC_CONST
dnl Check for volatile
AC_COMPILE_CHECK([volatile],
[] , [volatile int i;], [], AC_DEFINE(volatile,))
dnl Check for void pointers
AC_COMPILE_CHECK([void pointers],
[] , [void *p;], [], AC_DEFINE(HAVE_NO_VOID_PTR))
AC_TEST_PROGRAM([
int main() {exit(!(sizeof(char*)==8));}], AC_DEFINE(PTR_64_BITS))
AC_CHECK_SIZEOF(int,4)
AC_CHECK_SIZEOF(long,4)
AC_CHECK_SIZEOF(char *,4)
AC_C_CHAR_UNSIGNED


#
# Processor Specifics
#
dnl Check for big-endians
AC_WORDS_BIGENDIAN



#
# System services
#

#
# Check if we can get a signal when data is ready
#
# BSD
AC_COMPILE_CHECK(bsd_sigio, [#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>], [
int i, fd;
(void) fcntl(fd, F_SETOWN, getpid());
i = fcntl(fd, F_GETFL, 0);
(void) fcntl(fd, F_SETFL, i | FASYNC);
], AC_DEFINE(SIGIO_FASYNC) vsigio=1)
if test -z "$vsigio"; then
#HP-UX
AC_COMPILE_CHECK(hp_ux_sigio, [#include <sys/types.h>
#include <sys/ioctl.h>], [
int i, fd, pid;
pid = (int) getpid();
(void) ioctl(fd, SIOCSPGRP, &pid);
i = 1;
(void) ioctl(fd, FIOASYNC, &i);
], AC_DEFINE(SIGIO_FIOASYNC) vsigio=1)
fi
if test -z "$vsigio"; then
#SVR4
AC_COMPILE_CHECK(sigpoll, [#include <sys/types.h>
#include <stropts.h>
#include <sys/conf.h>], [
int i, fd;
i = ioctl(fd, I_SETSIG, S_RDNORM|S_RDBAND|S_HIPRI|S_BANDURG);
], AC_DEFINE(SIGIO_SETSIG) vsigio=1)
fi
if test -z "$vsigio"; then
echo "...SIGIO not available"
fi



#
# Programs
#
dnl Check if ranlib exists
if test -z "$RANLIB"; then
  # Extract the first word of `ranlib', so it can be a program name with args.
  set dummy ranlib; word=$2
  echo checking for $word
  IFS="${IFS=   }"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      RANLIB="ranlib"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$RANLIB" && RANLIB="true"
test -n "$RANLIB" && test -n "$verbose" && echo "       setting RANLIB to $RANLIB"


AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(DFLAGS)
AC_SUBST(ARCH)
AC_SUBST(LIBS)
AC_SUBST(RANLIB)
AC_SUBST(SHM_DIR)
AC_SUBST(USC_DIR)
AC_SUBST(ALOG_DIR)
AC_SUBST(SYS_DIR)

AC_OUTPUT(Makefile)
