https://github.com/teuben/nemo
Raw File
Tip revision: f7beac931bf9caefb1a620ade43d0a72b47b9720 authored by Jean Charles Lambert on 16 July 2009, 08:20:52 UTC
update copyright
Tip revision: f7beac9
configure.ac
dnl configure.ac:
dnl Process this file with autoconf to produce a new configure script
dnl if it has changed. See also the Makefile in $NEMO  how to automate
dnl this.
dnl http://www-106.ibm.com/developerworks/linux/library/l-debcon.html
dnl ---------------------------------------------------------------------------------

AC_MSG_CHECKING([NEMO config])

AC_INIT(NEMORC)

AC_CONFIG_HEADER([config.h:config.h.in])

dnl -- checks for programs
dnl -- checks for libraries
dnl -- checks for header files
dnl -- checks for typedefs
dnl -- checks for structures
dnl -- checks for compiler characteristics
dnl -- checks for library functions
dnl -- checks for system services


dnl ---			NEMO base directory
NEMO="`pwd`"
NEMOHOST="`./config.guess`"
NEMO_LIBS=""
NEMO_CFLAGS=""
NEMO_FFLAGS=""
AC_SUBST(NEMO)
AC_SUBST(NEMOHOST)
AC_SUBST(NEMO_LIBS)
AC_SUBST(NEMO_CFLAGS)
AC_SUBST(NEMO_FFLAGS)

dnl -- 			warning stuff
AC_SUBST(WARNING)
WARNING="Do not edit this file, it has been generated by configure"

dnl ---			Nemo version - just for fun for now
NEMOVER="`cat VERSION`"
AC_SUBST(NEMOVER)

dnl ---                 Create needed libraries for next step
for i in bin lib obj local; do
 if ! test -e $i ; then
   mkdir $i
 fi
done

dnl ----                Architecture stuff we need to know
AC_CANONICAL_HOST
echo "Found CANONICAL_HOST = $host_os"
  
dnl ---                 sizeof various data types
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
AC_CHECK_SIZEOF(long double)
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)


AC_HEADER_STDC
AC_CHECK_FUNCS(strchr memcpy)

dnl AC_PROG_CPP

