Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] View of /trunk/opencl/configure.ac
ViewVC logotype

View of /trunk/opencl/configure.ac

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (download) (annotate)
Sun Jul 17 13:51:24 2011 UTC (7 years, 4 months ago) by jhr
File size: 13184 byte(s)
  Working on OpenCL configuration
dnl Process this file with autoconf to produce a configure script.
dnl
dnl COPYRIGHT (c) 2010 John Reppy (http://cs.uchicago.edu/~jhr)
dnl All rights reserved.
dnl
dnl This the configuration script for autoconf version 2.60+.  The
dnl file configure.in is for older versions.

AC_INIT(sml3d-opencl,0.1,sml3d@mailman.cs.uchicago.edu)

AC_PREREQ(2.60)
AC_COPYRIGHT([[COPYRIGHT (c) 2010 John Reppy (http://cs.uchicago.edu/~jhr)]])
AC_CONFIG_SRCDIR(src/opencl/opencl_mlb.in)
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
 
dnl
dnl include additional macros
dnl
sinclude(config/ax_lang_compiler_ms.m4)
sinclude(config/ax_check_framework.m4)
sinclude(config/ax_check_lib_stdcall.m4)

dnl
dnl get host information
dnl
AC_CANONICAL_HOST

dnl check for standard programs
dnl
AC_PROG_CC_C99
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MAKE_SET

dnl
dnl ******************** MLton related configuration ********************
dnl

dnl check for mlton
dnl
AC_ARG_WITH(mlton,
  AC_HELP_STRING([--with-mlton=<path>], [specify path to mlton executable]),
  [ac_cv_use_mlton=$withval], [ac_cv_use_mlton=no])
if test x"$ac_cv_use_mlton" = xno ; then
  # look for mlton in the path
  AC_PATH_PROG([MLTON], [mlton], [none],
    [$PATH$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR/usr/local/bin])
else
  AC_MSG_CHECKING([path to mlton ($ac_cv_use_mlton)])
  case $ac_cv_use_mlton in
    /*) ;;
    *) AC_MSG_ERROR([path to mlton must be absolute]) ;;
  esac
  if test -x $ac_cv_use_mlton ; then
    MLTON=$ac_cv_use_mlton
  AC_MSG_RESULT([ okay])
  else
    MLTON=none
  AC_MSG_RESULT([ invalid])
  fi
fi
if test x"$MLTON" = xnone ; then
  AC_MSG_ERROR([unable to find mlton])
fi
AC_SUBST(MLTON)

dnl determine the native size for mlton (32 or 64 bits)
dnl
AC_MSG_CHECKING([native size of mlton executables])
MLTON_OBJPTR_REP=`$MLTON -show path-map | grep OBJPTR_REP | sed -e s/OBJPTR_REP//`
case x"$MLTON_OBJPTR_REP" in
  *rep32)
    AC_MSG_RESULT([32 bit])
    CFLAGS="$CFLAGS -m32"
  ;;
  *rep64)
    AC_MSG_RESULT([64 bit])
    CFLAGS="$CFLAGS -m64"
  ;;
  *) AC_MSG_ERROR([unable to determine mlton's word size]) ;;
esac

dnl check to see if we have a version of MLton that includes the C_Pointer module, which
dnl was added in revision 7407.
dnl
AC_MSG_CHECKING([for C_Pointer structure])
ac_cv_mlb_file=conftest.mlb
cat - > $ac_cv_mlb_file <<_ACEOF
local
  \$(SML_LIB)/basis/c-types.mlb
in
structure CPtr = C_Pointer
end
_ACEOF
$MLTON -stop tc $ac_cv_mlb_file >/dev/null 2>&1
if test $? -eq 0 ; then
  ac_cv_mlton_has_c_pointer=yes
else
  ac_cv_mlton_has_c_pointer=no
fi
AC_MSG_RESULT([$ac_cv_mlton_has_c_pointer])

if test x"$ac_cv_mlton_has_c_pointer" != xyes ; then
  AC_MSG_ERROR([OpenCL library requires a newer version of MLton])
fi

dnl
dnl ******************** developer related configuration ********************
dnl
dnl for sml3d developers (as opposed to users), we need some additional
dnl software.
dnl

MLTON_PATH=`dirname $MLTON`

dnl check for mlulex or ml-ulex
dnl
AC_PATH_PROGS([ML_ULEX], [mlulex ml-ulex], [false],
  [$PATH$PATH_SEPARATOR$MLTON_PATH])

dnl check for mlantlr or ml-antlr
dnl
AC_PATH_PROGS([ML_ANTLR], [mlantlr ml-antlr], [false],
  [$PATH$PATH_SEPARATOR$MLTON_PATH])

AC_SUBST(ML_ULEX)
AC_SUBST(ML_ANTLR)


dnl
dnl ******************** OS related configuration ********************
dnl

case "$host_os" in
  mingw32)
    ROOT_DIR=`pwd -W`
    EXE_SUFFIX=".exe"
  ;;
  *)
    ROOT_DIR=`pwd`
    EXE_SUFFIX=""
  ;;
esac
SRC_DIR=$ROOT_DIR/src
LIB_DIR=$ROOT_DIR/lib

AC_SUBST(ROOT_DIR)
AC_SUBST(SRC_DIR)
AC_SUBST(LIB_DIR)
AC_SUBST(EXE_SUFFIX)

dnl
dnl ******************** OpenCL configuration ********************
dnl
dnl initialize the command-line options to support the various optional packages
dnl
OPENCL_OPTION="none"

case "$host_os" in
  darwin*) # On Mac OS X we check for installed frameworks
    AX_CHECK_FRAMEWORK(
      [OpenCL],
      [OPENCL_OPTION="-framework OpenCL"; OPENCL_INCLUDE="#include <OpenCL/cl.h>"],
      [])
  ;;
  mingw32) # windows is not supported yet
    AC_MSG_ERROR([OpenCL is not supported on Windows])
  ;;
  *)
    AC_CHECK_LIB(
      [OpenCL],
      [clGetPlatformIDs],
      [OPENCL_OPTION="-lOpenCL"; OPENCL_INCLUDE="#include <CL/cl.h>"])
  ;;
esac

if test x"$OPENCL_OPTION" = xnone ; then
  AC_MSG_ERROR([no OpenCL library found])
else
  OPENCL_LIB="\$(SML3D_LIB)/opencl.mlb"
  OPENCL_GL_SML=""
  OPENCL_SML3D_MLB=""
  OPENCL_GL_SML=""
  OPENCL_WITH_GL_SML="cl-without-gl.sml"
  OPENCL_WITH_GL_CPPFLAGS=""
fi
AC_SUBST(OPENCL_OPTION)
AC_SUBST(OPENCL_LIB)
AC_SUBST(OPENCL_SML3D_MLB)
AC_SUBST(OPENCL_GL_SML)
AC_SUBST(OPENCL_WITH_GL_SML)
AC_SUBST(OPENCL_WITH_GL_CPPFLAGS)

dnl
dnl ******************** OpenCL sizes etc. ********************
dnl
AC_CHECK_SIZEOF([cl_char], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_char2], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_char3], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_char4], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_char8], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_char16], [], [$OPENCL_INCLUDE])
SIZEOF_CL_CHAR=$ac_cv_sizeof_cl_char
SIZEOF_CL_CHAR2=$ac_cv_sizeof_cl_char2
SIZEOF_CL_CHAR3=$ac_cv_sizeof_cl_char3
SIZEOF_CL_CHAR4=$ac_cv_sizeof_cl_char4
SIZEOF_CL_CHAR8=$ac_cv_sizeof_cl_char8
SIZEOF_CL_CHAR16=$ac_cv_sizeof_cl_char16
AC_CHECK_ALIGNOF([cl_char], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_char2], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_char3], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_char4], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_char8], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_char16], [$OPENCL_INCLUDE])
ALIGNOF_CL_CHAR=$ac_cv_alignof_cl_char
ALIGNOF_CL_CHAR2=$ac_cv_alignof_cl_char2
ALIGNOF_CL_CHAR3=$ac_cv_alignof_cl_char3
ALIGNOF_CL_CHAR4=$ac_cv_alignof_cl_char4
ALIGNOF_CL_CHAR8=$ac_cv_alignof_cl_char8
ALIGNOF_CL_CHAR16=$ac_cv_alignof_cl_char16
# AS_VAR_ARITH([BITSOF_CL_CHAR], [8 * $SIZEOF_CL_CHAR])
BITSOF_CL_CHAR=$(( 8 * $SIZEOF_CL_CHAR ))
AC_SUBST(SIZEOF_CL_CHAR)
AC_SUBST(SIZEOF_CL_CHAR2)
AC_SUBST(SIZEOF_CL_CHAR3)
AC_SUBST(SIZEOF_CL_CHAR4)
AC_SUBST(SIZEOF_CL_CHAR8)
AC_SUBST(SIZEOF_CL_CHAR16)
AC_SUBST(ALIGNOF_CL_CHAR)
AC_SUBST(ALIGNOF_CL_CHAR2)
AC_SUBST(ALIGNOF_CL_CHAR3)
AC_SUBST(ALIGNOF_CL_CHAR4)
AC_SUBST(ALIGNOF_CL_CHAR8)
AC_SUBST(ALIGNOF_CL_CHAR16)
AC_SUBST(BITSOF_CL_CHAR)

AC_CHECK_SIZEOF([cl_short], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_short2], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_short3], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_short4], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_short8], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_short16], [], [$OPENCL_INCLUDE])
SIZEOF_CL_SHORT=$ac_cv_sizeof_cl_short
SIZEOF_CL_SHORT2=$ac_cv_sizeof_cl_short2
SIZEOF_CL_SHORT3=$ac_cv_sizeof_cl_short3
SIZEOF_CL_SHORT4=$ac_cv_sizeof_cl_short4
SIZEOF_CL_SHORT8=$ac_cv_sizeof_cl_short8
SIZEOF_CL_SHORT16=$ac_cv_sizeof_cl_short16
AC_CHECK_ALIGNOF([cl_short], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_short2], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_short3], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_short4], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_short8], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_short16], [$OPENCL_INCLUDE])
ALIGNOF_CL_SHORT=$ac_cv_alignof_cl_short
ALIGNOF_CL_SHORT2=$ac_cv_alignof_cl_short2
ALIGNOF_CL_SHORT3=$ac_cv_alignof_cl_short3
ALIGNOF_CL_SHORT4=$ac_cv_alignof_cl_short4
ALIGNOF_CL_SHORT8=$ac_cv_alignof_cl_short8
ALIGNOF_CL_SHORT16=$ac_cv_alignof_cl_short16
# AS_VAR_ARITH([BITSOF_CL_SHORT], [8 * $SIZEOF_CL_SHORT])
BITSOF_CL_SHORT=$(( 8 * $SIZEOF_CL_SHORT ))
AC_SUBST(SIZEOF_CL_SHORT)
AC_SUBST(SIZEOF_CL_SHORT2)
AC_SUBST(SIZEOF_CL_SHORT3)
AC_SUBST(SIZEOF_CL_SHORT4)
AC_SUBST(SIZEOF_CL_SHORT8)
AC_SUBST(SIZEOF_CL_SHORT16)
AC_SUBST(ALIGNOF_CL_SHORT)
AC_SUBST(ALIGNOF_CL_SHORT2)
AC_SUBST(ALIGNOF_CL_SHORT3)
AC_SUBST(ALIGNOF_CL_SHORT4)
AC_SUBST(ALIGNOF_CL_SHORT8)
AC_SUBST(ALIGNOF_CL_SHORT16)
AC_SUBST(BITSOF_CL_SHORT)

AC_CHECK_SIZEOF([cl_int], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_int2], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_int3], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_int4], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_int8], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_int16], [], [$OPENCL_INCLUDE])
SIZEOF_CL_INT=$ac_cv_sizeof_cl_int
SIZEOF_CL_INT2=$ac_cv_sizeof_cl_int2
SIZEOF_CL_INT3=$ac_cv_sizeof_cl_int3
SIZEOF_CL_INT4=$ac_cv_sizeof_cl_int4
SIZEOF_CL_INT8=$ac_cv_sizeof_cl_int8
SIZEOF_CL_INT16=$ac_cv_sizeof_cl_int16
AC_CHECK_ALIGNOF([cl_int], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_int2], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_int3], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_int4], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_int8], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_int16], [$OPENCL_INCLUDE])
ALIGNOF_CL_INT=$ac_cv_alignof_cl_int
ALIGNOF_CL_INT2=$ac_cv_alignof_cl_int2
ALIGNOF_CL_INT3=$ac_cv_alignof_cl_int3
ALIGNOF_CL_INT4=$ac_cv_alignof_cl_int4
ALIGNOF_CL_INT8=$ac_cv_alignof_cl_int8
ALIGNOF_CL_INT16=$ac_cv_alignof_cl_int16
# AS_VAR_ARITH([BITSOF_CL_INT], [8 * $SIZEOF_CL_INT])
BITSOF_CL_INT=$(( 8 * $SIZEOF_CL_INT ))
AC_SUBST(SIZEOF_CL_INT)
AC_SUBST(SIZEOF_CL_INT2)
AC_SUBST(SIZEOF_CL_INT3)
AC_SUBST(SIZEOF_CL_INT4)
AC_SUBST(SIZEOF_CL_INT8)
AC_SUBST(SIZEOF_CL_INT16)
AC_SUBST(ALIGNOF_CL_INT)
AC_SUBST(ALIGNOF_CL_INT2)
AC_SUBST(ALIGNOF_CL_INT3)
AC_SUBST(ALIGNOF_CL_INT4)
AC_SUBST(ALIGNOF_CL_INT8)
AC_SUBST(ALIGNOF_CL_INT16)
AC_SUBST(BITSOF_CL_INT)

AC_CHECK_SIZEOF([cl_long], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_long2], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_long3], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_long4], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_long8], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_long16], [], [$OPENCL_INCLUDE])
SIZEOF_CL_LONG=$ac_cv_sizeof_cl_long
SIZEOF_CL_LONG2=$ac_cv_sizeof_cl_long2
SIZEOF_CL_LONG3=$ac_cv_sizeof_cl_long3
SIZEOF_CL_LONG4=$ac_cv_sizeof_cl_long4
SIZEOF_CL_LONG8=$ac_cv_sizeof_cl_long8
SIZEOF_CL_LONG16=$ac_cv_sizeof_cl_long16
AC_CHECK_ALIGNOF([cl_long], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_long2], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_long3], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_long4], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_long8], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_long16], [$OPENCL_INCLUDE])
ALIGNOF_CL_LONG=$ac_cv_alignof_cl_long
ALIGNOF_CL_LONG2=$ac_cv_alignof_cl_long2
ALIGNOF_CL_LONG3=$ac_cv_alignof_cl_long3
ALIGNOF_CL_LONG4=$ac_cv_alignof_cl_long4
ALIGNOF_CL_LONG8=$ac_cv_alignof_cl_long8
ALIGNOF_CL_LONG16=$ac_cv_alignof_cl_long16
# AS_VAR_ARITH([BITSOF_CL_LONG], [8 * $SIZEOF_CL_LONG])
BITSOF_CL_LONG=$(( 8 * $SIZEOF_CL_LONG ))
AC_SUBST(SIZEOF_CL_LONG)
AC_SUBST(SIZEOF_CL_LONG2)
AC_SUBST(SIZEOF_CL_LONG3)
AC_SUBST(SIZEOF_CL_LONG4)
AC_SUBST(SIZEOF_CL_LONG8)
AC_SUBST(SIZEOF_CL_LONG16)
AC_SUBST(ALIGNOF_CL_LONG)
AC_SUBST(ALIGNOF_CL_LONG2)
AC_SUBST(ALIGNOF_CL_LONG3)
AC_SUBST(ALIGNOF_CL_LONG4)
AC_SUBST(ALIGNOF_CL_LONG8)
AC_SUBST(ALIGNOF_CL_LONG16)
AC_SUBST(BITSOF_CL_LONG)

AC_CHECK_SIZEOF([cl_float], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_float2], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_float3], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_float4], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_float8], [], [$OPENCL_INCLUDE])
AC_CHECK_SIZEOF([cl_float16], [], [$OPENCL_INCLUDE])
SIZEOF_CL_FLOAT=$ac_cv_sizeof_cl_float
SIZEOF_CL_FLOAT2=$ac_cv_sizeof_cl_float2
SIZEOF_CL_FLOAT3=$ac_cv_sizeof_cl_float3
SIZEOF_CL_FLOAT4=$ac_cv_sizeof_cl_float4
SIZEOF_CL_FLOAT8=$ac_cv_sizeof_cl_float8
SIZEOF_CL_FLOAT16=$ac_cv_sizeof_cl_float16
AC_CHECK_ALIGNOF([cl_float], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_float2], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_float3], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_float4], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_float8], [$OPENCL_INCLUDE])
AC_CHECK_ALIGNOF([cl_float16], [$OPENCL_INCLUDE])
ALIGNOF_CL_FLOAT=$ac_cv_alignof_cl_float
ALIGNOF_CL_FLOAT2=$ac_cv_alignof_cl_float2
ALIGNOF_CL_FLOAT3=$ac_cv_alignof_cl_float3
ALIGNOF_CL_FLOAT4=$ac_cv_alignof_cl_float4
ALIGNOF_CL_FLOAT8=$ac_cv_alignof_cl_float8
ALIGNOF_CL_FLOAT16=$ac_cv_alignof_cl_float16
# AS_VAR_ARITH([BITSOF_CL_FLOAT], [8 * $SIZEOF_CL_FLOAT])
BITSOF_CL_FLOAT=$(( 8 * $SIZEOF_CL_FLOAT ))
AC_SUBST(SIZEOF_CL_FLOAT)
AC_SUBST(SIZEOF_CL_FLOAT2)
AC_SUBST(SIZEOF_CL_FLOAT3)
AC_SUBST(SIZEOF_CL_FLOAT4)
AC_SUBST(SIZEOF_CL_FLOAT8)
AC_SUBST(SIZEOF_CL_FLOAT16)
AC_SUBST(ALIGNOF_CL_FLOAT)
AC_SUBST(ALIGNOF_CL_FLOAT2)
AC_SUBST(ALIGNOF_CL_FLOAT3)
AC_SUBST(ALIGNOF_CL_FLOAT4)
AC_SUBST(ALIGNOF_CL_FLOAT8)
AC_SUBST(ALIGNOF_CL_FLOAT16)
AC_SUBST(BITSOF_CL_FLOAT)

dnl
dnl write output
dnl
AC_CONFIG_FILES(
dnl ***** Makefiles *****
  Makefile
  src/opencl/Makefile
  src/tests/print-info/Makefile
  src/tests/vectoradd/Makefile
dnl ***** Path maps *****
  lib/smlcl-path-map:config/smlcl-path-map.in
dnl MLB files
  src/opencl/opencl.mlb:src/opencl/opencl_mlb.in
dnl SML files
  src/opencl/cl-sizes.sml:src/opencl/cl-sizes_sml.in)

dnl
dnl shell scripts
dnl
AC_CONFIG_FILES([
  bin/config-smlcl.sh:config/config-smlcl_sh.in
], [chmod +x bin/config-smlcl.sh])
AC_CONFIG_FILES([
  config/mk-mlb-files.sh:config/mk-mlb-files_sh.in
], [chmod +x config/mk-mlb-files.sh])

dnl
dnl run configuration commands
dnl

AC_CONFIG_COMMANDS(
  [src/opencl/config],
  [(cd src/opencl; make config)],
  [])

dnl
dnl generate wrapper MLB files
dnl
AC_CONFIG_COMMANDS(
    [make-mlb-files],
    [config/mk-mlb-files.sh],
    [])

AC_OUTPUT

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