configure.ac 11.1 KB
Newer Older
incardon's avatar
incardon committed
1 2 3
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

4
## Take all the options with the exception of --enable-install-req
incardon's avatar
incardon committed
5 6

AC_PREREQ(2.59)
incardon's avatar
incardon committed
7
AC_INIT(OpenFPM_numerics, 1.0.0, BUG-REPORT-ADDRESS)
incardon's avatar
incardon committed
8 9
AC_CANONICAL_SYSTEM
AC_CONFIG_SRCDIR([src/main.cpp])
10

incardon's avatar
incardon committed
11 12 13 14 15 16
AM_INIT_AUTOMAKE
AC_CONFIG_HEADER([src/config/config.h])
m4_ifdef([ACX_PTHREAD],,[m4_include([m4/acx_pthread.m4])])
m4_ifdef([ACX_MPI],,[m4_include([m4/acx_mpi.m4])])
m4_ifdef([AX_OPENMP],,[m4_include([m4/ax_openmp.m4])])
m4_ifdef([AX_CUDA],,[m4_include([m4/ax_cuda.m4])])
incardon's avatar
incardon committed
17
m4_ifdef([IMMDX_LIB_METIS],,[m4_include([m4/immdx_lib_metis.m4])])
18
m4_ifdef([IMMDX_LIB_PARMETIS],,[m4_include([m4/immdx_lib_parmetis.m4])])
19 20 21 22 23 24 25 26
m4_ifdef([AX_BOOST_BASE],,[m4_include([m4/ax_boost_base.m4])])
m4_ifdef([AX_BOOST_IOSTREAMS],,[m4_include([m4/ax_boost_iostreams.m4])])
m4_ifdef([AX_BOOST_PROGRAM_OPTIONS],,[m4_include([m4/ax_boost_program_options.m4])])
m4_ifdef([AX_BOOST_UNIT_TEST_FRAMEWORK],,[m4_include([m4/ax_boost_unit_test_framework.m4])])
m4_ifdef([AX_BLAS],,[m4_include([m4/ax_blas.m4])])
m4_ifdef([AX_LAPACK],,[m4_include([m4/ax_lapack.m4])])
m4_ifdef([AX_SUITESPARSE],,[m4_include([m4/ax_suitesparse.m4])])
m4_ifdef([AX_EIGEN],,[m4_include([m4/ax_eigen.m4])])
27
m4_ifdef([AX_LIB_HDF5],,[m4_include([m4/ax_lib_hdf5.m4])])
28
m4_ifdef([AX_LIB_PETSC],,[m4/ax_petsc_lib.m4])
Pietro Incardona's avatar
Pietro Incardona committed
29
m4_ifdef([AX_LIB_HILBERT],,[m4/ax_lib_hilbert.m4])
jenkins's avatar
jenkins committed
30

31
case $host_os in
jenkins's avatar
jenkins committed
32 33 34 35
   *darwin*|*macosx*)
        CXXFLAGS+=" --std=c++11 "
        AC_DEFINE([HAVE_OSX],[],[We have OSX])
        ;;
36 37 38 39 40 41 42 43 44
   *cygwin*)
        # Do something specific for cygwin
        CXXFLAGS+=" --std=gnu++11 "
        ;;
    *)
        #Default Case
        CXXFLAGS+=" --std=c++11 "
        ;;
esac
45

incardon's avatar
incardon committed
46 47 48
NVCCFLAGS=" "
INCLUDES_PATH=" "

49 50 51 52 53 54
# set default prefix
if test "$prefix" = "NONE"; then
   prefix="/usr/local"
fi

# Add openfpm_numerics to prefix forlder (if prefix end if openfpm_pdata remove that path)
incardon's avatar
incardon committed
55 56 57 58
if [ echo "$prefix" | grep -qE "/openfpm_pdata$" ]; then
  prefix=$(echo "$prefix" | sed 's/\(.*\)\/openfpm_pdata$/\1/g')
fi

59
prefix="$prefix/openfpm_numerics"
incardon's avatar
incardon committed
60 61 62 63 64 65 66 67 68
echo "Installation dir is: $prefix"

# Checks for programs.
AC_PROG_CXX

# Checks g++ flags

AC_CANONICAL_HOST

69
# Check that the compiler support mpi
incardon's avatar
incardon committed
70

71 72 73 74
AC_LANG_PUSH([C++])
AC_CHECK_HEADER(mpi.h,[],[echo "mpi.h not found"
                          exit 200])
AC_LANG_POP([C++])
incardon's avatar
incardon committed
75

