1AC_PREREQ([2.69])
2################################################################################
3dnl	************************************************************************
4dnl	******* the following line shall be commented in branches/... **********
5dnl define([librsbsvnversion],[esyscmd([sh -c "basename `svn info | grep ^URL | sed 's/URL: '//g` | tr -d '\n'"])])dnl
6dnl	************************************************************************
7define([librsbtodaydate],[esyscmd([sh -c "date '+%Y%m%d%H%M' | tr -d '\n'"])])dnl
8dnl define([librsbsvnrevision],[esyscmd([sh -c "svnversion -n"])])dnl
9dnl define([librsbsvnversion],[esyscmd([sh -c "git branch  | grep '^*' | tr -d '* \n' "])])dnl
10define([librsbsvnrevision],[Unversioned directory])dnl
11dnl	************************************************************************
12dnl	**** the following lines shall be updated at each release **************
13dnl	************************************************************************
14define([librsb_ver_major],[1])dnl
15define([librsb_ver_minor],[2])dnl
16define([librsb_ver_patch],[0])dnl
17define([librsb_ver_prers],[10])dnl
18dnl	************************************************************************
19define([librsb_ver_string],librsb_ver_major.librsb_ver_minor.librsb_ver_patch)dnl
20define([librsb_librsbvernum],[librsb_ver_major"0"librsb_ver_minor"01"])dnl
21define([librsb_abi_vernum],[0:0:0])dnl
22define([librsb_lib_string],librsb_librsbvernum)dnl
23define([librsb_release],librsb_ver_string[.]librsb_ver_prers)dnl
24define([librsbversion],[ifelse(librsbsvnversion,[master],librsbsvnrevision,librsb_release)])dnl
25dnl define([librsbversion],[ifelse(librsbsvnversion,[trunk],[trunk],librsb_ver_major.librsb_ver_minor.librsb_ver_patch[]librsb_ver_prers)])dnl
26AC_INIT([librsb],[librsbversion],[michelemartone_AT_users_DOT_sourceforge_DOT_net])
27dnl
28# The following are valid for both trunk and release version.
29# It indicates the version this trunk is loosely related to.
30LIBRSB_VER_MAJOR=librsb_ver_major
31LIBRSB_VER_MINOR=librsb_ver_minor
32LIBRSB_VER_PATCH=librsb_ver_patch
33LIBRSB_LIBRSB_VER=librsb_librsbvernum
34if test x"librsbsvnversion" = x"trunk" ; then
35LIBRSB_VER_PRERS="-trunk"
36else
37LIBRSB_VER_PRERS=."librsb_ver_prers"
38fi
39LIBRSB_VER_DATE="librsbtodaydate"
40LIBRSB_VERSION="librsbversion"
41LIBRSB_MAIN_RELEASE="librsb_ver_string"
42LIBRSB_ABI_VERSION="librsb_abi_vernum"
43AC_SUBST(LIBRSB_VER_MAJOR)
44AC_SUBST(LIBRSB_VER_MINOR)
45AC_SUBST(LIBRSB_VER_PATCH)
46AC_SUBST(LIBRSB_VER_DATE)
47AC_SUBST(LIBRSB_VER_PRERS)
48AC_SUBST(LIBRSB_LIBRSB_VER)
49AC_SUBST(LIBRSB_VERSION)
50AC_SUBST(LIBRSB_MAIN_RELEASE)
51AC_SUBST(LIBRSB_ABI_VERSION)
52################################################################################
53SVN_REVISION="librsbsvnrevision"
54AH_TEMPLATE([SVN_REVISION])
55AC_DEFINE(SVN_REVISION,"librsbsvnrevision",[SVN REVISION])
56AC_SUBST(SVN_REVISION)
57AH_TEMPLATE([COPYRIGHT_STRING])
58AC_DEFINE(COPYRIGHT_STRING,"Copyright (c) 2008-2021 Michele Martone",[])
59dnl AC_SUBST([COPYRIGHT_STRING],["Copyright (c) 2008-2021 Michele Martone"])
60AC_COPYRIGHT([Copyright (c) 2008-2021, Michele Martone])
61################################################################################
62AM_INIT_AUTOMAKE
63LT_INIT
64AC_CONFIG_MACRO_DIR([m4])
65dnl AC_PROG_FC
66AC_PROG_FC(xlf2003 xlf2003_r ifort gfortran )
67m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]),[2.60]),-1, [],[AC_OPENMP()])
68dnl AC_PROG_CXX(xlC xlC_r7 xlC_r4 xlC_r g++ pgCC )
69# on epsilon cc is not reloaded with modules
70AC_PROG_CC(xlc_r xlc icc pgcc gcc cc)
71# ... Makefile.am:45: compiling `unroll.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'
72AM_PROG_CC_C_O
73# libtoolize if autoconf complains for the following
74AM_PROG_AS
75#AC_USE_SYSTEM_EXTENSIONS
76#AC_PROG_C
77#AC_PROG_INSTALL
78dnl AC_PROG_RANLIB
79AC_PROG_AWK
80AC_PROG_GREP
81AC_CHECK_SIZEOF([void *])
82AC_CHECK_SIZEOF([char])
83dnl AC_CHECK_SIZEOF([unsigned char])
84AC_CHECK_SIZEOF([int])
85dnl AC_CHECK_SIZEOF([unsigned int])
86AC_CHECK_SIZEOF([short int])
87dnl AC_CHECK_SIZEOF([short unsigned int])
88AC_CHECK_SIZEOF([long])
89AC_CHECK_SIZEOF([long int])
90dnl AC_CHECK_SIZEOF([long unsigned int])
91AC_CHECK_SIZEOF([long long int])
92dnl AC_CHECK_SIZEOF([long long unsigned int])
93AC_CHECK_SIZEOF([size_t])
94AC_CHECK_SIZEOF([float])
95AC_CHECK_SIZEOF([double])
96AC_CHECK_SIZEOF([long double])
97# to use complex we need a specialized header
98AC_CHECK_SIZEOF([complex])
99AC_CHECK_SIZEOF([float complex])
100AC_CHECK_SIZEOF([double complex])
101#
102m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]),[2.60]),-1, [],[AC_OPENMP()])
103#
104AC_CHECK_PROG([have_grep],[grep],[yes],[no])
105AC_CHECK_PROG([have_sed],[sed],[yes],[no])
106AC_CHECK_PROGS([OCTAVE],[$OCTAVE octave],[false],[])
107AC_CHECK_PROGS([DOXYGEN],[$DOXYGEN doxygen],[false],[])
108AC_CHECK_PROGS([HELP2MAN],[$HELP2MAN help2man],[false],[])
109AC_CHECK_PROGS([M4],[$M4 gm4 m4 /opt/freeware/bin/m4],[false],[])
110AC_CHECK_PROGS([GREP],[$GREP ggrep grep],[false],[])
111AC_CHECK_PROGS([SED],[$SED gsed sed],[false],[])
112AC_CHECK_PROGS([CUT],[$CUT gcut cut],[false],[])
113AC_CHECK_PROGS([NPROC],[$NPROC nproc],[false],[])
114dnl Precious variables:
115AC_ARG_VAR([M4],[M4 macro preprocessor])
116AC_ARG_VAR([OCTAVE],[GNU Octave executable])
117AC_ARG_VAR([AR],[Library archiver program])
118AC_ARG_VAR([ARFLAGS],[Library archiver program flags])
119AC_ARG_VAR([LD],[Linker program])
120AC_ARG_VAR([DOXYGEN],[Doxygen program for generating documentation from librsb source code])
121AC_ARG_VAR([HELP2MAN],[Help2man is a program for generating man pages from program help output])
122AC_ARG_VAR([RSB_USER_SET_MEM_HIERARCHY_INFO],[Memory hierarchy info string for librsb; e.g.: L2:4/64/512K,L1:8/64/24K])
123AC_ARG_VAR([OPENMP_CFLAGS],[C compilation flags for OpenMP])
124AC_ARG_VAR([OPENMP_FCFLAGS],[Fortran compilation flags for OpenMP])
125dnl AC_ARG_VAR([SED],["sed program."])
126dnl AC_ARG_VAR([GREP],["grep program."])
127#
128AC_CONFIG_HEADERS([rsb-config.h],[sed 's/^#define /#define RSB_/g;s/ RSB_RSB_/ RSB_/g' rsb-config.h > rsb-config.h.tmp ; echo '#endif /* RSB_CONFIG_H_INCLUDED */' >> rsb-config.h.tmp ; cat $srcdir/rsb_license_header.inc $srcdir/rsb-config.h.hin rsb-config.h.tmp > rsb-config.h ; rm rsb-config.h.tmp])
129AC_C_BIGENDIAN()
130AC_FUNC_VPRINTF
131AC_C_CONST()
132AC_C_INLINE()
133AC_TYPE_SIZE_T()
134dnl AC_STRUCT_TM()
135dnl AC_HEADER_STDBOOL
136dnl AC_C_VOLATILE
137dnl AC_CHECK_TYPES([ptrdiff_t])
138#
139AC_CHECK_FUNC([mlockall], AC_DEFINE([HAVE_MLOCKALL], [1], [If present, the mlockall function makes all allocations memory resident.]))
140AC_CHECK_FUNC([sysconf], AC_DEFINE([HAVE_SYSCONF], [1], [If present, the sysconf function gives lots of system info.]))
141dnl AC_CHECK_FUNC([hwloc_topology_init], AC_DEFINE([HAVE_HWLOC], [1], [If present, the hwloc_topology_init function gives lots of system info.]))
142AC_CHECK_FUNC([gethostname], AC_DEFINE([HAVE_GETHOSTNAME], [1], [If present, will give us host name.]))
143AC_CHECK_FUNC([posix_memalign], AC_DEFINE([HAVE_POSIX_MEMALIGN], [1], [The POSIX aligned memory allocator.(The function posix_memalign() is available since glibc 2.1.91)]))
144AC_CHECK_FUNC([memalign], AC_DEFINE([HAVE_MEMALIGN], [1], [This function is obsolete.]))
145AC_CHECK_FUNC([getenv], AC_DEFINE([HAVE_GETENV], [1], [Get an environment variable.]))
146AC_CHECK_FUNC([fileno], AC_DEFINE([HAVE_FILENO], [1], [fileno(): C FILE to posix file descriptor.]))
147dnl AC_CHECK_FUNC([gzdirect], AC_DEFINE([HAVE_GZDIRECT], [1], []))
148
149AC_CHECK_FUNCS([rand isatty])
150AC_CHECK_FUNCS([sched_getaffinity])
151AC_CHECK_FUNCS([memset strncmp])
152AC_CHECK_FUNCS([dup])
153dnl AC_CHECK_FUNCS([read write])
154AC_CHECK_FUNCS([fread fwrite])
155#dnl	***********************************************************************
156#dnl					THESE ARE ESSENTIAL
157#dnl	***********************************************************************
158AC_CHECK_HEADERS([libgen.h])
159AC_CHECK_HEADERS([sched.h])
160AC_CHECK_HEADERS([dmalloc.h])
161dnl	AC_CHECK_HEADERS([duma.h])
162AC_CHECK_FUNC([getopt_long], AC_DEFINE([HAVE_GETOPT_LONG], [1], [getopt_long is GNU candy]))
163AC_CHECK_FUNC([times], AC_DEFINE([HAVE_TIMES], [1], [times]))
164AC_CHECK_FUNC([gettimeofday], AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [gettimeofday]))
165AC_CHECK_FUNC([setenv], AC_DEFINE([HAVE_SETENV], [1], [setenv]))
166dnl It would be nice to use alloca (on-stack allocator), but our code is not amenable for this.
167dnl AC_CHECK_FUNC([alloca], AC_DEFINE([HAVE_ALLOCA], [1], [alloca]))
168dnl AC_CHECK_HEADERS([alloca.h])
169AC_CHECK_HEADERS([omp.h])
170AC_CHECK_HEADERS([getopt.h])
171AC_CHECK_HEADERS([malloc.h memory.h])
172AC_CHECK_HEADERS([pthread.h]) dnl unused, for now
173AC_CHECK_HEADERS([papi.h])
174AC_CHECK_HEADERS([gsl/gsl_sort.h])
175AC_CHECK_HEADERS([times.h]) dnl for times (optional)
176AC_CHECK_HEADERS([sys/utsname.h])
177AC_CHECK_HEADERS([sys/resource.h]) dnl for getrusage (optional)
178AC_CHECK_HEADERS([complex.h])
179AC_CHECK_HEADERS([assert.h])
180AC_CHECK_HEADERS([rpc/xdr.h])
181AC_CHECK_HEADERS([sys/mman.h]) dnl mlockall
182AC_CHECK_HEADERS([stdint.h])
183AC_CHECK_HEADERS([unistd.h]) dnl read write
184AC_CHECK_HEADERS([stdio.h]) dnl printf
185AC_CHECK_HEADERS([stdarg.h]) dnl vprintf
186AC_CHECK_HEADERS([time.h]) dnl
187AC_CHECK_HEADERS([regex.h]) dnl
188AC_CHECK_HEADERS([string.h] [strings.h] [ctype.h]) dnl
189dnl
190AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
191#ifdef __MINGW32__
192#error "You are likely using MINGW (Minimalist GNU for Windows)."
193#else
194    /* "You are likely not using MINGW (Minimalist GNU for Windows)." */
195#endif
196])], [ac_cv_we_use_mingw=no], [ac_cv_we_use_mingw=yes])
197if test "x$ac_cv_we_use_mingw" = xyes; then
198	ac_cv_mingw_add="-D__USE_MINGW_ANSI_STDIO=1"
199      	AC_MSG_NOTICE([You are likely using MINGW (Minimalist GNU for Windows). Adding ${ac_cv_mingw_add} to compilation flags to avoid broken C99 support.])
200	CFLAGS="${CFLAGS} ${ac_cv_mingw_add}"
201fi
202dnl
203dnl	In the following, will use  AC_ARG_ENABLE  for proper options/features and  AC_ARG_WITH  for packages or environment or compilation switches.
204# rsbench-only LIBS and CFLAGS:
205RSB_RSBENCH_LIBS=
206RSB_RSBENCH_CFLAGS=
207dnl
208AC_ARG_WITH(math, AS_HELP_STRING([--with-math],[Specify the math library]), [if test "x$withval" = xno; then want_math_libs= ; else want_math_libs="$withval" ; fi], [want_math_libs="-lm"])
209AC_CHECK_HEADERS([math.h], [LIBS="${LIBS} $want_math_libs"], [break])
210
211AC_ARG_WITH(xdr, AS_HELP_STRING([--with-xdr],[Specify XDR library.  e.g.: --with-xdr="..." ]), [if test "x$withval" = xno; then want_xdr_libs= ; else want_xdr_libs="$withval" ; fi], [want_xdr_libs=" "])
212AC_CHECK_HEADERS([rpc/xdr.h])
213
214AH_TEMPLATE([RSB_WITH_HWLOC])
215AC_ARG_WITH(hwloc, AS_HELP_STRING([--with-hwloc],[Specify the hwloc library (EXPERIMENTAL)]), [if test "x$withval" = xno; then want_hwloc_libs= ; else want_hwloc_libs="$withval"; if test "x$want_hwloc_libs" = x"yes" ; then want_hwloc_libs="-lhwloc" ; fi; enable_hwloc=yes ; fi], [want_hwloc_libs=" "])
216AC_CHECK_HEADERS([hwloc.h], [if test "x$enable_hwloc" != x -a "x$want_hwloc_libs" != x ; then LIBS="${LIBS} $want_hwloc_libs"; fi;], [break])
217
218if test "x${CC}" = x"xlc" -o "x${CC}" = x"xlc_r"  ; then
219      	AC_MSG_NOTICE([Disabling XDR support: our API was only tested on Linux.])
220	want_xdr_libs=
221	ac_cv_header_rpc_xdr_h=no
222fi
223
224if test x"$want_xdr_libs" != x"" && test "x$ac_cv_header_rpc_xdr_h" = xyes ; then
225	dnl use --without-xdr to disable it
226      	AC_MSG_NOTICE([Enabling xdr support.])
227	AC_DEFINE([RSB_WANT_XDR_SUPPORT],[1],[experimental.])
228	LIBS="${LIBS} $want_xdr_libs"
229	else
230	AC_MSG_WARN([No xdr headers found.])
231	AC_DEFINE([RSB_WANT_XDR_SUPPORT],[0],[experimental.])
232fi
233dnl
234AH_TEMPLATE([RSB_WANT_DMALLOC])
235AC_ARG_WITH(dmalloc, AS_HELP_STRING([--with-dmalloc],[With dmalloc (experimental).]),
236[if test "x$withval" = xyes; then
237	enable_dmalloc=1;
238	if test x"$ac_cv_header_dmalloc_h" = xyes ; then
239		LIBS="${LIBS} -ldmalloc"
240		DMALLOC_CFLAGS="-DDMALLOC"
241	fi
242 else
243	enable_dmalloc=0
244 fi],[enable_dmalloc=0])
245AC_DEFINE_UNQUOTED([RSB_WANT_DMALLOC],[$enable_dmalloc],[])
246dnl
247dnl
248dnl
249AH_TEMPLATE([RSB_WANT_MKL])
250AC_ARG_WITH(mkl-include, AS_HELP_STRING([--with-mkl-include],[Specify the MKL (Intel Math Kernel Library) library headers path. e.g.: --with-mkl-include="/opt/intel/mkl/include". ]), [if test "x$withval" = xno; then MKL_INCLUDE= ; else if test "x$withval" = xyes; then MKL_INCLUDE="" ; else MKL_INCLUDE="$withval" ; fi  ; fi], [true] )
251
252AC_ARG_WITH(mkl, AS_HELP_STRING([--with-mkl],[Specify the MKL (Intel Math Kernel Library) library to be used with the benchmarking program. E.g.: --with-mkl="...". Include options should be specified in the MKL_INCLUDE environment variable. ]), [if test "x$withval" = xno; then want_mkl_libs= ; else if test "x$withval" = xyes; then want_mkl_libs="-static -L/opt/intel/mkl/lib/ia32/ -lmkl_solver -Wl,--start-group -lmkl_intel -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -lpthread" ; else want_mkl_libs="$withval" ; fi  ; fi], [true] )
253
254dnl
255dnl
256dnl
257AC_ARG_WITH(zlib, AS_HELP_STRING([--with-zlib],[Specify Z library.  e.g.: --with-zlib="..." for reading gzip-compressed matrix files.]), [if test "x$withval" = xno; then want_zlib_libs="" ; else want_zlib_libs="$withval" ; fi], [want_zlib_libs=""])
258AC_CHECK_HEADERS([zlib.h])
259want_zlib_support="no"
260if test x"$want_zlib_libs" != x"" && test "x$ac_cv_header_zlib_h" = xyes ; then
261	dnl use --without-zlib to disable it
262      	AC_MSG_NOTICE([Enabling zlib support.])
263	AC_DEFINE([RSB_WANT_ZLIB_SUPPORT],[1],[Support for reading gzipped matrices.])
264	if test x"$want_zlib_libs" = x"yes" ; then want_zlib_libs=-lz; fi
265	LIBS="${LIBS} $want_zlib_libs"
266	want_zlib_support="yes"
267	else
268dnl	AC_MSG_WARN([No zlib headers found.])
269	AC_DEFINE([RSB_WANT_ZLIB_SUPPORT],[0],[Support for reading gzipped matrices.])
270	want_zlib_support="no"
271fi
272dnl
273dnl
274dnl
275AC_ARG_WITH(ompio, AS_HELP_STRING([--with-ompio],[Use OpenMP and fgets_unlocked() for parallel I/O]), [if test "x$withval" = xno; then want_ompio="no" ; else want_ompio="yes" ; fi], [want_ompio="no"])
276
277if test x"$want_ompio" = x"yes" ; then
278      	AC_MSG_NOTICE([Enabling OpenMP + fgets_unlocked() IO support.])
279	AC_DEFINE([RSB_WANT_OMPIO_SUPPORT],[1],[Support for reading matrices in parallel (Experimental, untested).])
280	else
281	AC_DEFINE([RSB_WANT_OMPIO_SUPPORT],[0],[Support for reading matrices in parallel (Experimental, untested).])
282fi
283dnl
284dnl
285dnl
286AC_CHECK_HEADERS([limits.h], [break], [break])
287AC_CHECK_HEADERS([signal.h], [break], [break])
288dnl AC_CHECK_HEADERS([bits/sigaction.h], [], [],
289dnl [#ifdef RSB_HAVE_SIGNAL_H
290dnl # include <signal.h>
291dnl #endif
292dnl ])
293# an AIX specific check
294AC_CHECK_HEADERS([sys/systemcfg.h], [break], [break])
295AC_DEFINE([RSB_WANT_VERBOSE_MESSAGES],[0],[If set, the library will be much more verbose. Should be enabled for debugging purposes only.])
296AC_DEFINE([RSB_WANT_KERNELS_DEBUG],[1],[If set, RSB_WANT_KERNELS_DEBUG will enable comparative consistency checking of the multiplying kernels against a naive, trusted implementation.])
297AC_DEFINE([RSB_SORT_IN_PLACE],[0],[If set, sort operations will happen in place.])
298dnl AC_DEFINE([RSB_WANT_BLOCK_TRAILING_STRUCT_QUICK],[0],[This flag is still unsupported])
299AC_DEFINE([RSB_BLOCK_SMALL_INDICES],[1],[If set, the library will use smaller indices in blocks.])
300dnl
301dnl
302detected_memhinfo=`$srcdir/scripts/linux-sys-cache.sh`;
303dnl
304AC_ARG_WITH(nounroll-cflag, AS_HELP_STRING([--with-nounroll-cflag],[Specify the no unroll compiler flag (if unset, will be guessed).]),
305        [if test "x$withval" = xno; then userset_nounroll_cflag="" ; else userset_nounroll_cflag="$withval" ; fi] , [userset_nounroll_cflag="";])
306dnl
307default_want_int_verrbosity="0";
308AC_ARG_ENABLE(internals-error-verbosity, AS_HELP_STRING([--enable-internals-error-verbosity],[Set error verbosity level of library internal functions (RSB_INT_ERR_VERBOSITY): can be 0 (no printout at all, never), 1 (on error). Use this to debug the library itself. Experimental.]),
309        [if test "x$enableval" = xno; then want_int_verrbosity="${default_want_int_verrbosity}" ; else want_int_verrbosity="$enableval" ; fi] , [want_int_verrbosity="${default_want_int_verrbosity}";])
310dnl
311default_want_ext_verrbosity="0";
312AC_ARG_ENABLE(interface-error-verbosity, AS_HELP_STRING([--enable-interface-error-verbosity],[Set error verbosity level of library interface functions (RSB_OUT_ERR_VERBOSITY): can be 0 (no printout), 1 (printout on error, if requested), 2 (printout on error), 99 (exit on error). Use this to debug your program or to better understand the library usage. ]),
313        [if test "xenableval" = xno; then want_ext_verrbosity="${default_want_ext_verrbosity}" ; else want_ext_verrbosity="$enableval" ; fi] , [want_ext_verrbosity="${default_want_ext_verrbosity}";])
314dnl
315default_want_io_level=0;
316AC_ARG_ENABLE(io-level, AS_HELP_STRING([--enable-io-level],[Set input/output functionality level (RSB_WANT_IO_LEVEL), a number between 0 and 7, as any sum combination of 1 (standard input/output), 2 (standard error), 4 (arbitrary descriptors). (experimental).]),
317        [if test "x$enableval" = xno; then want_io_level="${default_want_io_level}" ; else want_io_level="$enableval" ; fi] , [want_io_level="7";])
318dnl
319default_want_max_threads="160"
320if test x"${NPROC}" != xfalse -a "`${NPROC}`" -gt $default_want_max_threads; then default_want_max_threads="`${NPROC}`"; fi
321AC_ARG_WITH(max-threads, AS_HELP_STRING([--with-max-threads],[Maximal number of supported threads (default 160).]),
322        [if test "x$withval" = xno; then want_max_threads="$default_want_max_threads" ; else want_max_threads="$withval" ; fi] , [want_max_threads="$default_want_max_threads";])
323dnl
324AC_ARG_WITH(memhinfo, AS_HELP_STRING([--with-memhinfo],[Compile with user specified memory hierarchy information, which can be overridden by runtime detection and runtime read of RSB_USER_SET_MEM_HIERARCHY_INFO environment variable.]),
325        [if test "x$withval" = xno; then memhinfo="" ; openmp_flags= ; else memhinfo="$withval" ; fi] , [memhinfo="";])
326if test "x${detected_memhinfo}" = x -a "x${memhinfo}" = x; then
327  FALLBACK_MEM_HIERARCHY_INFO='L2:4/64/512K,L1:8/64/24K'
328  AC_MSG_WARN([Failed detecting memory hierarchy info: setting to fallback value of ${FALLBACK_MEM_HIERARCHY_INFO}. If you know it, consider setting it via e.g. --with-memhinfo=${FALLBACK_MEM_HIERARCHY_INFO} ."])
329  memhinfo="${FALLBACK_MEM_HIERARCHY_INFO}"
330fi
331AC_SUBST([RSB_USER_SET_MEM_HIERARCHY_INFO],"${memhinfo}")
332AC_SUBST([RSB_DETECTED_MEM_HIERARCHY_INFO],"${detected_memhinfo}")
333dnl AC_DEFINE([RSB_USER_SET_MEM_HIERARCHY_INFO],[$memhinfo],[If not null, the library will rely on this for memory hierarchy info.])
334dnl
335dnl
336AC_ARG_WITH(ar, AS_HELP_STRING([--with-ar],[Specify the library archiver program explicitly.]), [if test "x$withval" = xno; then true ; else AR="$withval" ; fi] , [ AR="$AR" ] )
337AC_ARG_WITH(arflags, AS_HELP_STRING([--with-arflags],[Specify the library archiver program flags explicitly.]), [if test "x$withval" = xno; then true ; else ARFLAGS="$withval" ; fi] , [ ARFLAGS="$ARFLAGS" ] )
338AC_ARG_WITH(m4, AS_HELP_STRING([--with-m4],[Specify the M4 preprocessor program explicitly.]), [if test "x$withval" = xno; then true ; else M4="$withval" ; fi] , [true;] )
339dnl
340m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]),[2.60]),-1, [
341AC_ARG_WITH(openmp, AS_HELP_STRING([--with-openmp],[Use the OpenMP multithreading mechanisms.]),
342        [if test "x$withval" = xno; then enable_openmp=no ; openmp_flags= ; else openmp_flags="$withval" ; enable_openmp=yes ; fi] , [enable_openmp=yes])
343],[])
344dnl
345if test "x$enable_openmp" = x ; then
346	enable_openmp=yes
347fi
348dnl
349if test "x$enable_openmp" != x"yes" && test "x$want_ompio" = x"yes"; then
350	AC_MSG_ERROR([You must enable OpenMP if you want OpenMP-backed I/O!])
351fi
352dnl
353#dnl	***********************************************************************
354dnl define(DEFAULT_MATRIX_OPS,[spmv_uaua,spmv_sxsa,spmv_uxua,infty_norm,rowssums,spmv_sasa,spsv_sxsx,spsv_uxua])
355define(DEFAULT_MATRIX_OPS,[spmv_uaua,spmv_uauz,spmv_uxua,spmv_unua,spmv_sasa,spsv_uxua,spmv_sxsa,spsv_sxsx,infty_norm,rowssums,scale])
356dnl define(DEFAULT_MATRIX_OPS,[spmv_uaua,spmv_uauz,spmv_uxua,spmv_unua,spmv_sasa,spmv_sxsa,infty_norm,rowssums,scale])
357dnl define(DEFAULT_UNROLLS,[1,2,4])
358define(DEFAULT_UNROLLS,[1])
359define(RSB_M4_SIMPLE_LOOP_UNROLL_DEFAULT_FACTOR,[16])
360dnl define(DEFAULT_TYPES,[int,double])
361define(DEFAULT_TYPES,["double,float,float complex,double complex"])
362#dnl	***********************************************************************
363# the default block unrolls
364default_unrolls=DEFAULT_UNROLLS
365default_util_unrolls=RSB_M4_SIMPLE_LOOP_UNROLL_DEFAULT_FACTOR
366# the default types for macro-generated code
367blas_matrix_types="double,float,float complex,double complex"
368psblas_matrix_types="${blas_matrix_types}"
369non_blas_matrix_types="int"
370all_matrix_types="$non_blas_matrix_types,$blas_matrix_types"
371#default_types=int,double,float,float complex, double complex
372# float complex and double complex are c99 types
373default_types=DEFAULT_TYPES
374# the default matrix operations
375blas_matrix_ops=spmv_uaua,spmv_uauz,spmv_uxua,spmv_unua,spmv_sasa,spsv_uxua,spmv_sxsa,spsv_sxsx
376dnl
377psblas_matrix_ops="${blas_matrix_ops}",infty_norm,rowssums,scale
378dnl
379dnl extra_blas_matrix_ops=,spmv_sxsx,spmv_uxux
380extra_blas_matrix_ops= # 20140719 these kernels are not active at the moment
381#
382non_blas_matrix_ops=infty_norm,rowssums,scale
383dnl non_blas_matrix_ops=...spmm_az # 20140719 this kernel is not active at the moment
384all_matrix_ops="$blas_matrix_ops,$non_blas_matrix_ops$extra_blas_matrix_ops"
385#
386default_matrix_ops=DEFAULT_MATRIX_OPS
387#dnl	***********************************************************************
388dnl AC_ARG_WITH(block-unrolls, AS_HELP_STRING([--with-block-unrolls],[Generate unrolled kernels for blocks with specified columns/rows (default:DEFAULT_UNROLLS)(experimental)]), [default_unrolls="$withval"],[default_unrolls="$default_unrolls"])
389#dnl	***********************************************************************
390dnl AC_ARG_WITH(row-unrolls, AS_HELP_STRING([--with-row-unrolls],[Generate unrolled kernels for blocks with specified rows (default:DEFAULT_UNROLLS)(experimental)]), [row_unrolls="$withval"],[row_unrolls="$default_unrolls"])
391row_unrolls="$default_unrolls"
392#dnl	***********************************************************************
393dnl AC_ARG_WITH(column-unrolls, AS_HELP_STRING([--with-column-unrolls],[Generate unrolled kernels for blocks with specified columns (default:DEFAULT_UNROLLS) (experimental)]), [column_unrolls="$withval"],[column_unrolls="$default_unrolls"])
394column_unrolls="$default_unrolls"
395#dnl	***********************************************************************
396AC_DEFINE([RSB_WANT_SPARSE_BLAS_LEVEL_1],[1],[If set, a reference, unoptimized Sparse BLAS Level 1 interface will be functional.])
397#dnl	***********************************************************************
398AC_ARG_ENABLE(matrix-types, AS_HELP_STRING([--enable-matrix-types],[Generate kernels for specified types (default:DEFAULT_TYPES) (you can specify 'all' to get all of them, or 'blas' for Sparse BLAS ones)]), [want_matrix_types="$enableval"],[want_matrix_types="$default_types"])
399#dnl	***********************************************************************
400AC_ARG_ENABLE(matrix-ops, AS_HELP_STRING([--enable-matrix-ops],[Generate kernels for specified matrix operations (default:DEFAULT_MATRIX_OPS) (you can specify 'all' to get all of them, or 'blas' for only ones for Sparse BLAS, or 'psblas' for only ones for PSBLAS) (Experimental, the default "all" is recommended.)]), [want_matrix_ops="$enableval"],[want_matrix_ops="$default_matrix_ops"])
401#dnl	***********************************************************************
402AC_ARG_ENABLE(vector-utils-loop-unrolls, AS_HELP_STRING([--enable-vector-utils-loop-unrolls],[Loop unrolling of generated vector utility functions (default:RSB_M4_SIMPLE_LOOP_UNROLL_DEFAULT_FACTOR)]), [util_unrolls="$enableval"],[util_unrolls="$default_util_unrolls"])
403#dnl	***********************************************************************
404AC_ARG_ENABLE(octave-testing, AS_HELP_STRING([--enable-octave-testing],[Enabling GNU Octave based testing.]),
405[if test "x$enableval" = xno; then
406	enable_octave_testing=no
407 else
408	enable_octave_testing=yes
409 fi],[enable_octave_testing=yes])
410#dnl	***********************************************************************
411if test "x$want_matrix_types" = xall; then
412	AC_MSG_NOTICE([Enabling all matrix types.])
413	want_matrix_types="${all_matrix_types}";
414else
415	true;
416	if test "x$want_matrix_types" = x"blas"; then
417		AC_MSG_NOTICE([Enabling all matrix types for Sparse BLAS (S,C,D,Z).])
418		want_matrix_types="${blas_matrix_types}";
419		#if test "x$enable_octave_testing" = xyes; then want_matrix_types=${want_matrix_types},int ; fi
420	else
421	    if test "x$want_matrix_types" = x"psblas"; then
422		AC_MSG_NOTICE([Enabling matrix types for Parallel Sparse BLAS (PSBLAS).])
423		want_matrix_types="${psblas_matrix_types}";
424		#if test "x$enable_octave_testing" = xyes; then want_matrix_types=${want_matrix_types},int ; fi
425	    else
426		true;
427	    fi
428	fi
429fi
430#dnl	***********************************************************************
431if test "x$want_matrix_ops" = xall; then
432	AC_MSG_NOTICE([Enabling all of the matrix ops.])
433	want_matrix_ops="${all_matrix_ops}";
434else
435	if test "x$want_matrix_ops" = xblas; then
436		AC_MSG_NOTICE([Enabling matrix ops for Sparse BLAS.])
437		want_matrix_ops="${blas_matrix_ops}";
438	else
439	    if test "x$want_matrix_ops" = xpsblas; then
440		AC_MSG_NOTICE([Enabling matrix ops for Parallel Sparse BLAS (PSBLAS).])
441		want_matrix_ops="${psblas_matrix_ops}";
442	    else
443		true;
444	    fi
445	fi
446fi
447#dnl	***********************************************************************
448if test x"$want_matrix_types" != x"$default_types" -o x"$want_matrix_ops" != x"$default_matrix_ops" -o x"$util_unrolls" != x"$default_util_unrolls"; then
449if test x"$M4" = x"false"; then
450	AC_MSG_ERROR([Did not specify an m4 processor, so code generation from m4 files is disabled (and so configure time specification of non default types, operations, unrolls) !])
451fi
452fi
453#dnl	***********************************************************************
454sparse_blas_interface_default=yes
455AC_ARG_ENABLE(sparse-blas-interface, AS_HELP_STRING([--disable-sparse-blas-interface],[Build a Sparse BLAS interface to librsb.]),
456[if test "x$enableval" = xno; then
457	sparse_blas_interface=no
458 else
459	sparse_blas_interface=yes
460 fi],[sparse_blas_interface="${sparse_blas_interface_default}"])
461#dnl	***********************************************************************
462enable_looping_kernels=no
463AH_TEMPLATE([RSB_WANT_LOOPING_KERNELS])
464#dnl	***********************************************************************
465AC_ARG_WITH(oski, AS_HELP_STRING([--with-oski],[OSKI comparative benchmarking (WARNING: be sure to set
466	OSKI_INCLUDE, OSKI_LUA_PATH, OSKI_PATH environment variables first). UNFINISHED.]),
467[if test "x$withval" = xno; then
468	enable_oski=no
469 else
470	enable_oski=yes
471 fi],[enable_oski=no])
472#dnl	***********************************************************************
473#AC_ARG_WITH(papi, AS_HELP_STRING([--with-papi],[PAPI (Performance Application Programming Interface). UNFINISHED.]),
474#[if test "x$withval" = xno; then
475#	enable_papi=no
476# else
477#	enable_papi=yes
478# fi],[enable_papi=no])
479#dnl	***********************************************************************
480AH_TEMPLATE([RSB_WITH_LIKWID])
481AC_ARG_WITH(likwid, AS_HELP_STRING([--with-likwid],[LIKWID support (will add the LIKWID_LIBS variable to LIBS and LIKWID_CFLAGS to CFLAGS). UNFINISHED.]),
482[if test "x$withval" = xno; then
483	enable_likwid=no
484 else
485	enable_likwid=yes
486 fi],[enable_likwid=no])
487#dnl	***********************************************************************
488AC_ARG_ENABLE(allocator-wrapper, AS_HELP_STRING([--enable-allocator-wrapper],[If enabled, librsb will keep count of internal memory allocations via a allocator functions wrappers.]),
489[if test "x$enableval" = xno; then
490	disable_allocator_wrapper=yes
491 else
492	disable_allocator_wrapper=no
493 fi],[disable_allocator_wrapper=yes])
494#dnl	***********************************************************************
495AC_ARG_ENABLE(alignment, AS_HELP_STRING([--disable-alignment],[By default, we allocate aligned memory. This can be disabled.]),
496[if test "x$enableval" = xno; then
497	enable_alignment=no
498 else
499	enable_alignment=yes
500 fi],[enable_alignment=yes])
501enable_b=yes
502enable_c=yes
503#dnl	***********************************************************************
504AC_ARG_ENABLE(librsb-stats, AS_HELP_STRING([--enable-librsb-stats],[If enabled, will allow collection of time statistics in librsb operations.]),
505[if test "x$enableval" = xno; then
506	enable_librsb_stats=no
507 else
508	enable_librsb_stats=yes
509 fi],[enable_librsb_stats=no])
510#dnl	***********************************************************************
511AC_ARG_ENABLE(rsb-num-threads, AS_HELP_STRING([--enable-rsb-num-threads],[RSB_NUM_THREADS environment variable to control number of threads (Experimental, with effect on rsb_spmv/rsb_spmm).]),
512[if test "x$enableval" = xno; then
513	enable_rsb_num_threads=no
514 else
515	enable_rsb_num_threads=yes
516 fi],[enable_rsb_num_threads=no])
517#dnl	***********************************************************************
518dnl AC_ARG_ENABLE(fortran-interface, AS_HELP_STRING([--disable-fortran-interface],[Fortran interface.]),
519dnl [if test "x$enableval" = xno; then
520dnl	enable_fortran=no
521dnl else
522dnl 	enable_fortran=yes
523dnl  fi],[enable_fortran=yes])
524#dnl	***********************************************************************
525AC_ARG_ENABLE(fortran-module-install, AS_HELP_STRING([--enable-fortran-module-install],[Install (compiler specific) Fortran module (blas_sparse.mod) (experimental).]),
526[if test "x$enableval" = xno; then
527	want_blas_sparse_mod_install=no
528 else
529	want_blas_sparse_mod_install=yes
530 fi],[want_blas_sparse_mod_install=no])
531#dnl	***********************************************************************
532want_install_pkg_config_default=no
533AC_ARG_ENABLE(pkg-config-install, AS_HELP_STRING([--enable-pkg-config-install],[Install pkg-config file (librsb.pc) installation.]),
534[if test "x$enableval" = x"yes"; then
535	want_install_pkg_config=yes
536	AC_MSG_NOTICE([Will install pkg-config librsb.pc file.])
537 else
538	want_install_pkg_config=yes
539	AC_MSG_NOTICE([Will not install pkg-config librsb.pc file (--enable-pkg-config-install to change).])
540 fi],[want_install_pkg_config="${want_install_pkg_config_default}"])
541#dnl	***********************************************************************
542dnl AC_ARG_ENABLE(fortran-blas-sparse-header-install, AS_HELP_STRING([--enable-fortran-blas-sparse-header-install],[Install (non standard) Sparse BLAS Fortran header (blas_sparse.fi) (experimental).]),
543dnl [if test "x$enableval" = xno; then
544dnl dnl 	want_blas_sparse_fi_install=no
545dnl  else
546dnl 	want_blas_sparse_fi_install=yes
547dnl fi],[want_blas_sparse_fi_install=no])
548dnl want_blas_sparse_fi_install="${sparse_blas_interface}"
549#dnl	***********************************************************************
550AC_ARG_ENABLE(doc-build, AS_HELP_STRING([--enable-doc-build],[If doxygen is detected or supplied (DOXYGEN environment variable), documentation will be rebuilt. If 'help2man' (HELP2MAN) is also present, it will be used to build additional man pages.]),
551[if test "x$enableval" = xno; then
552	want_build_doc=no
553 else
554	want_build_doc=yes
555 fi],[want_build_doc=no])
556#dnl	***********************************************************************
557AC_ARG_ENABLE(shlib-linked-examples, AS_HELP_STRING([--enable-shlib-linked-examples],[Shared library based examples (experimental: developer only).]),
558[if test "x$enableval" = xno; then
559	want_rsb_dl=no
560 else
561	want_rsb_dl=yes
562 fi],[want_rsb_dl=no])
563#dnl	***********************************************************************
564AC_ARG_ENABLE(c-examples, AS_HELP_STRING([--disable-c-examples],[C example programs building.]),
565[if test "x$enableval" = xno; then
566	enable_c_examples=no
567 else
568	enable_c_examples=yes
569 fi],[enable_c_examples=yes])
570#dnl	***********************************************************************
571AC_ARG_ENABLE(fortran-examples, AS_HELP_STRING([--disable-fortran-examples],[Fortran test and example programs generation and building. (experimental)]),
572[if test "x$enableval" = xno; then
573	enable_fortran_examples=no
574 else
575	enable_fortran_examples=yes
576 fi],[enable_fortran_examples=yes])
577#dnl	***********************************************************************
578AC_C_RESTRICT()
579AC_ARG_ENABLE(restrict, AS_HELP_STRING([--disable-restrict],[Use the restrict keyword.]),
580[if test "x$enableval" = xno; then
581	enable_restrict=no
582 else
583	enable_restrict=yes
584 fi],[enable_restrict=yes])
585#dnl	***********************************************************************
586AC_ARG_WITH(c99-flag, AS_HELP_STRING([--with-c99-flag],[Add the -std=c99 compilation flag to CFLAGS.]),
587[if test "x$withval" = xno; then
588	enable_c99=no
589 else
590	enable_c99=yes
591 fi],[enable_c99=yes])
592#dnl	***********************************************************************
593want_spsm_diagonal_check_default=yes
594AC_ARG_ENABLE(zero-division-checks-on-solve, AS_HELP_STRING([--enable-zero-division-checks-on-solve],[Prevents zero-division when performing triangular solution.]),
595[if test "x$enableval" = xyes; then
596	want_spsm_diagonal_check=yes
597 else
598	want_spsm_diagonal_check=no
599 fi],[want_spsm_diagonal_check="${want_spsm_diagonal_check_default}"])
600#dnl	***********************************************************************
601want_sigaction_in_rsbench=no
602AC_ARG_ENABLE(sigaction-interruptible-rsbench, AS_HELP_STRING([--enable-sigaction-interruptible-rsbench],[rsbench will be interruptible using sigaction (breaks the standard: may break the build.).]),
603[if test "x$enableval" = xyes; then
604	want_sigaction_in_rsbench=yes;
605 else
606	want_sigaction_in_rsbench=no;
607 fi],[want_sigaction_in_rsbench=no;])
608if test x$want_sigaction_in_rsbench = xno ; then
609	AC_DEFINE([RSB_WANT_ACTION_SIGNAL],[1],[experimental.])
610fi
611#dnl	***********************************************************************
612enable_optimize=no
613#dnl	***********************************************************************
614AC_ARG_ENABLE(internal-headers-install, AS_HELP_STRING([--enable-internal-headers-install],[Install internal headers (only for debugging / inspection purposes, not for ordinary users).]),
615[if test "x$enableval" = xyes; then
616 	enable_ihi=yes;
617 	AC_MSG_NOTICE([Will install also internal headers.])
618else
619 	enable_ihi=no;
620fi],[enable_ihi=no])
621#dnl	***********************************************************************
622RSB_USE_ASSERT="";
623AC_ARG_ENABLE(debug-getenvs, AS_HELP_STRING([--enable-debug-getenvs],[Enable (undocumented) developer oriented getenv-based controls.]),
624[if test "x$enableval" = xyes; then
625	AC_DEFINE([RSB_ALLOW_INTERNAL_GETENVS],[1],[Extra (undocumented) developer oriented control switches.])
626else
627	AC_DEFINE([RSB_ALLOW_INTERNAL_GETENVS],[0],[Extra (undocumented) developer oriented control switches.])
628fi],[true;])
629#dnl	***********************************************************************
630RSB_USE_ASSERT="";
631AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[Compile with debug flags and enable assertions and other internals. This will slow down the code considerably.]),
632[if test "x$enableval" = xyes; then
633	enable_debug=yes;
634	RSB_USE_ASSERT=1;
635dnl
636	want_int_verrbosity=1; # FIXME: this shall be removed from here, once the library gets stable for release!
637	AC_MSG_NOTICE([With the debug switch enabled, also setting internal error verbosity level at value 1.])
638dnl
639else
640	enable_debug=no
641fi],[enable_debug=no])
642#dnl	***********************************************************************
643AH_TEMPLATE([RSB_WITH_SPARSE_BLAS_INTERFACE])
644if test "x$sparse_blas_interface" = xyes; then
645	AC_MSG_NOTICE(Will build a Sparse BLAS interface to librsb.)
646	AC_DEFINE([RSB_WITH_SPARSE_BLAS_INTERFACE],[1],[Sparse BLAS interface compilation.])
647else
648      	AC_MSG_NOTICE([Will not build a Sparse BLAS interface to librsb.])
649fi
650#dnl	***********************************************************************
651want_looping_kernels=0;
652if test "x$enable_looping_kernels" = xyes; then
653	AC_MSG_NOTICE(Enabling looping kernels.)
654	want_looping_kernels=1;
655	AC_DEFINE([RSB_WANT_LOOPING_KERNELS],[1],[Looping kernels.])
656
657
658else
659dnl      	AC_MSG_NOTICE([Skipping the compilation of looping kernels.])
660	true
661fi
662#dnl	***********************************************************************
663AC_ARG_WITH(papi, AS_HELP_STRING([--with-papi],[Specify the PAPI library (UNFINISHED)]), [if test "x$withval" = xno; then want_papi_libs= ; else enable_papi=yes; want_papi_libs="$withval" ; fi], [want_papi_libs="-lpapi"])
664#dnl	***********************************************************************
665if test "x$enable_papi" = xyes; then
666	if test "x$ac_cv_header_papi_h" != xyes; then
667	AC_MSG_WARN([Header file <papi.h> not found, therefore we will not use it!])
668	else
669	if test "$want_papi_libs" = yes ; then want_papi_libs=-lpapi ; fi
670	RSB_RSBENCH_LIBS="${RSB_RSBENCH_LIBS} $want_papi_libs"
671	# TODO : set CFLAGS !
672      	AC_MSG_NOTICE(Enabling PAPI (Performance Application Programming Interface).)
673	# FIXME: should differentiate RSB_WANT_PERFORMANCE_COUNTERS from RSB_HAVE_PAPI
674	AC_DEFINE([RSB_WANT_PERFORMANCE_COUNTERS],[1],[Performance Counters.])
675	AC_DEFINE([RSB_HAVE_PAPI],[1],[Performance Application Programming Interface.])
676	fi
677else
678      	dnl AC_MSG_NOTICE(Skipping the use of PAPI (Performance Application Programming Interface).)
679	true
680fi
681#dnl	***********************************************************************
682if test "x$enable_likwid" = xyes; then
683	if test "x$LIKWID_LIBS" = x; then
684		LIKWID_LIBS="-llikwid"
685	fi
686  	AC_MSG_NOTICE(Enabling support for LIKWID (LIKWID_CFLAGS=${LIKWID_CFLAGS}) (LIKWID_LIBS=${LIKWID_LIBS}).)
687	RSB_RSBENCH_LIBS="${RSB_RSBENCH_LIBS} ${LIKWID_LIBS}"
688	RSB_RSBENCH_CFLAGS="${RSB_RSBENCH_CFLAGS} ${LIKWID_CFLAGS}"
689	AC_DEFINE([RSB_WITH_LIKWID],[1],[LIKWID marker API support.])
690else
691	AC_DEFINE([RSB_WITH_LIKWID],[0],[LIKWID marker API support.])
692fi
693#dnl	***********************************************************************
694if test "x$enable_hwloc" = xyes; then
695	if test "x$want_hwloc_libs" != x; then
696		HWLOC_LIBS="$want_hwloc_libs"
697	fi
698	AC_MSG_NOTICE(Enabling support for HWLOC (HWLOC_CFLAGS=${HWLOC_CFLAGS}) (HWLOC_LIBS=${HWLOC_LIBS}).)
699	RSB_RSBENCH_LIBS="${RSB_RSBENCH_LIBS} ${HWLOC_LIBS}"
700	RSB_RSBENCH_CFLAGS="${RSB_RSBENCH_CFLAGS} ${HWLOC_CFLAGS}"
701	AC_DEFINE([RSB_WITH_HWLOC],[1],[HWLOC API support.])
702else
703	AC_DEFINE([RSB_WITH_HWLOC],[0],[HWLOC API support.])
704fi
705#dnl	***********************************************************************
706if test "x$disable_allocator_wrapper" = xyes; then
707AC_DEFINE([RSB_DISABLE_ALLOCATOR_WRAPPER],1,[If defined, will not account for internally used memory.])
708      AC_DEFINE([RSB_WANT_ALLOCATOR_LIMITS],0,[If 1, will allow the user to set hard limits to the memory allocated by librsb. Trespass attempts will fail.])
709      AC_MSG_NOTICE(Will disable memory allocators wrappers.)
710else
711      AC_DEFINE([RSB_WANT_ALLOCATOR_LIMITS],1,[If 1, will allow the user to set hard limits to the memory allocated by librsb. Trespass attempts will fail.])
712      AC_MSG_NOTICE(Enabling memory allocators wrappers.)
713fi
714#dnl	***********************************************************************
715#dnl	***********************************************************************
716if test "x$enable_alignment" = xno; then
717      AC_MSG_NOTICE(Will not enforce aligned memory chunks allocation.)
718else
719      AC_MSG_NOTICE(Will enforce aligned memory chunks allocation.)
720AC_DEFINE([RSB_WANT_DOUBLE_ALIGNED],[1],[On some architectures (notably modern Intel), floating point computations on non double aligned data make loose some clock cycle.])
721fi
722#dnl	***********************************************************************
723if test "x$enable_librsb_stats" = xyes; then
724	AC_MSG_NOTICE(Enabling collection of time statistics in librsb operations (this introduces an overhead).)
725	AC_DEFINE([RSB_WANT_LIBRSB_STATS],[1],[Enabling collection of time statistics in librsb operations (this introduces an overhead).])
726fi
727#dnl	***********************************************************************
728if test "x$enable_rsb_num_threads" = xyes; then
729	AC_MSG_NOTICE(Enabling experimental RSB_NUM_THREADS environment variable.)
730	AC_DEFINE([RSB_WANT_RSB_NUM_THREADS],[1],[Enabling experimental RSB_NUM_THREADS environment variable.])
731fi
732#dnl	***********************************************************************
733dnl if test x$enable_fortran = xno; then
734dnl       AC_MSG_NOTICE(Will not build Fortran bindings.)
735dnl else
736dnl       AC_MSG_NOTICE(Will build Fortran bindings.)
737dnl       AC_DEFINE([RSB_WANT_EXPERIMENTAL_FORTRAN_INTERFACE],[1],[Fortran interface.])
738dnl fi
739#dnl	***********************************************************************
740if test "x$enable_c_examples" = xno; then
741      AC_MSG_NOTICE(Will not build C examples.)
742else
743      AC_MSG_NOTICE(Will build C examples.)
744fi
745#dnl	***********************************************************************
746if test "x$enable_fortran_examples" = xno; then
747      AC_MSG_NOTICE(Will not build Fortran examples.)
748else
749      AC_MSG_NOTICE(Will build (experimental) Fortran examples.)
750fi
751#dnl	***********************************************************************
752if test "x$enable_restrict" = xyes; then
753      AC_MSG_NOTICE([Will use the C99 restrict keyword.])
754      AC_MSG_NOTICE([Will also add the -std=c99 flag.])
755      enable_c99=yes
756else
757      AC_MSG_NOTICE([Will not use the C99 restrict keyword ])
758fi
759#dnl	***********************************************************************
760if test "x$want_build_doc" = xyes ; then
761      if test x"$DOXYGEN" = x"false"; then
762	      AC_MSG_ERROR([Doxygen not detected ! Please --disable-doc-build or supply a valid DOXYGEN variable.])
763	      want_build_doc=no
764      else
765	      AC_MSG_NOTICE([Will rebuild the documentation using "$DOXYGEN" as Doxygen executable.])
766	      if test x"$HELP2MAN" = x"false"; then
767      	   	AC_MSG_NOTICE([Program man pages will not generated: HELPMAN not detected.])
768	      fi
769      fi
770else
771	AC_MSG_NOTICE([Will not use Doxygen to build documentation (--enable-doc-build to change).])
772fi
773#dnl	***********************************************************************
774no_unroll_flags=""
775#dnl	***********************************************************************
776if test xyes = xyes; then # we need a new flag here for this : FIXME
777	# I am not sure whether these flags are optimal, but among these they are
778
779	if test "x${CC}" = x"xlc" -o "x${CC}" = x"xlc_r"  && test "x$spigni_forte" = "x" ; then
780		# use -qnostrict to turn  off aggressive optimization (debug cases)
781		# use -q64 to enable 64 bit compilation and ar -X 64 cru ... for linking (FIXME)
782          	# -qfdpr
783          	# The compiler generates additional symbol information for use by the AIX "fdprpro" code optimizer.
784		# /opt/freeware/bin path is harmful with autotools on the ENEA grid environment, as it is the default one!
785		PATH="/bin/:$PATH"
786
787		# the following should only be used along with -q64. not without! (FIXME)
788		ARFLAGS="-X 64 cru"
789		SPCFLAGS="-q 64"
790
791		#spigni_forte="-O3 -lmass -lessl"
792		spigni_forte="-O3 -lmass -lessl -q64 -bmaxdata:0x1000000000"
793		#spigni_forte="-O3 -lmass -lessl -q64 -bmaxdata:0x70000000"
794		# FIXME : configure is not smart enough to add -X64 to ARFLAGS
795		# FIXME : CXXFLAGS too
796#		spigni_forte="-O3 -lmass -lessl"
797		restrict_flags="-qkeyword=restrict"
798		c99_flags="-qlanglvl=extc99 $restrict_flags"
799		debug_flags="-O0 -g"
800		openmp_flags="-qsmp=omp"
801		if test -f /bin/uname ; then
802			# some AFS systems (e.g.: ENEA.it grid) need this fix
803			uname_M="`/bin/uname -M`"
804		else
805			uname_M="`uname -M`"
806		fi
807		if test "x${uname_M}" = x"IBM,9118-575" ; then
808			spigni_forte="$spigni_forte -qarch=pwr5 -qtune=pwr5"
809		fi
810		if test "x${uname_M}" = x"IBM,7040-681" ; then
811			spigni_forte="$spigni_forte -qarch=pwr4 -qtune=pwr4"
812		fi
813		# verbose : 0-3
814		# profiling info: -pga
815		# -qbrowse
816		no_unroll_flags="-qunroll=no"
817		# xlc has #pragma unroll !
818		AC_MSG_NOTICE([Guessing the compiler is xlc.])
819	fi
820
821        have_icc=no; # a fix to set correctly openmp_flags
822        if test "x${CC}" = x"icc" || ${CC} -V 2>&1 | grep Intel ; then have_icc=yes ; fi
823
824        if test "x${have_icc}" = x"yes" && test "x$spigni_forte" = "x" ; then
825#	if test "x${CC}" = x"icc" && test "x$spigni_forte" = "x" ; then
826		spigni_forte="-O3 -xSSE3  -no-alias-const -no-multibyte-chars -pipe "
827		# note: -tpp6 & -tpp7 and so on are old icc flags (version 11 does not support them)
828		# ipo seems to break autotools
829		# -xS ?
830		# TODO : '-ax:SSE2'  .. generate multiple paths ..
831
832		# -ax turns on the vectorizer (MMX, SSEx, ...)
833		# -mtune=..
834		restrict_flags="-restrict" # !
835		c99_flags="$restrict_flags"
836		debug_flags="-O0 -g"
837		#no_unroll_flags="-fno-unroll"
838		#20110608 icc v12 wants -unroll=0
839		no_unroll_flags="-unroll=0"
840		#openmp_flags="-openmp" # -parallel
841		#openmp_flags="-qopenmp" # -parallel
842		openmp_flags="-fopenmp" # -parallel
843		AC_MSG_NOTICE([Guessing the compiler is icc.])
844		walls="-Wall"
845	fi
846
847	if test "x${CC}" = x"pgcc" && test "x$spigni_forte" = "x" ; then
848		spigni_forte="-O3 -Mvect=cachesize:automatic,fuse,prefetch,sse -Mquad -Mscalarsse -Mnoframe -Minfo=all" # O3 is same as 4
849		c99_flags="-c99 -Xa"
850		restrict_flags="$c99_flags" # !
851		debug_flags="-O0 -g"
852		no_unroll_flags="-Mnounroll"
853		openmp_flags="-mp"
854		# -Mconcur is VERY interesting .. !!
855		# -Mlist (creates a listing file)
856		# -Mprof=hwcts     Use PAPI-based profiling with hardware counters (linux86-64 only).
857		# -pg exists, -g too
858		# -Mnovect disables the vectorizer, and is the default
859		AC_MSG_NOTICE([Guessing the compiler is pgcc.])
860	fi
861
862dnl	AC_MSG_NOTICE([Guessing compiler best flags...])
863	if test "x$ac_cv_c_compiler_gnu" = xyes && test "x$spigni_forte" = "x" ; then
864		# note that CC=icc will not imply ac_cv_c_compiler_gnu=yes !
865		# -malign-double does not make sense on 64 bit archs and triggers errors
866		#spigni_forte="-O3 -fomit-frame-pointer -ffast-math"
867		spigni_forte="-O3 -fomit-frame-pointer -mtune=native"
868		c99_flags="-std=c99" # ?
869		restrict_flags="$c99_flags" # !
870		debug_flags="-O0 -ggdb"
871		no_unroll_flags="-fno-unroll-loops"
872		hidden_visibility_flags="-fvisibility=hidden"
873		openmp_flags="-fopenmp"
874		if test x != x"${OPENMP_CFLAGS}" ; then
875			openmp_flags="${OPENMP_CFLAGS}"
876		fi
877		# NOTE: -ffast-math disables math functions specifications, and therefore is EVIL
878		spigni_nativo="-pipe"
879		cpuinfomn=`cat /proc/cpuinfo| grep model.name | sed s/^.*://g`
880		# FIXME : the following will fail on tcsh
881#		if test x"` $CC -v 2>&1| grep -i red.*hat`" != x ; then
882		gcc_v=`$CC --version` # will be catched on tcsh
883		if test x"` $CC -v 2>&1 | grep -i red.*hat`" != x -o x"`echo $gcc_v` | grep -i red.hat" != x; then
884			# uhm..
885#			if test x"` echo $cpuinfomn | grep Athlon `" != x ; then
886#				# fails for a
887#				# model name      : AMD Athlon(tm) 7750 Dual-Core Processor
888#				spigni_nativo="$spigni_nativo -march=athlon -mtune=athlon"
889#			fi
890			if test x"` echo $cpuinfomn | grep 'AMD Opteron.*2216\>'`" != x ; then
891				# model name      : Dual-Core AMD Opteron(tm) Processor 2216
892				spigni_nativo="$spigni_nativo -march=opteron -mtune=opteron"
893			fi
894			if test x"` echo $cpuinfomn | grep 'AMD Opteron.*2352\>'`" != x ; then
895				# Opteron barcelona are 2344-2350, but the instruction set is ok
896				# model name      : AMD Athlon(tm) 7750 Dual-Core Processor
897				spigni_nativo="$spigni_nativo -march=barcelona -mtune=barcelona"
898			fi
899			if test x"` echo $cpuinfomn | grep 'AMD Athlon.*7750'`" != x ; then
900				# this is Phenom, not Opteron arcelona, but same instruction set
901				# model name      : AMD Athlon(tm) 7750 Dual-Core Processor
902				spigni_nativo="$spigni_nativo -march=barcelona -mtune=barcelona"
903			fi
904			if test x"` echo $cpuinfomn | grep 'AMD Athlon.*64.*X2.*Dual Core Processor 6000.'`" != x ; then
905                        	# K9 microarchitecture
906				# this is Windsor, released May 24, 2006
907				# rossini.ibspan.waw.pl
908				# model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 6000+
909	                        spigni_nativo="$spigni_nativo -march=amdfam10 -mtune=amdfam10"
910			fi
911			if test x"` echo $cpuinfomn | grep 'Xeon.*[EXWL]3...\>'`" != x ; then
912				# Wolfdale 	31..
913				# Kentsfield 	32..
914				# Yorkfield 	33..
915				# Lynnfield 	34..
916				# Bloomfield	35..
917				spigni_nativo="$spigni_nativo -march=core2 -mtune=core2"
918			fi
919			if test x"` echo $cpuinfomn | grep 'Xeon.*X7...'`" != x ; then
920				# Tigerton series, d.c.	72..
921				# Tigerton series, q.c.	73..	1066MT/s
922				# cresco1x .. portici.enea.it
923				# model name      : Intel(R) Xeon(R) CPU           X7350  @ 2.93GHz
924				# Tulsa series		71..
925				# crescobf.brindisi.enea.it:
926				# model name      : Intel(R) Xeon(R) CPU           X7350  @ 2.93GHz
927				spigni_nativo="$spigni_nativo -march=core2 -mtune=core2"
928			fi
929			if test x"` echo $cpuinfomn | grep 'Xeon.*[EXWL]70..\>'`" != x ; then
930				# Paxville (Netburst)
931				spigni_nativo="$spigni_nativo -march=pentium4 -mtune=pentium4"
932			fi
933			if test x"` echo $cpuinfomn | grep 'Xeon.*[EXWL]50..\>'`" != x ; then
934				# Dempsey (Netburst)
935				spigni_nativo="$spigni_nativo -march=pentium4 -mtune=pentium4"
936			fi
937			if test x"` echo $cpuinfomn | grep 'Core(TM)2 Quad CPU'`" != x ; then
938				# Conroe/Allendale
939				spigni_nativo="$spigni_nativo -march=core2 -mtune=core2"
940			fi
941			if test x"` echo $cpuinfomn | grep 'Xeon.*[EXWL]51..\>'`" != x ; then
942				# Woodcrest (Core2)
943				spigni_nativo="$spigni_nativo -march=core2 -mtune=core2"
944			fi
945			if test x"` echo $cpuinfomn | grep 'Xeon.*[EXWL]52..\>'`" != x ; then
946				# Wolfdale DP
947				spigni_nativo="$spigni_nativo -march=core2 -mtune=core2"
948			fi
949			if test x"` echo $cpuinfomn | grep 'Xeon.*[EXWL]53..\>'`" != x ; then
950				# Clovertown series, 1333MT/s, 2x4MB L2
951				# ce1-cresco.portici.enea.it
952				# model name     : Intel(R) Xeon(R) CPU           E5335  @ 2.00GHz
953				# Clovertown series, 1333MT/s
954				# cresco2-f3.portici.enea.it
955				# model name      : Intel(R) Xeon(R) CPU           E5345  @ 2.33GHz
956				# Harpertown series	54..	, 12 MB L2
957				# Gainestown (Nehalem)s.55..	4x256kB L2, 8MB L3
958				spigni_nativo="$spigni_nativo -march=core2 -mtune=core2"
959			fi
960#			if test x"` echo $cpuinfomn | grep Opteron `" != x ; then
961#				spigni_nativo="$spigni_nativo -march=opteron -mtune=opteron"
962#			fi
963			if test x"` echo $cpuinfomn | grep 'Pentium(R).4' `" != x ; then
964				spigni_nativo="$spigni_nativo -march=pentium4 -mtune=pentium4"
965			fi
966			if test x"` echo $cpuinfomn | grep 'Pentium III (Coppermine)' `" != x ; then
967				spigni_nativo="$spigni_nativo -march=pentium3 -mtune=pentium3 -msse"
968			fi
969#			if test x"` echo $cpuinfomn | grep 'Xeon'`" != x ; then
970#				Intel(R) Xeon(TM) CPU 3.00GHz
971#				spigni_nativo="$spigni_nativo -march=pentium4 -mtune=pentium4"
972#			fi
973		else
974			spigni_nativo="-march=native -mtune=native $spigni_nativo"
975		fi
976		# NOTE : compilers like gcc version 3.4.6 20060404 (Red Hat 3.4.6-10) do not accept native switch
977		# -march=pentium3
978		# on p4: --malign=double -march=pentium4 -mfpmath=sse -msse2 -
979		walls="-Wall -Wredundant-decls -Wno-switch -Wdisabled-optimization -Wdeclaration-after-statement   "" -Wpointer-arith -Wstrict-prototypes "
980		#" -pedantic"
981		AC_MSG_NOTICE([Guessing the C compiler is gcc.])
982	fi
983else
984	true
985fi
986
987#dnl	***********************************************************************
988#dnl	GNU FORTRAN runtime
989#dnl	***********************************************************************
990if test "x$ac_cv_fc_compiler_gnu" = xyes ; then
991	LIBS="${LIBS} -lgfortran"
992	AC_MSG_NOTICE([Guessing the Fortran compiler is gfortran and adding -lgfortran to LIBS (invoke with ac_cv_fc_compiler_gnu=no to prevent this).])
993fi
994#dnl	***********************************************************************
995#dnl	CFLAGS handling starts here
996#dnl	***********************************************************************
997if test "x$CFLAGS" = x ; then
998if test "x$enable_optimize" = xyes && test x$enable_debug != xyes ; then
999	if test "x$mio_spigni_forte" = "x" ; then
1000		true;
1001	else
1002		spigni_forte="$mio_spigni_forte";
1003		spigni_nativo="";
1004	fi
1005	if test "x$spigni_forte" = "x" ; then
1006		spigni="-O3 -malign-double $spigni_nativo"
1007		#spigni="-O3 -fomit-frame-pointer -malign-double $spigni_nativo"
1008	else
1009		spigni="$spigni_forte $spigni_nativo"
1010	fi
1011
1012	AC_MSG_NOTICE([Adding ${spigni} to CFLAGS.])
1013	#CFLAGS="${CFLAGS} ${spigni}"
1014	AC_MSG_NOTICE([Overriding CFLAGS="$CFLAGS".. ])
1015	CFLAGS="${spigni}"
1016else
1017	if test "x$enable_debug" = xyes; then
1018		if test "x$debug_flags" = "x" ; then
1019			CFLAGS="-O0 -g"
1020		else
1021			CFLAGS="${debug_flags}"
1022		fi
1023		AC_MSG_NOTICE([Optimization turned off. Debugging enabled. (CFLAGS overwritten)])
1024		# since we are allowed to suggest flags, we do so
1025		CFLAGS="${CFLAGS} ${SPCFLAGS}"
1026	else
1027		true;
1028	fi
1029	true;
1030fi
1031#
1032fi
1033#dnl	***********************************************************************
1034# fix just for SP
1035if test x"${SPCFLAGS}" != x ; then
1036	CFLAGS="${CFLAGS} ${SPCFLAGS}"
1037fi
1038#dnl	***********************************************************************
1039if test x"$enable_dmalloc" == x"1"  ; then
1040	CFLAGS="$CFLAGS $DMALLOC_CFLAGS"
1041fi
1042#dnl	***********************************************************************
1043if test x"$want_mkl_libs" != x""  ; then
1044	dnl use --without-mkl to disable it
1045      	AC_MSG_NOTICE([Enabling MKL support in the benchmarking program (will add "$MKL_INCLUDE" to compilation flags; will link to "$want_mkl_libs").])
1046	AC_DEFINE([RSB_WANT_MKL],[1],[Enabling MKL support in the benchmarking program.])
1047	RSB_RSBENCH_LIBS="${RSB_RSBENCH_LIBS} $want_mkl_libs"
1048		if test -n "$MKL_INCLUDE" ; then
1049			RSB_RSBENCH_CFLAGS="$RSB_RSBENCH_CFLAGS -I $MKL_INCLUDE"
1050		fi
1051	else
1052	AC_MSG_NOTICE([Disabling MKL support in the benchmarking program.])
1053	AC_DEFINE([RSB_WANT_MKL],[0],[No MKL support wanted in the benchmarking program.])
1054fi
1055#dnl	***********************************************************************
1056if test x"$enable_openmp" = x"yes"; then
1057	AC_DEFINE([RSB_WANT_OMP_RECURSIVE_KERNELS],[1],[Recursive kernels parallelized with OpenMP.])
1058	if test x"$openmp_flags" != "x" ; then
1059dnl		AC_DEFINE([RSB_WANT_OMP_KERNELS],[1],[Kernels parallelized with OpenMP.])
1060		CFLAGS="${CFLAGS} $openmp_flags"
1061		if test "x$OPENMP_FCFLAGS" = "x" ; then
1062			OPENMP_FCFLAGS="$openmp_flags"
1063		fi
1064		FCFLAGS="${FCFLAGS} ${OPENMP_FCFLAGS}"
1065	else
1066		AC_MSG_NOTICE([We do not know an appropriate OpenMP-enabling flag but assume OpenMP is active.])
1067		CFLAGS="${CFLAGS}"
1068	fi
1069else
1070	AC_DEFINE([RSB_WANT_OMP_RECURSIVE_KERNELS],[0],[Recursive kernels parallelized with OpenMP.])
1071	AC_MSG_NOTICE([OpenMP code disabled: 1 thread at most is allowed.])
1072        want_max_threads="1"
1073	true;
1074fi
1075#dnl	***********************************************************************
1076if test "x$enable_c99" = xyes; then
1077	if test "x$c99_flags" = "x" ; then
1078		AC_MSG_NOTICE([We do not know an appropriate c99-enabling flag..])
1079		CFLAGS="${CFLAGS}"
1080	else
1081		CFLAGS="${CFLAGS} $c99_flags"
1082	fi
1083else
1084	true;
1085fi
1086#dnl	***********************************************************************
1087AH_TEMPLATE([OSKI_LUA_PATH])
1088if test "x$enable_oski" = xyes; then
1089      	AC_MSG_NOTICE([Looking for user set OSKI_INCLUDE, OSKI_LUA_PATH, OSKI_PATH environment variables..])
1090	save_CFLAGS="$CFLAGS"
1091	if test -n "$OSKI_INCLUDE" ; then
1092		CFLAGS="$CFLAGS -I $OSKI_INCLUDE"
1093	fi
1094	AC_CHECK_HEADERS([oski/oski.h], [true])
1095	CFLAGS="$save_CFLAGS"
1096	if test "x$ac_cv_header_oski_oski_h" != xyes; then
1097dnl AC_MSG_WARN
1098	AC_MSG_ERROR([Header file <oski/oski.h> not found, therefore we will not use it!])
1099	else
1100		# FIXME: this is temporary, for my own machines
1101		if test -d "~/usr/local/include/" ; then
1102			CFLAGS="$CFLAGS -I ~/usr/local/include/"
1103		fi
1104
1105		if test -n "$OSKI_INCLUDE" ; then
1106			CFLAGS="$CFLAGS -I $OSKI_INCLUDE"
1107		fi
1108
1109		if test x"$OSKI_PATH" = x && test -d "/usr/local/lib/oski" ; then
1110			OSKI_PATH=/usr/local/lib/oski
1111		fi
1112		if test x"$OSKI_LUA_PATH" = x ; then
1113			OSKI_LUA_PATH="$OSKI_PATH/?.lua"
1114			else
1115			true;
1116		fi
1117		if test x"$OSKI_LIBS" = x ; then
1118			# oski-1.0.1h works in this way
1119			#OSKI_LIBS=`cat $OSKI_PATH/site-modules-static.txt | tr '\n' ' '`
1120			OSKI_LIBS=`cat $OSKI_PATH/site-modules-shared.txt | tr '\n' ' '`
1121			# the following often fail due to the incorrect order of libs:
1122			#OSKI_LIBS=`cat $OSKI_PATH/site-modules-static.txt|sed 's/^\/.*\///g;s/^'/"$OSKI_PATH\/"/g | tr '\n' ' '`
1123		fi
1124		if test x"$OSKI_LIBS" = x ; then
1125			AC_MSG_ERROR([No linkable libraries for OSKI ? Disable OSKI support ot try setting OSKI_LIBS by hand.])
1126		fi
1127		if test x"${OSKI_CFLAGS}" = x && test -d "~/usr/local/include/"; then
1128			OSKI_CFLAGS="$OSKI_CFLAGS -I  /usr/local/include/"
1129			OSKI_CFLAGS="$OSKI_CFLAGS -I ~/usr/local/include/"
1130		fi
1131		#
1132		RSB_RSBENCH_LIBS="${RSB_RSBENCH_LIBS} -L${OSKI_PATH} ${OSKI_LIBS}"
1133
1134		# FIXME: this is temporary, for my own machines
1135		if test -d "~/usr/local/lib/oski/" ; then
1136			RSB_RSBENCH_LIBS="${RSB_RSBENCH_LIBS} -L ~/usr/local/lib/oski/"
1137		fi
1138
1139		RSB_RSBENCH_CFLAGS="${RSB_RSBENCH_CFLAGS} $OSKI_CFLAGS"
1140	      	AC_MSG_NOTICE(Enabling comparative OSKI benchmarking.)
1141		AC_DEFINE([RSB_WANT_OSKI_BENCHMARKING],[1],[OSKI comparative benchmarking.])
1142		AC_DEFINE_UNQUOTED([OSKI_LUA_PATH],"$OSKI_LUA_PATH",[OSKI path to installed lua modules. User set OSKI_LUA_PATH environment variable at runtime will override this one, however.])
1143	fi
1144else
1145      	true;
1146fi
1147#dnl
1148AC_SUBST([RSB_CONST_MAX_SUPPORTED_THREADS],"${want_max_threads}")
1149#dnl	***********************************************************************
1150AC_DEFINE_UNQUOTED([RSB_INT_ERR_VERBOSITY],[$want_int_verrbosity],[Inner error verbosity (internal debug level).])
1151AC_DEFINE_UNQUOTED([RSB_OUT_ERR_VERBOSITY],[$want_ext_verrbosity],[Error verbosity (often known as debug level).])
1152AC_DEFINE_UNQUOTED([RSB_WANT_IO_LEVEL],[$want_io_level],[Supported input/output functionality.])
1153AC_DEFINE_UNQUOTED([RSB_USER_SET_MEM_HIERARCHY_INFO],["$RSB_USER_SET_MEM_HIERARCHY_INFO"],[If not null, the library will rely on this for memory hierarchy info.])
1154AC_DEFINE_UNQUOTED([RSB_DETECTED_MEM_HIERARCHY_INFO],["$RSB_DETECTED_MEM_HIERARCHY_INFO"],[If not null, the library will rely on this for memory hierarchy info, unless RSB_USER_SET_MEM_HIERARCHY_INFO is set.])
1155AC_DEFINE_UNQUOTED([RSB_CONST_MAX_SUPPORTED_THREADS],[$RSB_CONST_MAX_SUPPORTED_THREADS],[Maximal number of supported threads (default 160).])
1156AC_DEFINE_UNQUOTED([CFLAGS],["$CFLAGS"],[Compilation flags.])
1157AC_DEFINE_UNQUOTED([CC],["$CC"],[C compiler.])
1158if test x"$RSB_USE_ASSERT" != x ; then
1159AC_DEFINE_UNQUOTED([RSB_USE_ASSERT],["$RSB_USE_ASSERT"],[If undefined, NDEBUG will be defined.])
1160fi
1161#dnl	***********************************************************************
1162WANT_MATRIX_STORAGE=""
1163if test x"$enable_c" = xyes ; then
1164	WANT_MATRIX_BCOO_STORAGE=BCOR
1165#	WANT_MATRIX_BCOO_STORAGE=BCOR,BCOC
1166	WANT_MATRIX_STORAGE="$WANT_MATRIX_STORAGE,$WANT_MATRIX_BCOO_STORAGE"
1167fi
1168if test x"$enable_b" = xyes ; then
1169	WANT_MATRIX_BCSS_STORAGE=BCSR
1170#	WANT_MATRIX_BCSS_STORAGE=BCSR,BCSC
1171	WANT_MATRIX_STORAGE="$WANT_MATRIX_STORAGE,$WANT_MATRIX_BCSS_STORAGE"
1172fi
1173# we get rid of the comma
1174WANT_MATRIX_STORAGE="`echo $WANT_MATRIX_STORAGE| sed 's/^,//g'`"
1175#dnl	***********************************************************************
1176if test "x${userset_nounroll_cflag}" != x ; then
1177	no_unroll_flags="${userset_nounroll_cflag}"
1178fi
1179dnl	***********************************************************************
1180# for rsb_config.m4.in
1181AC_SUBST(enable_restrict)
1182AC_SUBST(enable_openmp)
1183AC_SUBST(CFLAGS)
1184AC_SUBST(FCFLAGS)
1185dnl AC_SUBST(NOUNROLLCFLAGS,"${CFLAGS} $no_unroll_flags")
1186AC_SUBST(NOUNROLLCFLAGS,"$no_unroll_flags")
1187AC_SUBST(HIDDEN_VISIBILITY_CFLAGS,"$hidden_visibility_flags")
1188AC_SUBST(RSB_RSBENCH_LIBS,"$RSB_RSBENCH_LIBS")
1189AC_SUBST(RSB_RSBENCH_CFLAGS,"$RSB_RSBENCH_CFLAGS")
1190AC_SUBST(WANT_ROW_UNLOOP_FACTORS,["$row_unrolls"])
1191AC_SUBST(WANT_LOOPING_KERNELS,["$want_looping_kernels"])
1192AC_SUBST(WANT_COLUMN_UNLOOP_FACTORS,["$column_unrolls"])
1193AC_SUBST(WANT_SIMPLE_LOOP_UNROLL_DEFAULT_FACTOR,["$util_unrolls"])
1194dnl AC_SUBST(WANT_HALFWORD_INDICES,["$want_halfword_indices"])
1195AC_SUBST(WANT_HALFWORD_INDICES,["yes"])
1196AC_SUBST(WANT_SPSM_DIAG_CHECK,["$want_spsm_diagonal_check"])
1197AC_SUBST(WANT_TYPES,["$want_matrix_types"])
1198AC_SUBST(WANT_MATRIX_BCSS_STORAGE,["$WANT_MATRIX_BCSS_STORAGE"])
1199AC_SUBST(WANT_MATRIX_BCOO_STORAGE,["$WANT_MATRIX_BCOO_STORAGE"])
1200AC_SUBST(WANT_MATRIX_LINKED_STORAGE,["$WANT_MATRIX_LINKED_STORAGE"])
1201AC_SUBST(WANT_MATRIX_VB_STORAGE,["$WANT_MATRIX_VB_STORAGE"])
1202AC_SUBST(WANT_MATRIX_STORAGE,["$WANT_MATRIX_STORAGE"])
1203AC_SUBST(WANT_MATRIX_OPS,["$want_matrix_ops"])
1204AC_SUBST(WANT_MATRIX_ALL_META_OPS,["spmv,spsv"])
1205AC_SUBST(WANT_MATRIX_ALL_OPS,["$all_matrix_ops"])
1206AC_SUBST(WANT_MATRIX_ALL_TYPES,["$all_matrix_types"])
1207dnl AC_SUBST(OT_SRCS,"`for o in $all_matrix_ops echo $o ; done`")
1208#dnl	***********************************************************************
1209if test x = x"$ARFLAGS" ; then ARFLAGS="cru" ; fi # damn AIX ar
1210AC_SUBST(ARFLAGS,"$ARFLAGS")
1211#dnl	***********************************************************************
1212EOL="\\n"
1213if test x"$DOXYGEN" != x"false" ; then
1214  doxygen_version="$($DOXYGEN --version)"
1215  test "$(echo -e "1.8.14\n$doxygen_version" | sort -V | head -n1)" = 1.8.14 && EOL="^^"
1216fi
1217AC_SUBST([EOL],[$EOL])
1218#dnl	***********************************************************************
1219
1220if test x"${enable_fortran_examples}" = x"yes" -a x"${FC}" = x"" ;  then
1221	enable_fortran_examples=no
1222	AC_MSG_WARN([No Fortran compiler detected (FC environment variable). Will not build the Fortran examples.])
1223fi
1224AC_SUBST([HAVE_FORTRAN_EXAMPLES],["$enable_fortran_examples"])
1225AM_CONDITIONAL([HAVE_FORTRAN_EXAMPLES],[test x"$enable_fortran_examples" = xyes ])
1226AM_CONDITIONAL([HAVE_C_EXAMPLES],[test x"$enable_c_examples" = xyes ])
1227AM_CONDITIONAL([HAVE_OCTAVE],[test x"$OCTAVE" != xfalse ])
1228want_int=`echo "$want_matrix_types" | grep '\<int\>'`
1229if test x"$OCTAVE" != xfalse -a x"$enable_octave_testing" = xyes ; then want_octave_testing=yes; else want_octave_testing=no; fi
1230AM_CONDITIONAL([WANT_OCTAVE_TESTING],[test x"$want_octave_testing" = x"yes" ])
1231if test x"$OCTAVE" != xfalse -a x"$want_int" != x -a x"$enable_octave_testing" = xyes ; then want_octave_testing_and_int=yes; else want_octave_testing_and_int=no ; fi
1232AM_CONDITIONAL([WANT_OCTAVE_TESTING_AND_INT],[test x"$want_octave_testing_and_int" = x"yes" ])
1233if test x"${FC}" = x"" ;  then
1234if test x"${want_blas_sparse_mod_install}" = x"yes" -o x"${sparse_blas_interface}" = x"yes" ;  then
1235	want_blas_sparse_mod_install=no;
1236	sparse_blas_interface=no;
1237	AC_MSG_WARN([No Fortran compiler detected (FC environment variable). Will not build the BLAS interface.])
1238fi
1239fi
1240AM_CONDITIONAL([WANT_BLAS_SPARSE_MOD_INSTALL],[test x"$want_blas_sparse_mod_install" = x"yes"])
1241dnl AM_CONDITIONAL([WANT_BLAS_SPARSE_FI],[test x"$want_blas_sparse_fi_install" = x"yes"])
1242AM_CONDITIONAL([HAVE_DOXYGEN],[test x"$DOXYGEN" != x"false" ])
1243AM_CONDITIONAL([WANT_BUILD_DOC],[test x"$want_build_doc" = x"yes" ])
1244AM_CONDITIONAL([HAVE_PKGCONFIG_INSTALL],[test x"$want_install_pkg_config" = x"yes" ])
1245AM_CONDITIONAL([HAVE_HELP2MAN],[test x"$HELP2MAN" != x"false" ])
1246AM_CONDITIONAL([HAVE_M4],[test x"$M4" != xfalse ])
1247AM_CONDITIONAL([HAVE_FC],[test x"$FC" != x ])
1248dnl AM_CONDITIONAL([WANT_DL],[test x"$want_rsb_dl" = x"yes"])
1249AM_CONDITIONAL([HAVE_SPARSE_BLAS_INTERFACE],[test x"$sparse_blas_interface" = xyes ])
1250AM_CONDITIONAL([WANT_INTERNAL_HEADERS_INSTALL],[test x"$enable_ihi" = xyes ])
1251AM_CONDITIONAL([WANT_OMPIO_SUPPORT],[test x"$want_ompio" = x"yes" && test x"$enable_openmp" = x"yes" ])
1252AC_SUBST(OCTAVE_FLAGS,"--no-history --no-line-editing  --no-site-file --norc   --silent")
1253#dnl	***********************************************************************
1254dnl AC_MSG_NOTICE([
1255dnl Will generate code for types in {$want_matrix_types}, for matrix ops in {$want_matrix_ops}.
1256dnl Will generate code for {$row_unrolls} x {$column_unrolls}-sized blocks, for types in {$want_matrix_types} for matrix ops in {$want_matrix_ops}.
1257dnl ])
1258dnl AC_MSG_NOTICE([FIXME : please run `make clean` as a first thing  ])
1259#dnl	***********************************************************************
1260AC_CONFIG_FILES([librsb-config:librsb-config.in],[chmod +x librsb-config])
1261AC_CONFIG_FILES([librsb.pc:librsb.pc.in],[])
1262AC_CONFIG_FILES([examples/make.sh:examples/make.sh.in],[chmod +x examples/make.sh])
1263AC_CONFIG_FILES([rsb_config.m4 Makefile bench/Makefile doc/Makefile doc/Doxyfile examples/Makefile scripts/Makefile m4/Makefile blas_sparse/Makefile])
1264AC_OUTPUT
1265#dnl	***********************************************************************
1266AC_MSG_NOTICE([dnl
1267=============== Build Programs and Flags ===============================
1268(you can override these at build time; e.g.: 'make CC=cc')
1269dnl	ac_cv_c_compiler_gnu: ${ac_cv_c_compiler_gnu}
1270	CC                     : ${CC}
1271	CFLAGS                 : ${CFLAGS}
1272	NOUNROLLCFLAGS         : ${NOUNROLLCFLAGS}
1273	FC (to disable, FC='') : ${FC}
1274	FCFLAGS                : ${FCFLAGS}
1275	LD                     : ${LD}
1276	LDFLAGS                : ${LDFLAGS}
1277	LIBS                   : ${LIBS}
1278	AR                     : ${AR}
1279	ARFLAGS                : ${ARFLAGS}
1280	M4                     : ${M4}
1281	OCTAVE                 : ${OCTAVE}
1282dnl	WANT_OCTAVE_TESTING
1283dnl	Octave executable            : "$OCTAVE"
1284	DOXYGEN                : ${DOXYGEN}
1285	HELP2MAN               : ${HELP2MAN}
1286dnl	SED               : ${SED}
1287dnl	HAVE_DOXYGEN                 : "$DOXYGEN"
1288dnl	Doxygen executable           : "$DOXYGEN"
1289dnl	HAVE_HELP2MAN                : "$HELP2MAN"
1290dnl	help2man executable : "$HELP2MAN"
1291dnl	HAVE_M4
1292dnl	M4 executable       : "$M4"
1293dnl	CXX                    : ${CXX}
1294dnl		Misc info:
1295=== Additional flags affecting only the benchmark program (rsbench): ===
1296	RSB_RSBENCH_LIBS             : ${RSB_RSBENCH_LIBS}
1297	RSB_RSBENCH_CFLAGS           : ${RSB_RSBENCH_CFLAGS}
1298dnl
1299dnl		Main code generator values, predefined defaults
1300dnl	All Numerical types          : ${all_matrix_types}
1301dnl	Numerical types              : ${default_types}
1302dnl	default_matrix_ops  : ${default_matrix_ops}
1303dnl	default_unrolls	    : ${default_unrolls}
1304dnl	all_matrix_ops      : ${all_matrix_ops}
1305dnl	blas_matrix_ops     : ${blas_matrix_ops}
1306dnl	psblas_matrix_ops   : ${psblas_matrix_ops}
1307dnl	Build Sparse BLAS Interface  : "${sparse_blas_interface_default}"
1308dnl	Util. Kernels Unroll         : ${default_util_unrolls}
1309dnl	Triangular solve zero check  : "${want_spsm_diagonal_check_default}"
1310dnl
1311========= Main code generator values, this build vs defaults ===========
1312(if these differ from the defaults, you need to have M4 and run 'make cleanall' and 'make')
1313	All Numerical types          : "${all_matrix_types}"
1314	Numerical types              : "${want_matrix_types}" vs ["${default_types}"]
1315dnl	want_matrix_ops     : ${want_matrix_ops}
1316dnl	row_unrolls         : ${row_unrolls}
1317dnl	column_unrolls      : ${column_unrolls}
1318dnl	HAVE_SPARSE_BLAS_INTERFACE:
1319	Build Sparse BLAS Interface  : "${sparse_blas_interface}" vs ["${sparse_blas_interface_default}"]
1320	Util. Kernels Unroll         : "${util_unrolls}" vs ["${default_util_unrolls}"]
1321dnl	matrix storage      : ${WANT_MATRIX_STORAGE}
1322	Triangular solve zero check  : "${want_spsm_diagonal_check}" vs ["${want_spsm_diagonal_check_default}"]
1323============== Build Configuration, this build vs defaults =============
1324(if you reconfigure and change these, you need to run 'make clean' and 'make')
1325dnl	host_os		  : ${host_os}
1326dnl	host_cpu	  : ${host_cpu}
1327dnl	short indices     : ${want_halfword_indices}
1328dnl	Configured I/O level : ${want_io_level}
1329dnl	RSB_WANT_IO_LEVEL                   : ${want_io_level}
1330	Supported I/O functionality level   : "${want_io_level}" vs "${default_want_io_level}"
1331dnl	RSB_OUT_ERR_VERBOSITY               : ${want_ext_verrbosity}
1332	Interface Error Verbosity           : "${want_ext_verrbosity}" vs "${default_want_ext_verrbosity}"
1333dnl	RSB_INT_ERR_VERBOSITY               : ${want_int_verrbosity}
1334	Internals Error Verbosity           : "${want_int_verrbosity}" vs "${default_want_int_verrbosity}"
1335dnl		Host specific info:
1336dnl	RSB_USER_SET_MEM_HIERARCHY_INFO     : ${RSB_USER_SET_MEM_HIERARCHY_INFO}
1337dnl	RSB_DETECTED_MEM_HIERARCHY_INFO     : ${RSB_DETECTED_MEM_HIERARCHY_INFO}
1338dnl	RSB_CONST_MAX_SUPPORTED_THREADS     : ${RSB_CONST_MAX_SUPPORTED_THREADS}
1339	Memory hierarchy info, detected     : "${RSB_DETECTED_MEM_HIERARCHY_INFO}"
1340	Memory hierarchy info, selected     : "${RSB_USER_SET_MEM_HIERARCHY_INFO}"
1341	Maximum of Supported threads        : "${RSB_CONST_MAX_SUPPORTED_THREADS}"
1342dnl
1343dnl		Configured Makefile conditionals:
1344dnl	WANT_SPSM_DIAG_CHECK
1345dnl	HAVE_FORTRAN_EXAMPLES
1346dnl 	Build Fortran code                  : "$enable_fortran"
1347	Build Fortran examples              : "$enable_fortran_examples"
1348dnl	HAVE_C_EXAMPLES
1349	Build C examples                    : "$enable_c_examples"
1350dnl	WANT_OMPIO_SUPPORT
1351dnl	Want OpenMP + I/O            : "$want_ompio"
1352dnl	RSB_DISABLE_ALLOCATOR_WRAPPER: "$disable_allocator_wrapper"
1353dnl	WANT_BLAS_SPARSE_MOD_INSTALL
1354	Install Sparse BLAS Fortran modules : "$want_blas_sparse_mod_install"
1355	Install pkg-config "librsb.pc" file : "$want_install_pkg_config"
1356dnl	WANT_BLAS_SPARSE_FI
1357dnl	Install Sparse BLAS Fortran headers : "$want_blas_sparse_fi_install"
1358dnl	WANT_OCTAVE_TESTING                 : "$want_octave_testing"
1359	Build Octave generated tester       : "$want_octave_testing"
1360dnl	WANT_OCTAVE_TESTING_AND_INT
1361	Build Octave generated tester (int) : "$want_octave_testing_and_int"
1362	Build HTML and man documentation    : "$want_build_doc"
1363	gzipped matrices support via zlib   : "${want_zlib_support}"
1364	gather elapsed time in librsb       : "${enable_librsb_stats}"
1365dnl
1366dnl	WANT_INTERNAL_HEADERS_INSTALL: "$enable_ihi"
1367dnl	CPU  	          : ${CPU}
1368dnl	all types ...
1369])
1370
1371if test x"$OCTAVE" != xfalse && test x"$want_int" != x  ; then
1372AC_MSG_NOTICE([You seem to have GNU Octave and enabled 'int' type. This will allow an additional part of the test suite to be generated.])
1373else
1374AC_MSG_NOTICE([You seem to not have GNU Octave or have disabled 'int' type. Part of the test suite will not be generated. If you want more testing capabilities, you should enable the 'int' type as well.])
1375fi
1376if test x"$M4" = x ; then
1377	AC_MSG_WARN([No m4 implementation detected. You will not be able to generate code.])
1378else
1379	true
1380fi
1381# FIXME : should warn the user in the case of opting out the 'int' type, as in this case there would be no GNU/octave based testing.
1382
1383if test x"$default_types"  != x"$want_matrix_types" ; then
1384AC_MSG_WARN([You chose a custom matrix types selection. If you just unpacked from archive, you should issue "make cleanall" to delete the shipped code and then "make" will regenerate it by using m4.])
1385fi
1386if test x"$want_rsb_dl"  = x"yes" ; then
1387dnl AC_MSG_WARN([You chose dynamic linking of example executables. To execute them you will probably to update your environment; e.g.: export LD_LIBRARY_PATH=`pwd`/:\$LD_LIBRARY_PATH .])
1388AC_MSG_WARN([You chose an obsolete switch (--enable-shlib-linked-examples), which now on is disabled.])
1389fi
1390AC_MSG_NOTICE([Successfully configured librsb version "$LIBRSB_VERSION".])
1391