dnl Use native cc if present
AC_MSG_CHECKING([for vendor's cc to be used instead of gcc])
AC_CHECK_PROG(CC, cc, cc)

AC_PROG_CC
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB

AC_ARG_PROGRAM

AC_CHECK_PROGS(MAKE, [gmake make])
if test x"${MAKE}" = x
then
    AC_MSG_ERROR([cannot find a make utility])
else
    AC_MSG_CHECKING([whether ${MAKE} is GNU Make])
    if ${MAKE} --version 2>/dev/null | head -n 1 |
       grep "GNU Make" >/dev/null
    then
        AC_MSG_RESULT([yes])
    else
        AC_MSG_RESULT([no])
        AC_MSG_ERROR([GNU Make is required, but ${MAKE} is
                      different])
    fi
fi

AC_ARG_ENABLE(debug, [  --enable-debug          compile for debugging], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
        CFLAGS="-g"
        CXXFLAGS="-g"
        FFLAGS="-g"
        LDFLAGS="-g"
        # should we define DEBUG too?
fi

AC_ARG_ENABLE(pedantic, [  --enable-pedantic       compile for pedantic gcc], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
  flags="ansi -pedantic -Werror -Wall -W -Wmissing-prototypes -Wstrict-prototypes"
  flags="$flags -Wtraditional -Wconversion -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align"
  flags="$flags -Wwrite-strings -Wnested-externs -fshort-enums -fno-common -Dinline= -g -O4"
  CFLAGS="$CFLAGS $flags"
  CXXFLAGS="$CXXFLAGS $flags"
  FFLAGS="$CFLAGS $flags"
fi

AC_MSG_CHECKING(which precision NEMO is going to use)
prec_flag=""
AC_ARG_ENABLE(single, [  --enable-single         single-precision], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
	prec_flag="-DSINGLEPREC"
fi
AC_ARG_ENABLE(float,  [  --enable-float          single-precision], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
	prec_flag="-DSINGLEPREC"
fi
AC_ARG_ENABLE(double, [  --enable-double         double-precision], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
	prec_flag="-DDOUBLEPREC"
fi
AC_ARG_ENABLE(mixed,  [  --enable-mixed          mixed-precision], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
	prec_flag="-DMIXEDPREC"
fi
AC_MSG_RESULT([$prec_flag])


AC_MSG_CHECKING(if the gnu coverage tool is to be used)
gcov_flag=""
AC_ARG_ENABLE(gcov,  [  --enable-gcov           gnu coverage tool], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
	gcov_flag="-fprofile-arcs -ftest-coverage"
fi
AC_MSG_RESULT($ok)


AC_ARG_ENABLE(lfs,  [  --enable-lfs            large-file-size (files over 2GB)], ok=$enableval, ok=yes)
if test "$ok" = "yes"; then
  CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
  echo "LFS selected, note that some filesystems may not support Large File anyways"
  echo "Test this with the NEMO command:"
  echo "     mkspiral s000 1000000 nmodel=40"
else
  echo "LFS not selected, be aware the largest filesize may be just 2GB"
fi


dnl check FFTW configure
AC_ARG_ENABLE(fortran,[  --disable-fortran       don't use any Fortran], enable_fortran=$enableval, enable_fortran=yes)

AC_ARG_WITH(mesa, [  --with-mesa             force the use of Mesa instead of other graphics libs], with_mesa=$withval, with_mesa=maybe)
AC_ARG_WITH(hdf,  [  --with-hdf              force the use of HDF], with_hdf=$withval, with_hdf=maybe)
AC_ARG_WITH(ccmalloc, 
		  [  --with-ccmalloc         use CCMALLOC for malloc], with_malloc=$withval, with_ccmalloc=no)

dnl ---------------------------------------------------------------------
dnl             Check for basic X windows stuff
AC_PATH_X
AC_PATH_XTRA
XINCS="$X_CFLAGS"
if test -d /usr/X11R6/lib64; then
  XLIBS="$X_LIBS $X_PRE_LIBS -L/usr/X11R6/lib64 -lXext -lX11 $X_EXTRA_LIBS"
else
  XLIBS="$X_LIBS $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS"
fi
AC_SUBST(XLIBS)
AC_SUBST(XINCS)

dnl ---------------------------------------------------------------------
dnl 3D Graphics Libraries (see also vis5d's configure.in)
dnl Or:  AX_CHECK_GL
dnl      AX_CHECK_GLU
dnl      AX_CHECK_GLUT

GLLIBS=""

# First, look for OpenGL or Mesa:
if test "$with_mesa" != "yes"; then
        AC_CHECK_LIB(GL, glBegin,
            AC_CHECK_LIB(GLU, gluProject, GLLIBS="-lGLU -lGL",
                         :, -lGL $XLIBS), :, $XLIBS)
fi
if test -z "$GLLIBS" -a "$with_mesa" != "no"; then
        AC_CHECK_LIB(MesaGL, glBegin,
            AC_CHECK_LIB(MesaGLU, gluProject, GLLIBS="-lMesaGLU -lMesaGL",
                         :, -lMesaGL $XLIBS), :, $XLIBS)
fi
if test "$with_mesa" = "yes"; then
        AC_CHECK_LIB(GL, glBegin,
            AC_CHECK_LIB(GLU, gluProject, GLLIBS="-lGLU -lGL",
                         :, -lGL $XLIBS), :, $XLIBS)
fi
if test -n "$GLLIBS"; then
        AC_DEFINE(HAVE_OPENGL)
else
        echo "couldn't find OpenGL libraries!"
        if test "$with_mesa" = "yes"; then
                AC_MSG_ERROR([couldn't find Mesa library])
        fi
fi

# Next, look for SGI IrisGL:
if test -z "$GLLIBS"; then
        AC_CHECK_LIB(gl_s, bgnqstrip, ok=yes,ok=no, $XLIBS)
        if test "$ok" = "yes"; then
                AC_CHECK_LIB(fm, fminit, GLLIBS="-lfm -lgl_s",:,-lgl_s $XLIBS)
                if test -z "$GLLIBS"; then
                        AC_CHECK_LIB(fm_s, fminit, 
                                GLLIBS="-lfm_s -lgl_s",:,-lgl_s $XLIBS)
                fi
        fi
        if test -n "$GLLIBS"; then
                AC_DEFINE(HAVE_SGI_GL)
                OPT_UTILS="$OPT_UTILS listfonts"
        fi
fi
# Finally, look for PEX (crufty old 3d extensions for X):
# (do these even work in Vis5d anymore?)
if test -z "$GLLIBS"; then
        # first, check for possible include & lib directory locations:
        if test -d /usr/lib/PEX5/utilities; then
                CPPFLAGS="$CPPFLAGS -I/usr/lib/PEX5/utilities"
        elif test -d /opt/graphics/PEX5/include/X11R6; then
                CPPFLAGS="$CPPFLAGS -I/opt/graphics/PEX5/include/X11R6"
        fi
        if test -d /opt/graphics/PEX5/lib; then
                LDFLAGS="$LDFLAGS -L/opt/graphics/PEX5/lib"
        fi

        # now, check for the actual library:
        save_LDFLAGS="$LDFLAGS"; LDFLAGS="$LDFLAGS $X_LIBS"
        AC_CHECK_LIB(PEX5, PEXInitialize, GLLIBS="$X_LIBS -lPEX5", :, $XLIBS)
        LDFLAGS="$save_LDFLAGS"

        if test -n "$GLLIBS"; then
                # finally, look for the pexut.a library
                AC_MSG_CHECKING([for pexut.a library])
                if test -z "$PEXUT_LIB"; then
                        if test -r /usr/lib/PEX5/utilities/pexut.a; then
                                PEXUT_LIB="/usr/lib/PEX5/utilities/pexut.a"
                        elif test -r /var/opt/PEX5/pexut.a; then
                                PEXUT_LIB="/var/opt/PEX5/pexut.a"
                        fi
                fi
                AC_MSG_RESULT(${PEXUT_LIB-no})
                if test -z "$PEXUT_LIB"; then
                        AC_MSG_WARN([pexut.a is required when using PEX])
                        GLLIBS=""
                elif test -r "$PEXUT_LIB"; then
                        GLLIBS="$PEXUT_LIB $GLLIBS"
                else
                        # this could happen if the user specified a bogus
                        # PEXUT_LIB environment variable:
                        AC_MSG_ERROR([$PEXUT_LIB is not readable])

                fi
        fi

        if test -n "$GLLIBS"; then
                AC_DEFINE(HAVE_PEX)
        fi
fi

if test -z "$GLLIBS"; then
        echo "****************************************************"
        echo "You need to install a 3D graphics library, preferably"
        echo "the free OpenGL replacement, Mesa.  You can download"
        echo "Mesa from the Mesa home page:"
        echo "              http://www.mesa3d.org/"
        echo "and install it by running:"
        echo "       ./configure && make && su -c 'make install'"
        echo "in the Mesa directory."

        if test -r /sbin/ldconfig; then
                echo "You may also need to run /sbin/ldconfig as root"
                echo "to update the system after installing Mesa."
                if test -r /etc/ld.so.conf; then
                if test -z "`grep /usr/local/lib /etc/ld.so.conf`"; then
                echo "(First, add '/usr/local/lib' to /etc/ld.so.conf if"
                echo "you installed Mesa under /usr/local, the default.)"
                fi
                fi
        fi
        echo "****************************************************"
dnl        AC_MSG_ERROR([couldn't find 3D graphics library])
fi
AC_SUBST(GLLIBS)

dnl -- Check for any particular functions in the GL libs:
save_LIBS="$LIBS"
LIBS="$GLLIBS $XLIBS $LIBS"
AC_CHECK_FUNCS(XMesaGetBackBuffer)
LIBS="$save_LIBS"

dnl ---------------------------------------------------------------------

dnl also check FFTW configure
dnl TODO: allow to choose a compiler, e.g. --with-fortran=f90   (setenv F77)

if test "$enable_fortran" = "yes"; then
  AC_MSG_CHECKING(whether we have a FORTRAN 77 compiler)
  AC_CHECK_PROGS(F77, f77 g77 gfortran g95 ifort ifc xlf xlf77 fl32 fort77 fc cf77 frt f90 xlf90)
  AC_PROG_F77
  if test -n "$F77"; then
    if test -n "$GCC"; then
      AC_F77_LIBRARY_LDFLAGS
      ACX_F77_FUNC_MANGLE
      case $host_os in
        ultrix*)
          CC="$CC -Dmain=MAIN_"
          ;;
        osf*)
          CC="$CC -Dmain=MAIN__"
          ;;
        sunos*)
          CC="$CC -Dmain=MAIN_"
          ;;
      esac
    fi
  else
    F77="echo"
    fortran=no
    AC_MSG_WARN([no FORTRAN compiler])
  fi
else
  F77="echo"
  fortran=no
  AC_MSG_WARN([no FORTRAN compiler])
fi

dnl Fortran/C linkeage : defines F77_CMAIN_FFLAGS
ACX_F77_CMAIN_FFLAGS([],[AC_MSG_WARN([problems fortran-c interface])])

dnl Fortran binary I/O has a 4 or 8 byte header the unfio library needs to know
AC_MSG_CHECKING(size of unformatted fortran I/O header/footer)
$F77 -o src/kernel/fortran/hdr_size src/kernel/fortran/hdr_size.f
src/kernel/fortran/hdr_size
$CC  -o src/kernel/fortran/hdr_size src/kernel/fortran/hdr_size.c
UNFIO_HDR_SIZE=`src/kernel/fortran/hdr_size one.dat`
AC_MSG_RESULT([$UNFIO_HDR_SIZE])
AC_DEFINE_UNQUOTED(UNFIO_HDR_SIZE,$UNFIO_HDR_SIZE,[Fortran unformatted I/O header size])


dnl MacOS (darwin) needs -lcc_dynamic, might need /sw stuff from FINK
dnl Only linux wants -rdynamic, for dlopen()
if test "$GCC" = "yes"; then
  NEMO_CFLAGS="$NEMO_CFLAGS $gcov_flag"
fi
NEMO_CFLAGS="$NEMO_CFLAGS $prec_flag"

AC_SUBST(CCSHARED)
CCSHARED="-fpic"
AC_SUBST(MACOS_LIBS)
MACOS_LIBS=""
AC_MSG_CHECKING(what flags we need to created shared libs)

case $host_os in
  linux*|Linux*)
    CCSHARED="-fpic"
    if test "$GCC" = "yes"; then
       NEMO_CFLAGS="$NEMO_CFLAGS -rdynamic" 
    fi				   
    ;;
  darwin*)
    CCSHARED="-fPIC -fno-common"
#    MACOS_LIBS="-lcc_dynamic -L/sw/lib"
    MACOS_LIBS="-L/sw/lib"
    NEMO_CFLAGS="$NEMO_CFLAGS -I/sw/include"
    ;;
  sol*)
#   -PIC ??
    CCSHARED="-KPIC"
    ;;
esac
AC_MSG_RESULT([$CCSHARED])



dnl --
dnl helper library for PGPLOT

AC_ARG_ENABLE(png, [  --enable-png            force the use of PNG for pgplot], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
   PNG_LIB="-lpng -lz"
else
   PNG_LIB=""
fi
AC_SUBST(PNG_LIB)



dnl ---------------------------------------------------------------------------
dnl PGPLOT detection: (NEMO allows PGPLOT to be built internally in $NEMO/lib)
dnl if $PGPLOT_DIR exists, take that as the default
dnl else, check a few standard places
dnl if all that fails and --with-pgplot-prefix is also not good, bail out.
dnl Known problems: if you have a local pgplot that needs odd libaries, e.g. -lpng 
dnl                 although the -lpng problem is now solved

AC_SUBST(PGPLOT_DIR)
AC_MSG_CHECKING(whether we have PGPLOT)
if test -d "$PGPLOT_DIR"; then
    pgplot_dir="$PGPLOT_DIR"
    AC_MSG_RESULT([yes, found \$PGPLOT_DIR=$PGPLOT_DIR])
else
    for dir in lib /usr/lib/pgplot /usr/local/lib/pgplot /usr/local/pgplot /opt/pgplot 
    do
        if test -f $dir/grfont.dat; then
            pgplot_dir="$dir"
            break;
        fi
    done
fi
AC_ARG_WITH(pgplot-prefix, 
        [  --with-pgplot-prefix=DIR   Directory where PGPLOT was installed, aka PGPLOT_DIR], 
        pgplot_config_prefix="$withval", 
        pgplot_config_prefix="$pgplot_dir")

yapp_default="ps"
if test x$pgplot_config_prefix != x; then
        if ! test -f ${pgplot_config_prefix}/grfont.dat ; then
                AC_MSG_WARN([could not find PGPLOT library in $pgplot_dir yet])
        fi
	PGPLOT_DIR="$pgplot_config_prefix"
        PGPLOT_INCLUDE="-I$pgplot_config_prefix"
        PGPLOT_LIB="-L$pgplot_config_prefix"
        PGPLOT_LIB="$PGPLOT_LIB -lcpgplot -lpgplot $PNG_LIB"
        AC_DEFINE(HAVE_LIBPGPLOT) 
        AC_MSG_RESULT([yes, $PGPLOT_DIR])
	yapp_default="pgplot"
else
	AC_MSG_WARN([could not find PGPLOT library in 2nd: $pgplot_config_prefix])
fi

dnl ---------------------------------------------------------------------

dnl check if we have the Fortran (sigh) idate function:  == doesn't work == 
dnl == doesn't work - confusion with pgplot stuff ==

dnl if test -n "$F77"; then
dnl         AC_LANG_SAVE
dnl         AC_LANG_FORTRAN77
dnl         AC_MSG_CHECKING([for Fortran idate function])
dnl         AC_TRY_LINK(,[idate(imon,iday,iyear)],[AC_DEFINE(HAVE_IDATE)
dnl                 AC_MSG_RESULT(yes)],AC_MSG_RESULT(no))
dnl         AC_LANG_RESTORE
dnl fi        

dnl ---------------------------------------------------------------------

LOADOBJ_MACH=""
LOADOBJ_LIBS=""

echo "Trying to find LOADOBJ options for $host_os ; host=$host"

case $host_os in
      linux*)
	LOADOBJ_MACH="-Dlinux -DSYSV"
	LOADOBJ_LIBS=-ldl
	;;
      solaris*)
	LOADOBJ_MACH="-Dsun4 -DSOLARIS -DSYSV"
	LOADOBJ_LIBS=-ldl
	;;
      darwin*)
	LOADOBJ_MACH="-Ddarwin -DDL"
	LOADOBJ_LIBS=-ldl
        ;;
      irix*)
	;;
esac

AC_SUBST(LOADOBJ_MACH)
AC_SUBST(LOADOBJ_LIBS)

#
# Find math library, and add ccmalloc support if needed
#
MATH_LIBS=''
AC_CHECK_LIB(m,sqrt,MATH_LIBS="-lm",,)

if test "$with_ccmalloc" = "yes"; then
  MATH_LIBS="-lccmalloc $MATH_LIBS"
fi
AC_SUBST(MATH_LIBS)

dnl ---------------------------------------------------------------------


AC_MSG_CHECKING(whether we have HDF)
AC_ARG_WITH(hdf-prefix, 
        [  --with-hdf-prefix=PFX     Prefix where HDF was installed], 
        hdf_config_prefix="$withval", 
        hdf_config_prefix="/usr/local")
dnl			this assumes people will use include <hdf.h>, not <hdf/hdf.h>
hdf=$hdf_config_prefix
for dir in $hdf $hdf/include $hdf/hdf $hdf/include/hdf
    do
	if test -f $dir/hdf.h; then
		HDF_INC="-I$dir"
		break;
	fi
    done

if test "X$HDF_INC" != "X"; then
    HDF_LIB="-L$hdf/lib -ldf -ljpeg -lz"
    AC_DEFINE(HAVE_HDF)
    AC_MSG_RESULT([yes: hdf4, $HDF_INC])
else
    HDF_INC=""
    HDF_LIB=""
    AC_MSG_RESULT(no)
    AC_MSG_WARN([could not find HDF library])
fi   

AC_SUBST(HDF_INC)
AC_SUBST(HDF_LIB)

dnl##--------------------------------------------------------------------
dnl   Could also check FTOOLS_INCLUDE and/or FTOOLS_DIR for cfitsio....
dnl   Note again, there are two ideas on where to store CFITSIO:
dnl     library in PREFIX/lib 
dnl     header  in PREFIX/include or PREFIX/include/cfitsio
dnl   This section also allows --with-cfitsio-prefix to point to the 
dnl   source code tree, since that is where the *.a and *.h files live


AC_ARG_ENABLE(cfitsio, [  --enable-cfitsio        use CFITSIO, instead of local fits I/O routines], ok=$enableval, ok=no)

if test "$ok" = "yes"; then

  AC_MSG_CHECKING(whether we have CFITSIO)

  cfdefault=/usr/local
 
  AC_ARG_WITH(cfitsio-prefix, AC_HELP_STRING([--with-cfitsio-prefix=PFX],
        [CFITSIO installation prefix (default: $cfdefault)]),
        cfitsio_config_prefix="$withval", cfitsio_config_prefix="use_default")
 
  if test "$cfitsio_config_prefix" = "use_default"; then
    if test -n "$CFITSIO"; then
      cfitsio_config_prefix="$CFITSIO"
    else
      cfitsio_config_prefix="$cfdefault"
    fi
  fi
                                                                                
  if test x$cfitsio_config_prefix != x; then
    cdir="$cfitsio_config_prefix"
    for dir in $cdir/include $cdir/cfitsio $cdir/include/cfitsio $cdir
      do
        if test -f ${dir}/fitsio.h ; then
          CFITSIO_INC="-I${dir}"
          incdir="$dir"
          break;
        fi
      done
                                                                                
    if test -n "$CFITSIO_INC"; then
      for dir in $cdir/lib $cdir
        do
          if test -f ${dir}/libcfitsio.a ; then
            CFITSIO_LIB="${dir}/libcfitsio.a"
            break;
          fi
        done
    fi
                                                                                
    if test -z "$CFITSIO_LIB"; then
      AC_MSG_RESULT($cdir (invalid))
      if test -z "$CFITSIO_INC"; then who="header"; else who="library"; fi
      AC_MSG_ERROR([CFITSIO ${who} not found, please specify valid --with-cfitsio-prefix=DIR])
    else
      AC_MSG_RESULT(${cdir})
      AC_DEFINE(HAVE_LIBCFITSIO)
      rm -f src/include/cfitsio ; ln -s $incdir src/include/cfitsio
    fi
  fi
else
  CFITSIO_INC=""
  CFITSIO_LIB=""
  AC_MSG_WARN([CFITSIO disabled])
fi

AC_SUBST(CFITSIO_INC)
AC_SUBST(CFITSIO_LIB)

dnl##--------------------------------------------------------------------

AC_MSG_CHECKING(almost whether we have LAM/MPI)
AC_MSG_RESULT(not yet)

dnl##--------------------------------------------------------------------

AC_MSG_CHECKING(whether we have PVM_ROOT and PVM_ARCH)

if test -d "$PVM_ROOT"; then
  PVM_LIB="-L$PVM_ROOT/lib/$PVM_ARCH -lpvm3 -lgpvm3"
  PVM_INC="-I$PVM_ROOT/include"
  AC_MSG_RESULT(yes)
else
  PVM_LIB=""
  PVM_INC=""
  AC_MSG_RESULT(no)
fi
AC_SUBST(PVM_LIB)
AC_SUBST(PVM_INC) 
dnl##--------------------------------------------------------------------

AC_MSG_CHECKING(whether we have MIRIAD)
if test -d "$MIR"; then
  mir="$MIR"
else
  mir="/usr/local/miriad/current"
fi

AC_ARG_WITH(miriad-prefix, 
        [  --with-miriad-prefix=PFX    Root directory where MIRIAD was installed], 
        miriad_config_prefix="$withval", 
        miriad_config_prefix="$mir")
if test -f ${miriad_config_prefix}/src/inc/maxdim.h ; then
        MIRIAD_INC="-I$miriad_config_prefix/src/inc -I$miriad_config_prefix/src/subs"
        MIRIAD_LIB="-L$miriad_config_prefix/lib"
        MIRIAD_LIB="$MIRIAD_LIB -lmir"
        AC_DEFINE(_WITH_MIRIAD) 
        AC_DEFINE(_WITH_MIRIAD_BIMA)
        AC_MSG_RESULT([yes: bima-miriad $MIR])
elif test -f ${miriad_config_prefix}/inc/maxdim.h ; then
	MIRIAD_INC="-I$miriad_config_prefix/inc -I$miriad_config_prefix/subs"
        MIRIAD_LIB="-L$miriad_config_prefix/lib"
        MIRIAD_LIB="$MIRIAD_LIB -lmir"
        AC_DEFINE(_WITH_MIRIAD) 
        AC_DEFINE(_WITH_MIRIAD_ATNF)
        AC_MSG_RESULT(yes: atnf-miriad)
else
        MIRIAD_INC=""
        MIRIAD_LIB=""
        AC_MSG_RESULT(no)
        AC_MSG_WARN([could not find MIRIAD library...])
fi
AC_SUBST(MIRIAD_INC)
AC_SUBST(MIRIAD_LIB)

dnl##--------------------------------------------------------------------
dnl##
dnl## GSL  (GNU Scientific Library)
dnl##
dnl##  also need to find out a way to replace -lgslcblas with -lcblas
dnl##  or if ATLAS has been installed, with -lcblas -latlas
dnl## --  Also note the -DHAVE_GSL is a bit of a kludge, since i cannot
dnl## --  figure out how to do this properly through config.h
dnl##--------------------------------------------------------------------


AC_ARG_ENABLE(gsl, [  --enable-gsl            use GSL], ok=$enableval, ok=no)

if test "$ok" = "yes"; then
  AM_PATH_GSL(0.9.2, ok=yes, ok=no)
  if test "$ok" = "yes"; then
    GSL_CFLAGS="$GSL_CFLAGS -DHAVE_GSL"
    AC_DEFINE(HAVE_LIBGSL)
  else
    AC_MSG_WARN([could not find GSL library])
  fi
else
  AC_MSG_WARN([GSL disabled])
fi

AC_SUBST(GSL_CFLAGS)
AC_SUBST(GSL_LIBS)

dnl##-----------------------------------------------------------------------
dnl##
dnl## Flogger library (set of sorting routines)
dnl##
dnl##-----------------------------------------------------------------------

AC_ARG_ENABLE(flogger, [  --enable-flogger        use Flogger], ok=$enableval, ok=no)

dnl##-----------------------------------------------------------------------
dnl##
dnl## TCL
dnl##
dnl##-----------------------------------------------------------------------
AC_ARG_ENABLE(tcl, [  --enable-tcl            use TCL], ok=$enableval, ok=no)

if test "$ok" = "yes"; then
  if test "$ok" = "yes"; then
    TCL_CFLAGS="$TCL_CFLAGS -DHAVE_TCL"
    AC_DEFINE(HAVE_TCL)
  else
    AC_MSG_WARN([could not find TCL library])
  fi
else
  AC_MSG_WARN([TCL disabled])
fi

AC_SUBST(TCL_CFLAGS)
AC_SUBST(TCL_LIBS)


dnl##--------------------------------------------------------------------
dnl##
dnl## PGPLOT parameters
dnl##
dnl##--------------------------------------------------------------------
if test -n "$option_pgplot_link_flags"; then
    PGPLOTINCLFLAGS="$option_pgplot_incl_flags"
    PGPLOTLINKFLAGS="$option_pgplot_link_flags"
    if test -n "$option_pgplot_link_search"; then
        PGPLOTLINKSEARCH="$option_pgplot_link_search"
    else
        PGPLOTLINKSEARCH=""
    fi
else
    PGPLOTINCLFLAGS=""
    PGPLOTLINKFLAGS=""
    PGPLOTLINKSEARCH=""
fi


dnl AC_CHECK_FUNC(vprintf, AC_DEFINE(HAVE_VPRINTF))
dnl if test "$ac_cv_func_vprintf" != yes; then

dnl AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT))
dnl fi
dnl ---------------------------------------------------------------------

dnl check for terminal library. this is a very cool solution
dnl from octave's configure.in
dnl Alternatively, check http://autoconf-archive.cryp.to/vl_lib_readline.html

unset tcap
for termlib in ncurses curses termcap terminfo termlib; do
    AC_CHECK_LIB(${termlib}, tputs, [tcap="-l$termlib"])
    test -n "$tcap" && break
done

RDL_LIBS=""
AC_ARG_ENABLE(readline, [  --enable-readline       use READLINE], ok=$enableval, ok=yes)
if test "$ok" = "yes"; then
   AC_CHECK_HEADER(readline/history.h,
	AC_CHECK_LIB(history, append_history,[
                     RDL_LIBS="-lhistory" 
		     AC_DEFINE(HAVE_LIBHISTORY)]))
   AC_CHECK_HEADER(readline/readline.h,
	AC_CHECK_LIB(readline, readline,[
                     RDL_LIBS="-lreadline $RDL_LIBS $tcap"
                     AC_DEFINE(HAVE_LIBREADLINE)], , $tcap))
else
   AC_MSG_WARN([READLINE disabled])
fi
AC_SUBST(RDL_LIBS)

AC_CHECK_LIB(df, DFSDndataset)
AC_CHECK_LIB(vogl, foreground)
AC_CHECK_LIB(z, inflate)
AC_CHECK_LIB(c, strtoll)
AC_CHECK_LIB(c, strtoull)

AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX


dnl AC_CHECK_LIB(utils, main)
dnl Replace `main' with a function in -lvogl:


dnl##	this doesn't seem to work, since gsl linkeage also need libcblas etc...
dnl AC_CHECK_LIB(gsl,gsl_version)
dnl##   hmm, but this does not seem to work either....
dnl AC_CHECK_LIB(gsl, main)
AC_SEARCH_LIBS(sin, m)
AC_SEARCH_LIBS(cblas_daxpy, gslcblas)
AC_SEARCH_LIBS(gsl_version, gsl)

dnl AC_CHECK_LIB(c, strsignal)

dnl Checks for header files.


AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sgtty.h strings.h sys/file.h sys/ioctl.h sys/time.h unistd.h)

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

AC_SYS_LONG_FILE_NAMES
dnl  next one can disable with --disable-largefile
AC_SYS_LARGEFILE

dnl Checks for library functions.
AC_TYPE_GETGROUPS
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_TYPE_SIGNAL
AC_FUNC_VFORK
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(ftime gethostname gettimeofday getwd mkdir select strdup strtod strtol strtoul dprintf log2)

AC_C_BIGENDIAN

dnl -- some final YAPP stuff

AC_ARG_WITH(yapp,
	[  --with-yapp=YAPPNAME    Yapp module to make default (pgplot, ps, ..)],
	yapp_name="$withval",
	yapp_name="$yapp_default")

YAPP_NAME="$yapp_name"

AC_MSG_CHECKING(looking for a reasonable YAPP)
case $yapp_name in
        ps)
          YAPP_LIBS=""
	  YAPP_DEF="yapp.ps"
          ;;
	pgplot)
	  if test "$PGPLOT_DIR" = "$NEMOLIB" ; then
	    YAPP_LIBS='-L\$NEMOLIB'" -lcpgplot -lpgplot $PNG_LIB $XLIBS $FLIBS"
	    PGPLOT_DIR='\$NEMOLIB'
	    AC_MSG_WARN(using dollar)
	    echo $PGPLOT_DIR
	    echo $NEMOLIB
	  else
   	    YAPP_LIBS="-L$PGPLOT_DIR -lcpgplot -lpgplot $PNG_LIB $XLIBS $FLIBS"
	    AC_MSG_WARN(using, external to NEMO, classic)
	  fi
	  YAPP_DEF="/xs"
          ;;
esac
AC_MSG_RESULT($YAPP_NAME)

AC_SUBST(YAPP_NAME)
AC_SUBST(YAPP_LIBS)
AC_SUBST(YAPP_DEF)

if test -d "$NEMODAT"; then
  echo "*** Warning: NEMO=$NEMO, maybe you are running NEMO already"
  echo "*** you probably should source $NEMO/nemo_end"
fi

AC_CONFIG_FILES(NEMORC.gen Makefile makedefs nemo_start nemo.pl)
AC_OUTPUT

echo "
-------------------------------------------------------------------------
All done, continue with your installation now as described in the
output from the command

     make install

Note that this command actually does not install NEMO yet, but merely
tells you what to do in which order. The recommended procedure is using
the bootstrap script in NEMO/src/scripts.
-------------------------------------------------------------------------
"

back to top