76
# Check target architetture
incardon's avatar
incardon committed
77

78
#AX_GCC_ARCHFLAG([], [CXXFLAGS="$CXXFLAGS $ax_cv_gcc_archflag"], [])
incardon's avatar
incardon committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102

###### Check for debug compilation

AC_MSG_CHECKING(whether to build with debug information)
debuger=no
AC_ARG_ENABLE(debug,
	AC_HELP_STRING(
	    [--enable-debug],
	    [enable debug data generation (def=no)]
	),
  	debuger="$enableval"
)

AC_MSG_RESULT($debuger)
if test x"$debuger" = x"yes"; then
	AC_DEFINE([DEBUG_MODE],[],[Debug])
	AC_DEFINE([DEBUG],[],[Debug])
	CXXFLAGS="$CXXFLAGS -g3  -Wall -O0 "
	NVCCFLAGS+="$NVCCFLAGS -g -O0 "
else
	CXXFLAGS="$CXXFLAGS -Wall -O3 -g3 -funroll-loops "
	NVCCFLAGS+="$NVCCFLAGS -O3 "
fi

incardon's avatar
incardon committed
103 104 105
#########

## Check for Metis
106
####### include openfpm_devices include path
incardon's avatar
incardon committed
107 108 109 110

IMMDX_LIB_METIS([],[echo "Cannot detect metis, use the --with-metis option if it is not installed in the default location"
                    exit 201])

111 112 113 114 115 116 117 118
## Check for parMetis

IMMDX_LIB_PARMETIS([],[echo "Cannot detect parmetis, use the --with-parmetis option if it is not installed in the default location"
                    exit 203])

## Check for HDF5

AX_LIB_HDF5([parallel])
119
        
120 121 122 123 124
if test x"$with_hdf5" = x"no"; then
    echo "Cannot detect hdf5, use the --with-hdf5 option if it is not installed in the default location"
    exit 207
fi

125 126
#########

incardon's avatar
incardon committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
###### Check for test coverage

AC_MSG_CHECKING(whether to build with test coverage)
test_cov=no
AC_ARG_ENABLE(test-coverage,
        AC_HELP_STRING(
            [--enable-test-coverage],
            [enable test coverage]
        ),
        test_cov="$enableval"
)



AC_MSG_RESULT($test_cov)
if test x"$test_cov" = x"yes"; then
        AC_DEFINE([TEST_COVERAGE_MODE],[],[Test coverage mode])
        CXXFLAGS="$CXXFLAGS  -fprofile-arcs -ftest-coverage "
fi


148 149
## Check for quadmath

Pietro Incardona's avatar
Pietro Incardona committed
150 151
AC_LANG_PUSH([C++])

152 153 154 155 156
have_quad_lib=no
have_quad_head=no
AC_CHECK_LIB(quadmath, sinq, [have_quad_lib=yes], [])
AC_CHECK_HEADER(quadmath.h,[have_quad_head=yes],[])

incardon's avatar
incardon committed
157
if test x"have_quad_math" == x"yes"; then
158 159 160 161
    AC_DEFINE(HAVE_LIBQUADMATH,[],[Have quad math lib])
    LIBQUADMATH=" -lquadmath "
fi

162

Pietro Incardona's avatar
Pietro Incardona committed
163 164
AC_LANG_POP([C++])

165 166 167 168 169 170
###### RT runtime lib

AC_CHECK_LIB(rt, clock_gettime, [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Have clock time])
                                 OPT_LIBS="$OPT_LIBS -lrt"
                                ])

171 172 173 174 175 176
##########

## Check for LIBHILBERT

AX_LIB_HILBERT([],[echo "Cannot detect libhilbert, use the --with-libhilbert option if it is not installed in the default location"
                    exit 210])
177

178
####### include OpenFPM_numerics include path"
incardon's avatar
incardon committed
179

jenkins's avatar
jenkins committed
180
INCLUDES_PATH+=" -I/usr/local/include -I. -I../../openfpm_devices/src -I../../openfpm_data/src -I../../openfpm_io/src -I../../openfpm_vcluster/src -I../../src"
incardon's avatar
incardon committed
181

incardon's avatar
incardon committed
182 183 184 185 186 187 188 189
####### Detect OpenMP

AX_OPENMP([CFLAGS="$OPENMP_CFLAGS"
           LDFLAGS="$OPENMP_LDFLAGS"],[])

AC_SUBST(OPENMP_CFLAGS)
AC_SUBST(OPENMP_LDFLAGS)

190
###### Check for se-class1
incardon's avatar
incardon committed
191

