Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/pure-cfg/configure.ac
ViewVC logotype

View of /branches/pure-cfg/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1274 - (download) (annotate)
Mon Jun 6 11:14:17 2011 UTC (8 years, 5 months ago) by jhr
File size: 9801 byte(s)
  Added target defines to CPPFLAGS
dnl Process this file with autoconf to produce a configure script.
dnl
dnl COPYRIGHT (c) 2010 The Diderot Project
dnl All rights reserved.
dnl

dnl NOTE: MANTICORE_DIST_VERSION is an M4 variable defined in config/aclocal.m4
dnl
AC_INIT(diderot,0.1,)

AC_PREREQ(2.60)
AC_COPYRIGHT([[COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)]])
AC_CONFIG_SRCDIR(src/dnorm/dnorm.c)
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)

dnl
dnl include additional macros
dnl
sinclude(config/acx_pthread.m4)
sinclude(config/check_smlnj.m4)
sinclude(config/check_smlnj_heap_suffix.m4)
sinclude(config/ax_check_framework.m4)

dnl
dnl get host information
dnl
AC_CANONICAL_HOST

dnl check for standard programs
dnl
AC_PROG_CC([clang gcc cc])
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET

dnl check for c99 support
dnl
AC_PROG_CC_C99
if test x"$ac_cv_prog_cc_c99" = xno ; then
  AC_MSG_ERROR([Diderot requires c99 support])
fi

dnl extra C compiler options
dnl
CFLAG_M64="-m64"
CFLAGS_BASE="-Wformat -Wreturn-type -Wuninitialized"
AC_SUBST(CFLAG_M64)
AC_SUBST(CFLAGS_BASE)

dnl
dnl check for pthreads support
dnl
ACX_PTHREAD()

dnl
dnl Look for NVIDIA's nvcc compiler
dnl
AC_MSG_NOTICE([checking for CUDA and nvcc])
AC_PATH_PROG(NVCC, nvcc, no, $PATH)
if test x"$NVCC" = xno ; then
  AC_MSG_WARN([nvcc not found])
  CUDA_ENABLED=false
  NVCC=":"
else
  AC_MSG_RESULT([$NVCC])
  CUDA_ENABLED=true
fi
AC_SUBST(NVCC)
AC_SUBST(CUDA_ENABLED)

dnl
dnl check for OpenCL support
dnl
CL_LIBS="none"
case "$host_os" in
  darwin*) # On Mac OS X we check for installed frameworks
    AX_CHECK_FRAMEWORK([OpenCL], [CL_LIBS="-framework OpenCL"], [])
  ;;
  *)
    AC_CHECK_LIB([OpenCL],[clGetPlatformIDs],[CL_LIBS="-lOpenCL"])
  ;;
esac
if test x"$CL_LIBS" = xnone ; then
  AC_MSG_WARN([no OpenCL library found])
  CL_ENABLED=false
  CL_VERSION=0
else
  CL_ENABLED=true
  AC_CHECK_HEADERS([CL/cl.h OpenCL/cl.h])
  # check the cl.h header for which version of OpenCL is supported
  AC_LANG([C])
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
# ifdef HAVE_CL_CL_H
#   include <CL/cl.h>
# elif defined(HAVE_OPENCL_CL_H)
#   include <OpenCL/cl.h>
# else
#   error no cl.h
# endif]],
[[#if defined(CL_VERSION_1_1)
  printf("11000\n");
#elif defined(CL_VERSION_1_0)
  printf("10000\n");
#else
  printf("0\n");
#endif
    ]])],
    [CL_VERSION=`./conftest$EXEEXT`], [CL_VERSION=0])
  # substitutions
  AC_SUBST(CL_LIBS)
fi
AC_SUBST(CL_ENABLED)
AC_SUBST(CL_VERSION)

dnl
dnl check for various library routines etc.
dnl
AC_CHECK_FUNCS(posix_memalign)
if test x"$ac_cv_func_posix_memalign" != xyes ; then
  AC_CHECK_FUNCS(memalign)
  if test x"$ac_cv_func_posix_memalign" != xyes ; then
    AC_CHECK_FUNCS(valloc)
  fi
fi

AC_CHECK_FUNCS(mach_absolute_time)
AC_CHECK_TYPES([struct timespec])
AC_CHECK_FUNCS(pthread_barrier_init)

