dnl Process this file with autoconf to produce a configure script.
AC_INIT(Makefile.in)

if test -z "$MOSHOME"
then
MOSHOME=`pwd`/../mosaic
fi

AC_ARG_WITH(neko,dnl
  --with-neko=PATH             nekosoft path
, MOSHOME=$with_neko)
AC_SUBST(MOSHOME)

AC_CHECK_FILES($MOSHOME/00README.neko,
,AC_MSG_ERROR(nekosoft not found. Set \$MOSHOME or use --with-neko= option.))

SDFREDHOME=`pwd/..`
AC_ARG_WITH(sdfred,dnl
  --with-sdfred=PATH             nekosoft path
, SDFREDHOME=$with_sdfred)
AC_SUBST(SDFREDHOME)

AC_PROG_MAKE_SET 



dnl Checks for programs.
AC_PROG_CC

if test -z "$CC"; then
	GCC=""
fi
	
AC_PROG_RANLIB
AC_PROG_MAKE_SET
AC_PROG_AWK

###

AC_PATH_PROG(SHELL,sh bash ksh)
AC_SUBST(SHELL)

AC_PATH_PROG(CSHELL,csh tcsh)
AC_SUBST(CSHELL)

AC_PATH_PROG(PERLPATH,perl)
AC_SUBST(PERLPATH)


AC_PATH_PROG(IRAFPATH,cl)
AC_PATH_PROG(IRAFPATH2,mkiraf)

## IRAF VERSION CHECK  (not impl.)

AC_PATH_PROG(SEXTRACTORPATH,sex)
## SEx VERSION CHECK  (not impl.)

dnl Checks for libraries.
AC_CHECK_LIB(m, sin)

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM

AC_TRY_COMPILE([#include <math.h>],[double p=M_PI;])
AC_CANONICAL_SYSTEM

AC_CHECK_SIZEOF(int ,4) 

SET_GCC=""

case "$host_os" in
hpux*)
    if test -z "$GCC"; then
      CFLAGS="$CFLAGS -Ae"
    fi
    ;;
sunos*|sol*)
    if test -n "$GCC" ; then
      SET_GCC="CC=$CC"
    fi
    ;;
*)
    :
    ;;
esac
AC_SUBST(SET_GCC)

dnl Checks for library functions.
AC_CHECK_FUNCS(mktime strstr strtod)

dnl MEMORY SIZE

dnl Checks for endian.
AC_C_BIGENDIAN
AC_TRY_COMPILE(,int a=WORDS_BIGENDIAN,,CFLAGS="$CFLAGS -DBYTE_REORDER")

CFLAGS="$CFLAGS "
## '-I$(IMC) -I$(MOSINC) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
## CFLAGS="$CFLAGS "'-I$(IMC) -I$(MOSINC)'
## CFLAGS="-ansi -pedantic -Wall $CFLAGS"
AC_SUBST(CFLAGS)

#AC_CHECK_FUNCS(fseeko, LARGEFILE="-DHAVE_FSEEKO")
#AC_CHECK_SIZEOF(off_t) 
#AC_SUBST(LARGEFILE)

AC_OUTPUT(Makefile)