192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
AC_MSG_CHECKING(whether to build with security enhancement class1)
se_class1=no
AC_ARG_ENABLE(se-class1,
        AC_HELP_STRING(
            [--enable-se-class1],
            [enable security enhancement class1]
        ),
        se_class1="$enableval"
)



AC_MSG_RESULT($se_class1)
if test x"$se_class1" = x"yes"; then
        AC_DEFINE([SE_CLASS1],[],[Security enhancement class 1])
fi


###### Check for se-class 2

AC_MSG_CHECKING(whether to build with security enhancement class 2)
se_class2=no
AC_ARG_ENABLE(se-class2,
        AC_HELP_STRING(
            [--enable-se-class2],
            [enable security enhancement class 2]
        ),
        se_class2="$enableval"
)


AC_MSG_RESULT($se_class2)
if test x"$se_class2" = x"yes"; then
        AC_DEFINE([SE_CLASS2],[],[Security enhancement class 2])
fi

###### Check for se-class 3

AC_MSG_CHECKING(whether to build with security enhancement class 3)
se_class3=no
AC_ARG_ENABLE(se-class3,
        AC_HELP_STRING(
            [--enable-se-class3],
            [enable security enhancement class 3]
        ),
        se_class3="$enableval"
incardon's avatar
incardon committed
238 239 240
)


241 242 243 244

AC_MSG_RESULT($se_class3)
if test x"$se_class3" = x"yes"; then
        AC_DEFINE([SE_CLASS3],[],[Security enhancement class 3])
incardon's avatar
incardon committed
245 246
fi

247 248 249 250 251 252 253 254 255 256 257 258 259
action_on_e=continue
AC_ARG_WITH([action-on-error],
             AS_HELP_STRING([--with-action-on-error=stop,throw,continue],
             [specify the action to do in case of error]),
             [action_on_e="$withval"],
             [action_on_e=continue])

if test x"$action_on_e" = x"stop"; then
           AC_DEFINE([STOP_ON_ERROR],[],[If an error occur stop the program])
fi
if test x"$action_on_e" = x"throw"; then
           AC_DEFINE([THROW_ON_ERROR],[],[when an error accur continue but avoid unsafe operation])
fi
incardon's avatar
incardon committed
260 261 262

##### CHECK FOR BOOST ##############

263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
AX_BOOST_BASE([1.52],[],[echo "boost not found"
                    exit 202])
AX_BOOST_UNIT_TEST_FRAMEWORK
AX_BOOST_PROGRAM_OPTIONS
AX_BOOST_IOSTREAMS

if test x"$ax_cv_boost_unit_test_framework" = x"no"; then
  echo "Notify boost not usable"
  exit 202
fi

if test x"$ax_cv_boost_iostreams" = x"no"; then
  echo "Notify boost not usable"
  exit 202
fi

if test x"$ax_cv_boost_programs_options" = x"no"; then
  echo "Notify boost not usable"
  exit 202
fi

### Unfortunately a lot of linux distros install a pretty old MPI in the system wide folder,
### override such MPI with the installed one is extremely difficult and tricky, because we want
### to include "some" system library but exclude mpi. One possibility is to give specifically
### the wanted libmpi.so directly to the linker. But this is not possible because this lib is
### given by mpic++ in the form -L/path/to/mpi -lmpi, the other is completely eliminate every
### -L with a system default library
###

# eliminate any /usr/lib and and /usr/include from $BOOST_LIB and $BOOST_INCLUDE

BOOST_LDFLAGS=$(echo "$BOOST_LDFLAGS" | sed -e 's/ -L\/usr\/lib64[ \b]//g' | sed -e 's/ -L\/usr\/lib[ \b]//g')
BOOST_CPPFLAGS=$(echo "$BOOST_CPPFLAGS" | sed -e 's/-I\/usr\/include[ \b]//g')

AC_SUBST(BOOST_LDFLAGS)
AC_SUBST(BOOST_CPPFLAGS)

###### Checking for OpenBLAS

incardon's avatar
incardon committed
302
AX_BLAS([],[])
303

incardon's avatar
incardon committed
304
AX_LAPACK([],[])
305 306 307

###### Checking for SUITESPARSE

incardon's avatar
incardon committed
308
AX_SUITESPARSE([],[])
309

310 311 312 313 314 315
##########

## Check for PETSC

AX_LIB_PETSC()

316 317
###### Checking for EIGEN

incardon's avatar
incardon committed
318
AX_EIGEN([],[])
incardon's avatar
incardon committed
319

320
###### Checking for libquadmath and libifcore
jenkins's avatar
jenkins committed
321

