https://github.com/teuben/nemo
Raw File
Tip revision: d0f673bdaeabe8dffa77528c13d81063a20d29f6 authored by Peter Teuben on 03 April 2024, 01:39:10 UTC
format
Tip revision: d0f673b
configure.ac
dnl configure.ac:
dnl Process this file with autoconf to produce a new configure script
dnl if it has changed. 
dnl
dnl https://autotools.io/index.html
dnl     aclocal --print
dnl will show which m4's are present and used
dnl git clone https://github.com/autoconf-archive/autoconf-archive
dnl ---------------------------------------------------------------------------------

AC_PREREQ(2.69)
AC_INIT(nemo_start.sh.in)

AC_MSG_CHECKING([NEMO config])


AC_CONFIG_MACRO_DIR([m4])
dnl AC_CONFIG_MACRO_DIRS - for future autoconf 2.70 ?
m4_include([m4/csh.m4])
dnl m4_include([m4/hdf5.m4])
dnl m4_include([m4/ax_lib_hdf5.m4])
m4_include([m4/ax_f77_cmain_fflags.m4])
m4_include([m4/ax_f77_func_mangle.m4])
m4_include([m4/acx_plplot.m4])
dnl m4_include([m4/gsl.m4])
dnl ax_lib_readline.m4
dnl ax_mpi.m4
dnl ax_pkg_swig.m4
dnl ax_prog_python_version.m4

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 CMAKE_FIND_BINARY

dnl ----                Architecture stuff we need to know
AC_CANONICAL_HOST
echo "Found CANONICAL_HOST = $host_os or $host or $host_cpu"
AC_CANONICAL_BUILD
echo "Found CANONICAL_BUILD = $build"
AC_CANONICAL_TARGET
echo "Found CANONICAL_TARGET = $target"


dnl AC_ARG_ENABLE(option-name, help-string, action-if-present, action-if-not-present)
dnl AC_ARG_WITH
dnl AC_SEARCH_LIBS(function, libraries-list, action-if-found, action-if-not-found, extra-libraries)

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_PROG_CSH
dnl next ones seems to force linking with FC, and we have F77 as well, for now, FC=F77
dnl AC_PROG_FC
dnl AC_FC_WRAPPERS

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(shared, [  --disable-shared        disable shared libraries? (needed for falcON on MAC)], ok=$enableval, ok=yes)
if test "$ok" = "yes"; then
  NO_SHARED_LIBS=0
else
  NO_SHARED_LIBS=1
fi
AC_SUBST(NO_SHARED_LIBS)

