configure.ac 4.4 KB
Newer Older
1 2 3
# See semver.org for version info
#################################

4 5 6 7 8
m4_define([VERSION_MAJOR], [0])
m4_define([VERSION_MINOR], [1])
m4_define([VERSION_PATCH], [0])
m4_define([VERSION_STRING], VERSION_MAJOR.VERSION_MINOR.VERSION_PATCH)

9 10
# Init build tools
##################
11

12
AC_INIT([aml],[VERSION_STRING],[swann@anl.gov])
13
AC_CONFIG_SRCDIR([include/aml.h])
14 15 16
AC_CONFIG_AUX_DIR([m4])
AC_CONFIG_MACRO_DIR([m4])
# automake should fail on any error
17
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects 1.12])
18

19 20
# Detect features
#################
21 22

AC_LANG([C])
23
AC_USE_SYSTEM_EXTENSIONS
24
AC_PROG_CC
25
AC_PROG_CC_C99
26
AM_PROG_CC_C_O
27 28
AC_PROG_CPP
AC_TYPE_SIZE_T
29
AC_TYPE_INTPTR_T
30 31
AC_PROG_AWK
AC_PROG_GREP
32 33 34 35 36 37 38 39 40 41
AM_PROG_AR
LT_INIT

# Extra dependencies, configuration
###################################

AC_SUBST([PACKAGE_VERSION_MAJOR],[VERSION_MAJOR])
AC_SUBST([PACKAGE_VERSION_MINOR],[VERSION_MINOR])
AC_SUBST([PACKAGE_VERSION_PATCH],[VERSION_PATCH])

42
# support for testing with valgrind
43 44
###################################

45 46 47 48 49 50 51 52 53 54 55 56
AC_ARG_ENABLE(valgrind,
[AS_HELP_STRING([--enable-valgrind],[Also valgrind on checks (default is no).])],
[valgrind=true],[valgrind=false])

if [[ "x$valgrind" = xtrue ]]; then
	AC_PATH_PROG(VALGRIND, valgrind, no)
	if [[  "x$VALGRIND" = xno ]]; then
		AC_MSG_ERROR([Valgrind not found in PATH. ])
	fi
fi
AM_CONDITIONAL([TEST_VALGRIND],[test "x$valgrind" = xtrue])

57
# support for compiling benchmarks
58 59
##################################

60 61 62 63 64
AC_ARG_ENABLE(benchmarks,
[AS_HELP_STRING([--enable-benchmarks],[Compile additional benchmarks (default is no).])],
[benchmarks=true],[benchmarks=false])

if [[ "x$benchmarks" = xtrue ]]; then
65
	AC_OPENMP
66 67 68 69
	AC_CHECK_LIB(m, sqrt)
fi
AM_CONDITIONAL([ADD_BENCHMARKS],[test "x$benchmarks" = xtrue])

70 71
AC_CHECK_LIB(dl, dlopen)

72
# add pthread support.
73 74
######################

75
# doc in m4/ax_pthread.m4. Defines automake PTHREAD_CFLAGS and PTHREAD_LIBS
76
AX_PTHREAD([],[AC_MSG_ERROR([Cannot find how to compile with pthreads.])])
77 78
CC="$PTHREAD_CC"

79
# NUMA support
80 81
##############

82 83 84
AC_CHECK_HEADERS([numa.h],,[AC_MSG_ERROR([AML requires libnuma headers.])])
AC_CHECK_HEADERS([numaif.h],,[AC_MSG_ERROR([AML requires libnuma headers.])])
AC_CHECK_LIB(numa, mbind,,[AC_MSG_ERROR([AML requires libnuma.])])
85

86
# check doxygen + sphinx for documentation build
87 88
################################################

89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen], [no])
AC_CHECK_PROG([SPHINXBUILD], [sphinx-build], [sphinx-build], [no])
if [[ "x$DOXYGEN" != xno ]]; then
	if [[ "x$SPHINXBUILD" != xno ]]; then
		AC_MSG_NOTICE([Doxygen and Sphinx found, documentation will be build])
		BUILD_DOCS=yes
	else
		AC_MSG_NOTICE([Sphinx not found, cannot build documentation])
		BUILD_DOCS=no
	fi
else
	AC_MSG_NOTICE([Doxygen not found, cannot build documentation])
	BUILD_DOCS=no
fi
AM_CONDITIONAL([BUILD_DOCS],[ test "x$BUILD_DOCS" = xyes ])

105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
# check nvidia compiler and libraries
#####################################

BUILD_CUDA=no
AC_DEFINE([HAVE_CUDA], [0], [Whether aml support cuda library calls.])
AC_DEFINE([RUN_CUDA], [0], [Whether the machine on which aml is compiled can run cuda code.])

# Check compilation features
AC_CHECK_PROG([NVCC], [nvcc], [nvcc], [no])
AC_CHECK_LIB(cudart, cudaMalloc, [CUDART=yes], [CUDART=no])
AC_CHECK_HEADERS([cuda.h], [CUDA_H=yes], [CUDA_H=no])
AC_CHECK_HEADERS([cuda_runtime.h], [CUDA_RUNTIME_H=yes], [CUDA_RUNTIME_H=no])

if [[ "x$NVCC"                != xno ]] && \
   [[ "x$CUDART"              = xyes ]] && \
   [[ "x$CUDA_H"              = xyes ]] && \
   [[ "x$CUDA_RUNTIME_H"      = xyes ]]
then
   BUILD_CUDA=yes
   AC_DEFINE([HAVE_CUDA], [1], [Whether aml support cuda library calls.])
fi

AM_CONDITIONAL([BUILD_CUDA],[ test "x$BUILD_CUDA" = xyes ])

# Check runtime features
if [[ "x$BUILD_CUDA" = xyes ]]; then
   LIBS="$LIBS -lcudart"
   RUN_CUDA=no
   AC_MSG_CHECKING([that cudart code runs without error])
   AC_RUN_IFELSE(
       [AC_LANG_PROGRAM([[
#include <cuda.h>
#include <cuda_runtime.h>]],
	 [int device; return cudaGetDevice(&device) == cudaSuccess ? 0 : 1;])],
	 [AC_DEFINE([RUN_CUDA], [1], [Whether the machine on which aml is compiled can run cuda code.])
         RUN_CUDA=yes],[])
   AC_MSG_RESULT($RUN_CUDA)
fi

AM_CONDITIONAL([RUN_CUDA],[ test "x$RUN_CUDA" = xyes ])

146 147
# Output
########
148

149
AC_CONFIG_HEADERS([include/config.h])
150 151 152

AC_CONFIG_FILES([Makefile
		 src/Makefile
153
		 include/Makefile
154
		 tests/Makefile
155
		 doc/Makefile
156
		 benchmarks/Makefile
157
		 o2lo
158
		 aml.pc
159
		 include/aml/utils/version.h], [chmod +x o2lo])
160
AC_OUTPUT