1AC_PREREQ(2.59)
2# was 2.61 but jaguar is not up to date so backported which
3# involved replacing AC_PROG_SED and UINT*_T type checks.
4AC_INIT([MADNESS], [0.10.1], [https://github.com/m-a-d-n-e-s-s/madness/issues], , [https://github.com/m-a-d-n-e-s-s/madness])
5AC_CONFIG_SRCDIR([configure.ac])
6
7# This is where autoconf automatically generated files go
8AC_CONFIG_AUX_DIR([config])
9
10# This is where local macros will be stored (by us)
11AC_CONFIG_MACRO_DIR([config])
12
13# Default options for automake ??
14AM_INIT_AUTOMAKE([-Wall -Werror nostdinc foreign])
15m4_pattern_allow([AM_PROG_AR])
16AM_PROG_AR
17
18# We want #defines output into a header file
19AC_CONFIG_HEADERS([src/madness/config.h])
20
21# Detect specific systems so can provide their whacky defaults
22acx_default_enable_all_static=no
23ACX_CRAYXT
24ACX_CRAYXE
25ACX_MAC
26ACX_IBMBGP
27ACX_IBMBGQ
28#AC_AIX
29ACX_WITH_STUBMPI
30
31# Set default thread processor-affinity
32BIND=${BIND-"-1 -1 -1"}
33AC_DEFINE_UNQUOTED([MAD_BIND_DEFAULT], ["$BIND"], [The default binding for threads])
34
35
36# This sets host, host_cpu, host_vendor, host_os
37AC_CANONICAL_HOST
38AC_MSG_NOTICE([HOST INFORMATION:   $host    $host_cpu    $host_vendor    $host_os])
39AC_DEFINE_UNQUOTED([HOST_CPU], ["$host_cpu"], [Defines the host cpu (x86, x86_64, ...).])
40AC_DEFINE_UNQUOTED([HOST_SYSTEM], ["$host_os"], [Defines the host os (linux-gnu, ...).])
41
42# Pick out CPUs for which we have special source files (assembler)
43use_x86_64_asm=no
44use_x86_32_asm=no
45
46AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
47#if !(defined(__x86_64__) || defined(_M_X64))
48#error Not x86_64
49#endif
50]])], [use_x86_64_asm=yes])
51
52if test $use_x86_64_asm = no; then
53  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
54#if !(defined(__i386) || defined(_M_IX86))
55#error Not x86
56#endif
57]])], [use_x86_32_asm=yes])
58fi
59
60# Define AM conditional for use of aforementioned assembler
61AM_CONDITIONAL([USE_X86_64_ASM], [test $use_x86_64_asm = yes])
62AM_CONDITIONAL([USE_X86_32_ASM], [test $use_x86_32_asm = yes])
63
64# All source will be built with the MPI C++ and C compilers
65ACX_MPI
66
67initial_CFLAGS="$CFLAGS"
68initial_CXXFLAGS="$CXXFLAGS"
69
70AC_PROG_CC([$MPICC])
71AC_PROG_CXX([$MPICXX])
72AC_PROG_F77([$MPIF77]) # f90 is a superset of f77
73AC_LANG_CPLUSPLUS
74AC_MSG_NOTICE([Compiler choices after 'AC LANG' ... $CXX and $CC])
75
76CFLAGS="$initial_CFLAGS"
77CXXFLAGS="$initial_CXXFLAGS"
78
79# Check that the MPICC Compiler can link correctly.
80AC_LANG_PUSH([C])
81AC_MSG_CHECKING([that the $MPICC linker works])
82AC_LINK_IFELSE(
83  [AC_LANG_PROGRAM([[]], [[]])],
84  [AC_MSG_RESULT([yes])],
85  [AC_MSG_RESULT([no])
86   AC_MSG_ERROR(["Unable to link with $MPICC])])
87AC_LANG_POP
88
89# Check that the MPICXX Compiler can link correctly.
90AC_MSG_CHECKING([that the $MPICXX linker works])
91AC_LINK_IFELSE(
92  [AC_LANG_PROGRAM([[]], [[]])],
93  [AC_MSG_RESULT([yes])],
94  [AC_MSG_RESULT([no])
95   AC_MSG_ERROR(["Unable to link with $MPICXX])])
96
97# Initialize Libtools (for shared libraries)
98LT_INIT
99LT_LANG([C++])
100AC_SUBST(enable_shared)
101AC_SUBST(enable_static)
102AC_ARG_ENABLE([all-static],
103    [AC_HELP_STRING([--enable-all-static@<:@=yes|no@:>@],
104      [Link with all static libraries --- likely to fail due to missing system static libraries. Do you really instead want --disable-shared which will avoid building the shared libaries and link against our static libraries?.])],
105    [
106      case $enableval in
107      yes)
108        acx_enable_all_static="yes"
109      ;;
110      no)
111        acx_enable_all_static="no"
112      ;;
113      *)
114        AC_MSG_ERROR([Invalid argument '$enableval' given for --enable-all-static])
115      esac
116    ],
117    [acx_enable_all_static="$acx_default_enable_all_static"]
118  )
119
120AM_CONDITIONAL([LINK_ALL_STATIC], [test $acx_enable_all_static = yes])
121
122ACX_DETECT_CXX
123# Check for C++14 support, and
124# add the -std=c++14 or -std=c++1y flag to CXXFLAGS if necessary.
125AX_CXX_COMPILE_STDCXX(14,[noext],[mandatory])
126
127# Detect which version of (__)restrict(__) is supported and define MADNESS_RESTRICT to it
128ACX_CXX_RESTRICT
129
130# Set debugging
131ACX_ENABLE_DEBUGGING
132
133# Set optimization
134ACX_ENABLE_OPTIMIZATION
135
136# Set warning flags by compiler vendor
137ACX_ENABLE_WARN
138
139# Select best compilation flags
140ACX_ENABLE_OPTIMAL
141
142# Get optional external libraries inplace so that building will partially check them
143#ACX_WITH_LIBUNWIND ... no longer needed for google perf?
144ACX_WITH_GOOGLE_PERF
145ACX_WITH_GOOGLE_TEST
146ACX_WITH_LIBXC
147ACX_WITH_PCM
148ACX_WITH_TBB
149ACX_ENABLE_GENTENSOR
150
151# Set task profiler option
152ACX_ENABLE_TASK_PROFILER
153
154# Check for basic build functionality
155AC_PROG_INSTALL
156AC_PROG_LN_S
157AC_PROG_MAKE_SET
158AM_PROG_AS
159#AC_PROG_SED
160AC_CHECK_PROG([HAVE_SED],[sed],[YES],[NO])
161if test $HAVE_SED = YES; then
162   AC_PATH_PROG(SED,sed)
163fi
164
165# We need these to build the documentation
166AC_CHECK_PROG([HAVE_DOXYGEN],[doxygen],[YES],[NO])
167if test $HAVE_DOXYGEN = YES; then
168   AC_PATH_PROG(DOXYGEN,doxygen)
169fi
170AC_CHECK_PROG([HAVE_DOT],[dot],[YES],[NO])
171if test $HAVE_DOT = YES; then
172   AC_PATH_PROG(DOT,dot)
173fi
174AC_CHECK_PROG([HAVE_PDFLATEX],[pdflatex],[YES],[NO])
175if test $HAVE_PDFLATEX = YES; then
176   AC_PATH_PROG(PDFLATEX,pdflatex)
177fi
178AC_CHECK_PROG([HAVE_LATEX],[latex],[YES],[NO])
179if test $HAVE_LATEX = YES; then
180   AC_PATH_PROG(LATEX,latex)
181fi
182AM_CONDITIONAL([CAN_BUILD_DOC], [test $HAVE_DOXYGEN = YES])
183
184AC_HEADER_TIME
185AC_HEADER_STDC
186AC_CHECK_HEADERS([limits.h stddef.h stdint.h stdlib.h string.h sys/param.h sys/time.h unistd.h])
187AC_CHECK_HEADERS([bits/atomicity.h ext/atomicity.h])
188AC_HEADER_STDBOOL
189# Check c++1x headers
190# MUST include CXXFLAGS into CPPFLAGS to choose proper C++ standard switch
191ac_save_CPPFLAGS="$CPPFLAGS"
192CPPFLAGS="$CPPFLAGS $CXXFLAGS"
193AC_CHECK_HEADERS([array type_traits tuple initializer_list])
194CPPFLAGS="$ac_save_CPPFLAGS"
195
196# Types
197AC_TYPE_PID_T
198ACX_CHECK_TLS
199AC_TYPE_SIZE_T
200#AC_TYPE_UINT64_T
201#AC_TYPE_INT64_T
202AC_CHECK_TYPES([uint64_t, int64_t, uint32_t, int32_t, uint16_t, uint8_t, long long])
203AC_C_VOLATILE
204AC_C_CONST
205AC_C_INLINE
206AC_CHECK_TYPES([ptrdiff_t])
207AC_CHECK_SIZEOF([void *])
208AC_SUBST([AUTOCONF_SIZEOF_VOID_P],[$ac_cv_sizeof_void_p])
209
210# Library functions
211AC_CHECK_FUNCS([sleep random execv perror gettimeofday memmove memset pow sqrt strchr strdup getenv])
212AC_FUNC_FORK
213# EFV: when using Intel compiler on OS X malloc is found to be non-GNU-compatible, which breaks gcc's cstdlib
214#AC_FUNC_MALLOC
215AC_FUNC_ERROR_AT_LINE
216ACX_POSIX_MEMALIGN
217
218# Check for Elemental
219ACX_WITH_ELEMENTAL
220
221# Set the default fortran integer type
222AC_ARG_WITH([fortran-int32],
223            [AC_HELP_STRING([--with-fortran-int32], [Set FORTRAN integer size to 32 bit. By default, assume 32-bit integers.])],
224            [
225              case $withval in
226              yes)
227                acx_fortran_int_size=4
228              ;;
229              no)
230                acx_fortran_int_size=8
231              ;;
232              *)
233                AC_MSG_ERROR([Unknown value provided for --with-fortran-int32])
234              esac
235            ],
236            [acx_fortran_int_size=4])
237
238case $acx_fortran_int_size in
2394)
240  AC_DEFINE([MADNESS_FORTRAN_DEFAULT_INTEGER_SIZE],[4],[Default Fortran integer size.])
241  AC_SUBST([MADNESS_FORTRAN_DEFAULT_INTEGER_SIZE],[4])
242  AC_MSG_NOTICE([Default Fortran integer: integer*4])
243;;
2448)
245  if test x$ac_cv_type_int64_t = xno; then
246    AC_MSG_ERROR([The compiler does not support int64_t, which is required to link with fortran libraries that use 8 byte integers. Rerun configure with '--with-fortran-int32' option.])
247  fi
248  AC_DEFINE([MADNESS_FORTRAN_DEFAULT_INTEGER_SIZE],[8],[Default Fortran integer size.])
249  AC_SUBST([MADNESS_FORTRAN_DEFAULT_INTEGER_SIZE],[8])
250  AC_MSG_NOTICE([Default Fortran integer: integer*8])
251esac
252
253ACX_WITH_MKL
254
255# Checks for Fortran linking conventions and BLAS+LAPACK at the same time
256ACX_FORTRAN_SYMBOLS
257
258# Compiler quirks
259ACX_UNQUALIFIED_STATIC_DECL
260ACX_STD_ABS
261
262# Check for xterm
263AC_CHECK_PROG(XTERM,xterm,xterm,no)
264if test $XTERM = 'xterm'; then
265  AC_DEFINE(HAVE_XTERM,[1],[If set indicates xterm is in path])
266fi
267
268# Check for gdb
269AC_CHECK_PROG(GDB,gdb,gdb,no)
270if test $GDB = 'gdb'; then
271  AC_DEFINE(HAVE_GDB,[1],[If set indicates gdb is in path])
272fi
273
274# How to handle MADNESS exceptions.
275AC_ARG_ENABLE(madex,
276              [AC_HELP_STRING([--enable-madex=arg],
277                [Specifies behavior of MADNESS assertions: throw (default), abort, assert, disable])],
278              [madex=$enableval],
279              [madex=throw])
280case $madex in
281  abort)
282    AC_MSG_NOTICE([MADNESS assertions will abort])
283    AC_DEFINE([MADNESS_ASSERTIONS_ABORT], [1], [Set if MADNESS assertions abort])
284  ;;
285  assert)
286    AC_MSG_NOTICE([MADNESS assertions will assert])
287    AC_DEFINE([MADNESS_ASSERTIONS_ASSERT], [1], [Set if MADNESS assertions assert])
288  ;;
289  disable)
290    AC_MSG_NOTICE([MADNESS assertions are disabled])
291    AC_DEFINE([MADNESS_ASSERTIONS_DISABLE], [1], [Set if MADNESS assertions disabled])
292  ;;
293  *)
294    AC_MSG_NOTICE([MADNESS assertions will throw])
295    AC_DEFINE([MADNESS_ASSERTIONS_THROW], [1], [Set if MADNESS assertions throw])
296  ;;
297esac
298
299# Determine if we should use the instrumented new/delete
300AC_ARG_ENABLE([memstats],
301              [AC_HELP_STRING([--enable-memstats], [If yes, gather memory statistics (expensive)])],
302              [memstats=$enableval],
303              [memstats=no])
304if test "$memstats" = "yes"; then
305  AC_MSG_NOTICE([MADNESS will gather memory statistics (expensive)])
306  AC_DEFINE([WORLD_GATHER_MEM_STATS], [1], [Set if MADNESS gathers memory statistics])
307fi
308
309AC_ARG_ENABLE([profile],
310              [AC_HELP_STRING([--enable-profile], [Enables profiling])],
311              [AC_MSG_NOTICE([Enabling profiling]); AC_DEFINE(WORLD_PROFILE_ENABLE, [1], [Define if should enable profiling])],
312              [])
313
314AC_ARG_ENABLE([tensor-bounds-checking],
315              [AC_HELP_STRING([--enable-tensor-bounds-checking],
316                [Enable checking of bounds in tensors ... slow but useful for debugging])],
317              [AC_MSG_NOTICE([Enabling tensor bounds checking]); AC_DEFINE(TENSOR_BOUNDS_CHECKING, [1], [Define if should enable bounds checking in tensors])],
318              [])
319
320AC_ARG_ENABLE([tensor-instance-count],
321              [AC_HELP_STRING([--enable-tensor-instance-count],
322                [Enable counting of allocated tensors for memory leak detection])],
323              [AC_MSG_NOTICE([Enabling tensor instance counting]); AC_DEFINE(TENSOR_INSTANCE_COUNT, [1], [Define if should enable instance counting in tensors])],
324              [])
325
326AC_ARG_ENABLE([spinlocks],
327              [AC_HELP_STRING([--enable-spinlocks],
328                [Enables use of spinlocks instead of mutexs (faster unless over subscribing processors)])],
329              [AC_MSG_NOTICE([Enabling use of spinlocks]); AC_DEFINE(USE_SPINLOCKS, [1], [Define if should use spinlocks])],
330              [])
331
332AC_ARG_ENABLE([never-spin],
333              [AC_HELP_STRING([--enable-never-spin],
334                [Disables use of spinlocks (notably for use inside virtual machines)])],
335              [AC_MSG_NOTICE([Disabling use of spinlocks]); AC_DEFINE(NEVER_SPIN, [1], [Define if should use never use spinlocks])],
336              [])
337
338AC_ARG_WITH([papi],
339            [AC_HELP_STRING([--with-papi], [Enables use of PAPI])],
340            [AC_MSG_NOTICE([Enabling use of PAPI]); AC_DEFINE(HAVE_PAPI,[1], [Define if have PAPI])],
341            [])
342
343AC_ARG_WITH([parsec],
344            [AC_HELP_STRING([--with-parsec], [Build with support for PaRSEC])])
345AS_IF([test "x$with_parsec" != "xno"],
346      [AS_IF([test "x$with_parsec" != "xyes"],
347             [PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$with_parsec/lib/pkgconfig"])
348       PKG_CHECK_MODULES([PaRSEC], [parsec],
349                         [AC_DEFINE([HAVE_PARSEC], [1], [Define if have PaRSEC])
350                          # Remove the trailing -I from the PaRSEC pkgconfig file
351                          PaRSEC_CFLAGS=`echo ${PaRSEC_CFLAGS} | sed 's#-I$##'`
352                          CFLAGS="$CFLAGS ${PaRSEC_CFLAGS}"
353                          # Don't propagate the -std=c99 C flag to C++
354                          PARSEC_CXXFLAGS=`echo ${PaRSEC_CFLAGS} | sed 's#-std=c99##'`
355                          CXXFLAGS="$CXXFLAGS ${PARSEC_CXXFLAGS}"
356                          LIBADD="$LIBADD ${PaRSEC_LIBS}"],
357                         [with_parsec="no"])
358       ])
359AM_CONDITIONAL([USE_PARSEC], [test "x$with_parsec" != "xno"])
360
361# Capture configuration info for user by compiled code
362AC_DEFINE_UNQUOTED([MADNESS_CONFIGURATION_USER],["$USER"],[User that configured the code])
363AC_DEFINE_UNQUOTED([MADNESS_CONFIGURATION_DATE],["`date`"],[Date of configuration])
364AC_DEFINE_UNQUOTED([MADNESS_CONFIGURATION_CXX], ["$CXX"],[Configured C++ compiler])
365AC_DEFINE_UNQUOTED([MADNESS_CONFIGURATION_CXXFLAGS], ["$CXXFLAGS"],[Configured C++ compiler flags])
366AC_DEFINE_UNQUOTED([MADNESS_CONFIGURATION_HOST], ["$HOSTNAME"],[Configured on this machine])
367
368# Pass additional configuration information to be used in source
369# ALSO: undefine the standard definitions that every autoheader-using package will define and thus clash
370AC_DEFINE_UNQUOTED([MADNESS_PACKAGE_NAME],["$PACKAGE_NAME"],[The full name of this package])
371AC_DEFINE_UNQUOTED([MADNESS_PACKAGE_VERSION],["$PACKAGE_VERSION"],[The version of this package])
372AC_DEFINE_UNQUOTED([MADNESS_PACKAGE_URL],["$PACKAGE_URL"],[The URL of the home page of this package])
373AC_DEFINE_UNQUOTED([MADNESS_PACKAGE_BUGREPORT],["$PACKAGE_BUGREPORT"],[The address where to send bug reports for this package])
374
375# Not yet enabled the user to configure this stuff but probably should
376AC_ARG_ENABLE([bsend-ack],
377            [AC_HELP_STRING([--disable-bsend-ack], [Use MPI Send instead of MPI Bsend for huge message acknowledgements.])],
378            [
379              if test "x$enableval" != xno; then
380                AC_DEFINE([MADNESS_USE_BSEND_ACKS],[1],[Define when MADNESS should use Bsend for huge message acknowledgements.])
381              fi
382            ],
383            [
384             AC_DEFINE([MADNESS_USE_BSEND_ACKS],[1],[Define when MADNESS should use Bsend for huge message acknowledgements.])
385            ])
386
387# Set the MPI thread level used by MADNESS
388# the default is not MPI_THREAD_MULTIPLE
389MADNESS_MPI_THREAD_LEVEL=MPI_THREAD_MULTIPLE
390AC_ARG_WITH([mpi-thread],
391            [AC_HELP_STRING([--with-mpi-thread], [Thread level for MPI (multiple,serialized)])],
392            [
393              case $withval in
394                multiple)
395                  MADNESS_MPI_THREAD_LEVEL=MPI_THREAD_MULTIPLE
396                  ;;
397                serialized)
398                  MADNESS_MPI_THREAD_LEVEL=MPI_THREAD_SERIALIZED
399                  ;;
400                *)
401                  AC_MSG_ERROR([Invalid value for --with-mpi-thread ($withval)])
402                  ;;
403              esac
404            ])
405AC_DEFINE_UNQUOTED([MADNESS_MPI_THREAD_LEVEL], [$MADNESS_MPI_THREAD_LEVEL], [Thread-safety level requested from MPI by MADNESS])
406AC_MSG_NOTICE([MPI thread-safety requested: $MADNESS_MPI_THREAD_LEVEL])
407# to use Elemental MUST use MPI_THREAD_MULTIPLE
408if test X$MADNESS_HAS_ELEMENTAL = X1 && test X$MADNESS_MPI_THREAD_LEVEL != XMPI_THREAD_MULTIPLE; then
409  AC_MSG_ERROR([Use of Elemental precludes --with-mpi-thread=serialized, must use --with-mpi-thread=multiple])
410fi
411
412# Display options
413AC_MSG_NOTICE([CPPFLAGS = $CPPFLAGS])
414AC_MSG_NOTICE([CFLAGS   = $CFLAGS])
415AC_MSG_NOTICE([CXXFLAGS = $CXXFLAGS])
416AC_MSG_NOTICE([LDFLAGS  = $LDFLAGS])
417AC_MSG_NOTICE([LIBS     = $LIBS])
418AC_MSG_NOTICE([build shared libraries: $enable_shared])
419AC_MSG_NOTICE([build static libraries: $enable_static])
420AC_MSG_NOTICE([link all static libraries: $acx_enable_all_static])
421
422# Set the library suffix used when generating doc/devsamp/Makefile.sample
423if test $enable_shared = yes; then
424
425if test $ON_A_MAC = yes; then
426# OS X library suffix
427AC_SUBST(LIB_SUFFIX,.dylib)
428else
429# Linux library suffix
430AC_SUBST(LIB_SUFFIX,.so)
431fi
432
433else
434
435# Set the static library file suffix (same on Linux and OS X)
436AC_SUBST(LIB_SUFFIX,.a)
437
438fi
439
440
441# These are the files that must be generated/preprocessed ... as you add files
442# please maintain the directory tree file order and indenting.
443AC_CONFIG_FILES([
444  Makefile
445    config/Makefile
446    config/MADNESS.pc
447    config/madness-config.cmake
448    config/madness-config-version.cmake
449    config/madness-project.cmake
450    src/Makefile
451      src/madness/Makefile
452        src/madness/external/Makefile
453          src/madness/external/gtest/Makefile
454          src/madness/external/muParser/Makefile
455          src/madness/external/tinyxml/Makefile
456        src/madness/world/Makefile
457        src/madness/misc/Makefile
458        src/madness/tensor/Makefile
459        src/madness/mra/Makefile
460      src/apps/Makefile
461        src/apps/chem/Makefile
462        src/apps/tdse/Makefile
463        src/apps/moldft/Makefile
464      src/examples/Makefile
465        src/examples/compiler/Makefile-prog
466    doc/Makefile
467    doc/doxygen.cfg
468    doc/devsamp/Makefile.sample
469])
470
471# The following make files are not generated by default. If you want to build
472# these applications, move the appropriate file into the AC_CONFIG_FILES list
473# above.
474
475#        src/apps/hf/Makefile
476#        src/apps/exciting/Makefile
477#        src/apps/polar/Makefile
478#        src/apps/nick/Makefile
479#        src/apps/interior_bc/Makefile
480
481AC_OUTPUT
482