dnl
dnl check for clock_gettime.  On Linux, this requires librt.
dnl
save_LIBS=$LIBS
LIBS="-lrt $LIBS"
AC_MSG_CHECKING([for clock_gettime])
AC_LINK_IFELSE(
  [AC_LANG_PROGRAM(
    [[#include <time.h>]],
    [[struct timespec t; clock_gettime(CLOCK_REALTIME, &t); ]])],
  [ ac_cv_func_clock_gettime=yes;
    AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [is clock_gettime available?])],
  [ac_cv_func_clock_gettime=no])
AC_MSG_RESULT($ac_cv_func_clock_gettime)
if test "$ac_cv_func_clock_gettime" = "no" ; then
  LIBS=$save_LIBS
fi

AC_CHECK_FUNCS(pthread_getcpuclockid)
AC_CHECK_FUNCS(sigtimedwait nanosleep)

dnl
dnl check for sched_setaffinity
dnl
AC_CHECK_FUNCS(sched_setaffinity)

dnl
dnl check for pthread_setaffinity_np
dnl
save_LIBS=$LIBS
save_CFLAGS=$CFLAGS
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
AC_MSG_CHECKING([for pthread_setaffinity_np])
AC_LINK_IFELSE(
  [AC_LANG_PROGRAM(
    [[#include <pthread.h>]],
    [[cpu_set_t s; pthread_setaffinity_np(pthread_self(), sizeof(s), &s); ]])],
  [ ac_cv_func_pthread_setaffinity_np=yes;
    AC_DEFINE(HAVE_PTHREAD_SETAFFINITY_NP, [1], [is pthread_setaffinity_np available?])],
  [ac_cv_func_pthread_setaffinity_np=no])
AC_MSG_RESULT($ac_cv_func_pthread_setaffinity_np)
LIBS=$save_LIBS
CFLAGS=$save_CFLAGS

dnl
dnl check for Linux NUMA support (libnuma)
dnl
AC_CHECK_LIB(numa,numa_available)
if test "$ac_cv_lib_numa_numa_available" = "yes" ; then
  PTHREAD_LIBS="$PTHREAD_LIBS -lnuma"
fi

dnl check for /proc/cpuinfo
dnl
AC_CHECK_FILES(/proc/cpuinfo)

dnl
dnl OS-specific linking issues
dnl
LD_NEEDS_RPATH=false;
LIBM=""
case "$host_os" in
  darwin*) # On Mac OS X we check for the presence of macports and/or fink
    if test -x /opt/local/bin/port ; then
      HAS_MACPORTS=yes
    else
      HAS_MACPORTS=no
    fi
    if test -x /sw/bin/fink ; then
      HAS_FINK=yes
    else
      HAS_FINK=no
    fi
  ;;
  linux*) # On Linux we include the -rpath option to pick up dynamically-loaded libraries
    LD_NEEDS_RPATH=true
    LIBM="-lm"
  ;;
esac

if test x"$HAS_MACPORTS" = xyes ; then
  LDPATHS="-L/opt/local/lib"
elif test x"$HAS_FINK" = xyes ; then
  LDPATHS="-L/sw/lib"
else
  LDPATHS=""
fi
AC_SUBST(LDPATHS)
AC_SUBST(LD_NEEDS_RPATH)
AC_SUBST(LIBM)

dnl
dnl get the path to the TEEM installation
dnl
AC_ARG_WITH(teem,
  AC_HELP_STRING([--with-teem=<path>], [specify path to teem installation]),
  [ac_cv_use_teem=$withval], [ac_cv_use_teem=no])
if test x"$ac_cv_use_teem" = xno ; then
  TEEM_DIR=none
else
  AC_MSG_CHECKING([path to teem ($ac_cv_use_teem)])
  case $ac_cv_use_teem in
    /*) ;;
    *) AC_MSG_ERROR([path to teem must be absolute]) ;;
  esac
  if test -x $ac_cv_use_teem ; then
    TEEM_DIR=$ac_cv_use_teem
    AC_MSG_RESULT([ okay])
  else
    TEEM_DIR=none
    AC_MSG_RESULT([ invalid])
  fi
fi
if test x"$TEEM_DIR" = xnone ; then
  AC_MSG_ERROR([unable to find teem])
fi
AC_SUBST(TEEM_DIR)

dnl ******************** SML/NJ configuration ********************
dnl

dnl check that we have a compatible version of SML/NJ
dnl
CHECK_SMLNJ([AC_MSG_ERROR([unable to find SML/NJ installation; check your PATH or set SMLNJ_CMD])])
if test $SMLNJ_MAJOR_VERSION -lt 110 \
  -o $SMLNJ_MINOR_VERSION -lt 73
then
  AC_MSG_ERROR([installation requires SML/NJ version 110.73+])
fi
AC_SUBST(SMLNJ_VERSION)

dnl determine the heap-image suffix
dnl
CHECK_SMLNJ_HEAP_SUFFIX([
  AC_MSG_ERROR([unsupported configuration ${host_cpu}-${host_os}])])

dnl look for ml-makedepend
dnl
AC_MSG_CHECKING([for ml-makedepend])
tmpPATH="$SMLNJ_PATH:$PATH"
AC_PATH_PROG(ML_MAKEDEPEND, ml-makedepend, ":", $tmpPATH)
if test $ML_MAKEDEPEND = none ; then
  AC_MSG_ERROR([ml-makedepend not found])
else
  AC_MSG_RESULT([$ML_MAKEDEPEND])
fi
AC_SUBST(ML_MAKEDEPEND)

dnl
dnl look for ml-build
dnl
tmpPATH="$SMLNJ_PATH:$PATH"
AC_PATH_PROG(ML_BUILD, ml-build, none, $tmpPATH)
if test $ML_BUILD = none ; then
  AC_MSG_ERROR([ml-build not found])
fi
AC_SUBST(ML_BUILD)

dnl ******************** Paths ********************

DIDEROT_ROOT=`pwd`
DIDEROT_DOCDIR=$DIDEROT_ROOT/doc
DIDEROT_SRCDIR=$DIDEROT_ROOT/src
DIDEROT_LIBDIR=$DIDEROT_ROOT/lib
DIDEROT_BINDIR=$DIDEROT_ROOT/bin
DIDEROT_MKDIR=$DIDEROT_ROOT/mk

HEAP_IMAGE_DIR=$DIDEROT_BINDIR/.heap
INSTALL_SMLNJ_WRAPPER=$DIDEROT_BINDIR/install-sml-wrapper.sh

AC_SUBST(DIDEROT_ROOT)
AC_SUBST(DIDEROT_DOCDIR)
AC_SUBST(DIDEROT_SRCDIR)
AC_SUBST(DIDEROT_LIBDIR)
AC_SUBST(DIDEROT_BINDIR)
AC_SUBST(DIDEROT_MKDIR)
AC_SUBST(HEAP_IMAGE_DIR)
AC_SUBST(INSTALL_SMLNJ_WRAPPER)

dnl
dnl ******************** C compiler properties ********************
dnl

dnl
dnl run the compiler tests in 64-bit mode
dnl
save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $CFLAG_M64"

dnl
dnl check for gcc builtin atomic operations
dnl
AC_MSG_CHECKING([for builtin atomic operations])
AC_LINK_IFELSE(
   [AC_LANG_PROGRAM([], [int foo1; int foo2 = __sync_fetch_and_add(&foo1, 1);])],
   AC_MSG_RESULT(yes)
   AC_DEFINE(
    [HAVE_BUILTIN_ATOMIC_OPS], 1,
    [Define to 1 if gcc compiler provides atomic operations.]),
   AC_MSG_RESULT(no))

AC_C_BIGENDIAN

dnl
dnl restore CFLAGS
dnl
CFLAGS=$save_CFLAGS

dnl
dnl ******************** config.h stuff ********************
dnl
AH_TOP([
/*
 * COPYRIGHT (c) 2011 Diderot project. (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 */

#ifndef _DIDEROT_CONFIG_H_
#define _DIDEROT_CONFIG_H_

])
AH_BOTTOM([

#endif /* !_DIDEROT_CONFIG_H_ */
])