AC_ARG_ENABLE(clang, [  --enable-clang          use clang compiler], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
        CC="clang"
        CXX="clang++"
	#FC="flang"
	#F77="flang"
	FC="gfortran"
	F77="gfortran"
fi

AC_ARG_ENABLE(pedantic, [  --enable-pedantic       compile for lots of pedantics], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
  flags="-std=c99  -pedantic -Wall -Werror -W -Wmissing-prototypes"
  flags="$flags -Wconversion -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align"
  flags="$flags -Wwrite-strings -Wnested-externs -fshort-enums -fno-common -Dinline= -g -O3"
  flags="$flags -Wsign-compare  -Wtype-limits -Wignored-qualifiers -Wempty-body -Wuninitialized"
  PFLAGS="-Wimplicit-int -Werror-implicit-function-declaration"
else
  PFLAGS="-Wall"
fi
AC_SUBST(PFLAGS)

AC_ARG_ENABLE(native, [  --enable-native         optimize for native CPU], ok=$enableval, ok=no)
if test "$ok" = "yes"; then
  flags="-march=native"
  CFLAGS="$CFLAGS $flags"
  CXXFLAGS="$CXXFLAGS $flags"
  FFLAGS="$CFLAGS $flags"
  falcon_NO_NATIVE=0
else
  falcon_NO_NATIVE=1
fi
AC_SUBST(falcon_NO_NATIVE)


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 (default)], 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


AC_ARG_ENABLE(fortran,[  --disable-fortran       don't use any Fortran], enable_fortran=$enableval, enable_fortran=yes)
AC_ARG_ENABLE(falcon, [  --disable-falcon        disable falcON],enable_falcon=$enableval, enable_falcon=yes)
if test "$enable_falcon" = "yes"; then
  MAKELIBS="corelibs dehnen"
else
  MAKELIBS="corelibs"
fi
MAKEDIRS="src usr"
AC_SUBST(MAKELIBS)
AC_SUBST(MAKEDIRS)

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_ccmalloc=$withval, with_ccmalloc=no)
AC_ARG_WITH(dso,
		  [  --with-dso              use DSO linking], with_dso=$withval, with_dso=no)
AC_ARG_WITH(opt, 
		  [  --with-opt              use opt for essentials], with_opt=$withval, with_opt=no)
AC_ARG_WITH(openmp,
		  [  --with-openmp           use OMP directives], with_openmp=$withval, with_openmp=no)

AC_ARG_WITH(std,
		  [  --with-std              use this -std=], with_std=$withval, with_std=c99)

if test $with_std != "default"; then
  STDFLAG="-D_GNU_SOURCE -std=$with_std"
else
  STDFLAG=""
fi
AC_SUBST(STDFLAG)

if test $with_openmp = "yes"; then
  CFLAGS="$CFLAGS -fopenmp"
  CXXFLAGS="$CXXFLAGS -fopenmp"
  FFLAGS="$CFLAGS -fopenmp"
  falcon_OPENMP="OPENMP"
else
  falcon_OPENMP="noOPENMP"
fi
AC_SUBST(falcon_OPENMP)

dnl ---------------------------------------------------------------------
dnl             Check for basic X windows stuff : AC_PATH_XTRA -> X_CFLAGS and X_LIBS
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"
elif test -d /usr/X11/lib; then
  XLIBS="$X_LIBS $X_PRE_LIBS -L/usr/X11/lib -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 CFITSIO_INC=""
dnl CFITSIO_LIB=""
dnl AC_CHECK_HEADERS([fitsio.h])
dnl AC_CHECK_HEADERS([/opt/include/fitsio.h],[CFITSIO_INC=-I/opt/include])
dnl AC_CHECK_HEADERS([/local/include/fitsio.h],[CFITSIO_INC=-I/local/include])
dnl AC_CHECK_LIB(cfitsio,ffopen,[CFITSIO_LIB="-lcfitsio"])
dnl AC_SUBST(CFITSIO_INC)
dnl AC_SUBST(CFITSIO_LIB)

dnl HDF5 is sometimes in a weird place, e.g. /usr/lib/x86_64-linux-gnu/hdf5/serial   /usr/include/hdf5/serial
dnl AX_LIB_HDF5()

dnl AX_LIB_HDF5([serial])

dnl
dnl
dnl PKG_CHECK_MODULES(HDF5, [hdf5-serial],
dnl			[AC_MSG_NOTICE([pkg-config hdf5-serial])],
dnl			[AC_MSG_ERROR([hdf5-serial not found])]
dnl			)			       
dnl

dnl PKG_CHECK_MODULES([HDF5], [hdf5-serial],[have_hdf5="yes"],[have_hdf5="no"])
dnl AC_SUBST([have_hdf5])

dnl 
dnl PKG_CHECK_MODULES(HDF5, [hdf5-serial],
dnl 			[AC_MSG_NOTICE([pkg-config hdf5-serial])],
dnl 			[PKG_CHECK_MODULES(HDF5, [hdf5],
dnl 						 [AC_MSG_NOTICE([pkg-config hdf5-serial])],
dnl 						 [HDF5_CFLAGS=""
dnl 						  HDF5_LIB="-lhdf5"
dnl 						  AC_MSG_NOTICE([falling back to -lhdf5])
dnl 						  ]


AC_SUBST([HDF5_CFLAGS])
AC_SUBST([HDF5_LIBS])


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

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 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, gfortran g77 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

FC=$F77
AC_SUBST(FC)

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

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  /usr/share/pgplot /usr/lib/pgplot5
    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 ---------------------------------------------------------------------

AC_ARG_ENABLE(plplot,
        [AS_HELP_STRING([--enable-plplot],
        [Activate PLPlot library (default = yes)])],
        AC_MSG_RESULT([yes]),
        AC_MSG_RESULT([no]))
AC_ARG_WITH(plplot-libdir,
        [AS_HELP_STRING([--with-plplot-libdir=<PLPlot library path>],
        [Provide an alternative path to the PLPlot library])])
AC_ARG_WITH(plplot-incdir,
        [AS_HELP_STRING([--with-plplot-incdir=<PLPlot include dir>],
        [Provide an alternative path to the PLPlot include directory])])

################# handle the PLPlot library (graphic plots) ##################
if test "$enable_plplot" != "no"; then
  ACX_PLPLOT($with_plplot_libdir,$with_plplot_incdir,
    [use_plplot="yes"]
    [LIBS="$LIBS -lplplot $PLPLOT_LIB"],
    [use_plplot="no"]
    AC_MSG_WARN([PLPlot library not found/incomplete! Plotting deactivated.]))
else
  AC_MSG_WARN([Plotting deactivated by user.])
fi

dnl     [AM_CPPFLAGS="$AM_CPPFLAGS $PLPLOT_CFLAGS"]


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 ---------------------------------------------------------------------

DSO_LINK=''
if test "$with_dso" = "yes"; then
  DSO_LINK="-Wl,--no-as-needed"
fi
AC_SUBST(DSO_LINK)

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


AC_MSG_CHECKING(whether we have HDF4)
AC_ARG_WITH(hdf-prefix, 
        [  --with-hdf-prefix=PFX     Prefix where HDF4 was installed], 
        hdf_config_prefix="$withval", 
        hdf_config_prefix="/usr")
dnl			this assumes people will use include <hdf.h>, not <hdf/hdf.h>
dnl                     on Fedora, you will find HDF4 in /usr/{include,lib}/hdf
dnl                     HDF5 uses hdf5.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 -L$hdf/lib/hdf -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


dnl PJT
CFITSIO_INC=""
CFITSIO_LIB=""

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
 
  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"
	  AC_MSG_RESULT($incdir (valid))	  
          break;
        fi
      done
                                                                                
    if test -n "$CFITSIO_INC"; then
      for dir in $cdir/lib $cdir $cdir/lib/$host_cpu-$host_os
        do
	  AC_MSG_RESULT($dir)
          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
  CFITSIOINC=""
  CFITSIOLIB=""
  AC_MSG_WARN([CFITSIO disabled])
fi

AC_SUBST(CFITSIO_INC)
AC_SUBST(CFITSIO_LIB)





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## 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

AC_SEARCH_LIBS([dlopen], [dl dld], [], [
  AC_MSG_WARN([unable to find the dlopen() function])
])


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 -- tar file caching?
dnl -- if you have my "wgetc" use:   --with-tar=$HOME/.wget-cache

tar_default="../tar"
AC_ARG_WITH(tar,
	[  --with-tar=TARDIR       cache directory for tar files for opt install],
	tar_dir="$withval",
	tar_dir="$tar_default")

NEMOTARS="$(readlink -f $tar_dir)"
AC_MSG_RESULT(Using NEMOTARS=$NEMOTARS)
AC_SUBST(NEMOTARS)

dnl -- some final YAPP stuff

AC_ARG_WITH(yapp,
	[  --with-yapp=YAPPNAME    Yapp module to make default (pgplot, ps, gnuplot, ...)],
	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"
          ;;
	gnuplot)
	  YAPP_LIBS=
	  YAPP_DEF=""
	  ;;
	plplot)
	  YAPP_LIBS="-lplplot"
	  YAPP_DEF="xwin"
	  ;;
	cpgplot)
	  if test "$PGPLOT_DIR" = "$NEMOLIB" ; then
	    YAPP_LIBS="-L\$(NEMOLIB) -lcpgplot -lpgplot $PNG_LIB \$(XLIBS) \$(FLIBS)"
	    PGPLOT_DIR='$NEMOLIB'
	    AC_MSG_WARN(C using dollar)
	    echo $PGPLOT_DIR
	    echo $NEMOLIB
	  else
   	    YAPP_LIBS="-L$PGPLOT_DIR -lcpgplot -lpgplot $PNG_LIB $XLIBS $FLIBS"
	    AC_MSG_WARN(C using, external to NEMO, classic)
	  fi
	  YAPP_DEF="/xs"
          ;;
	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"
          ;;
	giza)
	  YAPP_DEF="/xw"
	  YAPP_LIBS="-lgiza"
esac
AC_MSG_RESULT($YAPP_NAME)

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

dnl --------------------------------- override some local essentials via $NEMO/opt ? ------

if test "$with_opt" = "yes"; then
  #
  inc=$NEMO/opt/include
  if test -f $inc/hdf.h; then
    HDF_INC=
    HDF_LIB="-ldf -ljpeg -lz"
    AC_SUBST(HDF_INC)
    AC_SUBST(HDF_LIB)
    AC_MSG_WARN(using HDF4 from opt)
  else
    AC_MSG_WARN(no HDF4 in opt)
  fi
  #
  if test -f $inc/hdf5.h; then
    HDF5_INC=
    HDF5_LIB="-lhdf5"
    AC_SUBST(HDF5_INC)
    AC_SUBST(HDF5_LIB)
    AC_MSG_WARN(using HDF5 from opt)
  else
    AC_MSG_WARN(no HDF5 in opt)    
  fi
  #
  if test -f $inc/fitsio.h; then
    CFITSIO_INC=
    CFITSIO_LIB="-lcfitsio"
    AC_SUBST(CFITSIO_INC)
    AC_SUBST(CFITSIO_LIB)
    AC_MSG_WARN(using CFITSIO from opt)
  else
    AC_MSG_WARN(no CFITSIO in opt)    
  fi
else
  AC_MSG_WARN(not using opt)
fi
AC_SUBST(MATH_LIBS)


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

AC_CONFIG_FILES(Makefile makedefs nemo-config nemo_start.csh nemo_start.sh nemo_start.py usr/dehnen/utils/make.sh)
AC_OUTPUT

echo "
-------------------------------------------------------------------------
All done configuring, continue with your installation with

     make build check bench5

Users need to source the nemo_start.(c)sh file in their shell to
enable NEMO commands and set up their NEMO environment.
If there any compile or linkings problems, check out \$NEMOLIB/makedefs
-------------------------------------------------------------------------
"

back to top