322
AC_CHECK_LIB(ifcore, for_cpystr, [ LIBIFCORE=-lifcore  ], [ LIBIFCORE= ])
jenkins's avatar
jenkins committed
323 324
AC_CHECK_LIB(quadmath, sinq, [ LIBQUADMATH=-lquadmath  ], [ LIBQUADMATH= ])
AC_SUBST(LIBQUADMATH)
325
AC_SUBST(LIBIFCORE)
jenkins's avatar
jenkins committed
326

327 328
###### Checking for compiler flags -fext-numeric-literals

Pietro Incardona's avatar
Pietro Incardona committed
329 330 331 332
AC_LANG_PUSH([C++])

my_save_cflags="$CXXFLAGS"
CXXFLAGS=-fext-numeric-literals
333 334 335 336 337 338
AC_MSG_CHECKING([whether CXX supports -fext-numeric-literals])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
    [AC_MSG_RESULT([yes])]
    [AM_CXXFLAGS=-fext-numeric-literals],
    [AC_MSG_RESULT([no])]
)
Pietro Incardona's avatar
Pietro Incardona committed
339 340
AC_LANG_POP([C++])
CXXFLAGS="$my_save_cflags"
341 342
AC_SUBST([AM_CXXFLAGS])

Pietro Incardona's avatar
Pietro Incardona committed
343 344


incardon's avatar
incardon committed
345 346 347 348
####### Checking for GPU support

AX_CUDA

349 350
## detect for NVCC

incardon's avatar
incardon committed
351 352 353 354
if test x"$NVCC_EXIST" = x"yes"; then
  AC_MSG_CHECKING(whether to build with GPU support)
  gpu_support=yes
  AC_ARG_ENABLE(gpu,
355 356 357 358 359
	AC_HELP_STRING(
	    [--enable-gpu],
	    [enable gpu support]
	),
  	gpu_support="$enableval"
incardon's avatar
incardon committed
360 361 362 363
  )

  AC_MSG_RESULT($gpu_support)
  if test x"$gpu_support" = x"yes"; then
364 365 366 367
	AC_DEFINE([GPU],[],[GPU support])
  else
	CUDA_LIBS=""
	CUDA_CFLAGS=""
incardon's avatar
incardon committed
368 369 370 371 372
  fi
else
  gpu_support=no
fi

373 374 375 376
if test x$gpu_support = x"no"; then
     CUDA_LIBS=""
     CUDA_CFLAGS=""
fi
incardon's avatar
incardon committed
377 378 379

# Set this conditional if cuda is wanted

380 381 382
AM_CONDITIONAL(BUILDCUDA, test ! x$NVCC = x"no")

###########################
incardon's avatar
incardon committed
383

384
# Define that there is MPI
incardon's avatar
incardon committed
385

386
AC_DEFINE([HAVE_MPI],[],[MPI Enabled])
incardon's avatar
incardon committed
387 388 389

AC_SUBST(NVCCFLAGS)
AC_SUBST(INCLUDES_PATH)
390
AC_SUBST(LIBQUADMATH)
391
AC_SUBST(OPT_LIBS)
incardon's avatar
incardon committed
392 393 394 395 396

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

397
AC_CONFIG_FILES([Makefile src/Makefile ])
incardon's avatar
incardon committed
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
AC_OUTPUT
echo ""
echo   "***********************************"
echo   "*                                 *"
if [ test x"$profiler" = x"yes" ]; then
  echo "*    profiler: yes                *"
else
  echo "*    profiler: no                 *"
fi
if [ test x"$memcheck" = x"yes" ]; then
  echo "*    memcheck: yes                *"
else
  echo "*    memcheck: no                 *"
fi
if [ test x"$debuger" = x"yes" ]; then
  echo "*    debug: yes                   *"
else
  echo "*    debug: no                    *"
fi
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
if [ test x"$se_class1" = x"yes" ]; then
  echo "*    se-class1: yes               *"
else
  echo "*    se-class1: no                *"
fi
if [ test x"$se_class2" = x"yes" ]; then
  echo "*    se-class2: yes               *"
else
  echo "*    se-class2: no                *"
fi
if [ test x"$se_class3" = x"yes" ]; then
  echo "*    se-class3: yes               *"
else
  echo "*    se-class3: no                *"
fi
incardon's avatar
incardon committed
432 433 434 435 436 437 438 439
if [ test x"$gpu_support" = x"no" ]; then
  echo "*    gpu: no                      *"
else
  echo "*    gpu: yes                     *"
fi
echo   "*                                 *"
echo   "***********************************"