dnl
dnl ******************** write output ********************
dnl

AC_CONFIG_FILES(
dnl
dnl ***** Makefiles *****
  Makefile
  src/clinfo/Makefile
  src/dnorm/Makefile
  src/compiler/Makefile
  src/lib/build/Makefile
  src/lib/build/mk/build.gmk:src/lib/build/mk/build_gmk.in
  test/MIP/Makefile
  test/probe/Makefile
dnl
dnl ***** CM files *****
  src/compiler/codegen/sources.cm:src/compiler/codegen/sources_cm.in
dnl
dnl ***** SML source files *****
  src/compiler/fields/run-dnorm.sml:src/compiler/fields/run-dnorm_sml.in
  src/compiler/common/paths.sml:src/compiler/common/paths_sml.in
)

AC_CONFIG_HEADERS(src/include/Diderot/config.h:config/config_h.in)

dnl
dnl shell scripts
dnl
AC_CONFIG_FILES([
  bin/install-sml-wrapper.sh:config/install-sml-wrapper_sh.in
], [chmod +x bin/install-sml-wrapper.sh])

dnl
dnl generate makefiles for runtime library builds
dnl
dnl usage: MK_BUILD_DIR(<build-dir>, <target-platform>, <options>)
dnl
AC_DEFUN([MK_BUILD_DIR], [
    if test ! -d src/lib/build/$1 ; then
      mkdir src/lib/build/$1
    fi
    [sed -e 's,@BUILD_TARGET@,$1,g' \
      -e 's,@TARGET_PLATFORM@,$2,g' \
      -e 's,@BUILD_OPTIONS@,$3,g' \
      src/lib/build/mk/Makefile.in \
        > src/lib/build/$1/Makefile.in]
    AC_CONFIG_FILES(src/lib/build/$1/Makefile)
  ])

MK_BUILD_DIR(rt-c-f, c, [float])
MK_BUILD_DIR(rt-c-f-debug, c, [float debug])
MK_BUILD_DIR(rt-c-f-par, parallel, [parallel float])
MK_BUILD_DIR(rt-c-f-par-debug, parallel, [parallel float debug])

if test x"$CL_ENABLED" = xtrue ; then
  MK_BUILD_DIR(rt-cl-f, cl, [float])
  MK_BUILD_DIR(rt-cl-f-debug, cl, [float debug])
fi

AC_OUTPUT

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0