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


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


AM_INIT_AUTOMAKE([subdir-objects])
incardon's avatar
incardon committed
12
AC_CONFIG_HEADER([src/config/config.h])
incardon's avatar
incardon committed
13 14 15 16
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 18 19 20
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])])
incardon's avatar
incardon committed
21

Pietro Incardona's avatar
Pietro Incardona committed
22

Pietro Incardona's avatar
Pietro Incardona committed
23 24 25 26 27 28 29 30 31 32 33 34
case $host_os in
   *cygwin*)
        # Do something specific for cygwin
        CXXFLAGS+=" --std=gnu++11 "
        ;;
    *)
        #Default Case
        CXXFLAGS+=" --std=c++11 "
        ;;
esac

CXXFLAGS+=" -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-unused-parameter "
incardon's avatar
incardon committed
35
NVCCFLAGS=" "
incardon's avatar
incardon committed
36
INCLUDES_PATH=" "
incardon's avatar
incardon committed
37

incardon's avatar
incardon committed
38 39 40 41 42
# set default prefix
if test "$prefix" = "NONE"; then
   prefix="/usr/local"
fi

43 44 45 46 47
# Add openfpm_vcluster to prefix forlder (if prefix end if openfpm_pdata remove that path)
if [ echo "$prefix" | grep -qE "/openfpm_pdata$" ]; then
  prefix=$(echo "$prefix" | sed 's/\(.*\)\/openfpm_pdata$/\1/g')
fi

incardon's avatar
incardon committed
48 49 50 51 52 53
prefix="$prefix/openfpm_vcluster"
echo "Installation dir is: $prefix"

AC_PROG_RANLIB
AM_PROG_AR

incardon's avatar
incardon committed
54 55 56 57 58 59 60
# Checks for programs.
AC_PROG_CXX

# Checks g++ flags

AC_CANONICAL_HOST

incardon's avatar
incardon committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
###### Check for verbose

AC_MSG_CHECKING(whether to build with verbose print)
verbose=no
AC_ARG_ENABLE(verbose,
	AC_HELP_STRING(
	    [--enable-verbose],
	    [enable verbose print (def=no)]
	),
  	verbose="$enableval"
)



AC_MSG_RESULT($verbose)
if test x"$verbose" = x"yes"; then
	AC_DEFINE([VERBOSE_TEST],[],[Verbose test])
fi

incardon's avatar
incardon committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
###### 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
incardon's avatar
incardon committed
101
	CXXFLAGS="$CXXFLAGS -Wall -O3 -g3 -funroll-loops "
incardon's avatar
incardon committed
102 103 104
	NVCCFLAGS+="$NVCCFLAGS -O3 "
fi

105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
###### Check for se-class1

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"
)



AC_MSG_RESULT($se_class3)
if test x"$se_class3" = x"yes"; then
        AC_DEFINE([SE_CLASS3],[],[Security enhancement class 3])
fi

Pietro Incardona's avatar
Pietro Incardona committed
162

incardon's avatar
incardon committed
163
####### include openfpm_devices include path
incardon's avatar
incardon committed
164

incardon's avatar
incardon committed
165
INCLUDES_PATH+=" -I/usr/local/include -I. -Iconfig -I../../openfpm_devices/src -I../../openfpm_data/src"
incardon's avatar
incardon committed
166

167
########
incardon's avatar
incardon committed
168

incardon's avatar
incardon committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
###### Checking for compiler flags -fext-numeric-literals

AC_LANG_PUSH([C++])

my_save_cflags="$CXXFLAGS"
CXXFLAGS=-fext-numeric-literals
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])
    ]
)
AC_LANG_POP([C++])
CXXFLAGS="$my_save_cflags"
AC_SUBST([AM_CXXFLAGS])


189 190 191 192 193 194 195 196 197
## Enable scan coverty

AC_MSG_CHECKING(whether to build for scan coverty compilation)
AC_ARG_ENABLE(scan-coverty,
        AC_HELP_STRING(
            [--enable-scan-coverty],
            [enable scan-coverty compilation (def=no)]
        ),
        scancoverty="$enableval"
incardon's avatar
incardon committed
198 199
)

200
AC_MSG_RESULT($scancoverty)
incardon's avatar
incardon committed
201

202 203
if test x"$scancoverty" = x"yes"; then
        AC_DEFINE([COVERTY_SCAN],[],[Compile for coverty scan])
incardon's avatar
incardon committed
204 205
fi

incardon's avatar
incardon committed
206 207 208 209 210 211 212
####################################

DEFAULT_LIB=""
# At least for glibc, clock_gettime is in librt.  But don't pull that
# in if it still doesn't give us the function we want.
AC_CHECK_LIB(rt, clock_gettime,[DEFAULT_LIB+=" -lrt "],[],[])

incardon's avatar
incardon committed
213 214
##### CHECK FOR BOOST ##############

incardon's avatar
incardon committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
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
incardon's avatar
incardon committed
235

incardon's avatar
incardon committed
236 237 238 239 240 241 242 243 244 245
### 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

incardon's avatar
incardon committed
246 247
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')
incardon's avatar
incardon committed
248 249 250 251

AC_SUBST(BOOST_LDFLAGS)
AC_SUBST(BOOST_CPPFLAGS)

incardon's avatar
incardon committed
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
####### Checking for GPU support

AX_CUDA

if test x"$NVCC_EXIST" = x"yes"; then
  AC_MSG_CHECKING(whether to build with GPU support)
  gpu_support=yes
  AC_ARG_ENABLE(gpu,
        AC_HELP_STRING(
            [--enable-gpu],
            [enable gpu support]
        ),
        gpu_support="$enableval"
  )

  AC_MSG_RESULT($gpu_support)
  if test x"$gpu_support" = x"yes"; then
        AC_DEFINE([CUDA_GPU],[],[CUDA GPU support])
  fi
else
  gpu_support=no
incardon's avatar
incardon committed
273 274 275 276 277
fi


# Set this conditional if cuda is wanted

incardon's avatar
incardon committed
278 279 280 281 282
#

AM_CONDITIONAL(BUILDCUDA, test x$gpu_support = x"yes")

##########################
incardon's avatar
incardon committed
283 284

AC_SUBST(NVCCFLAGS)
incardon's avatar
incardon committed
285
AC_SUBST(INCLUDES_PATH)
incardon's avatar
incardon committed
286
AC_SUBST(DEFAULT_LIB)
incardon's avatar
incardon committed
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
echo ""
echo   "***********************************"
echo   "*                                 *"
if [ test x"$profiler" = x"yes" ]; then
  echo "*    profiler: yes                *"
else
  echo "*    profiler: no                 *"
fi
incardon's avatar
incardon committed
302 303 304 305 306
if [ test x"$memcheck" = x"yes" ]; then
  echo "*    memcheck: yes                *"
else
  echo "*    memcheck: no                 *"
fi
incardon's avatar
incardon committed
307 308 309 310 311 312 313 314 315 316 317 318 319
if [ test x"$debuger" = x"yes" ]; then
  echo "*    debug: yes                   *"
else
  echo "*    debug: no                    *"
fi
if [ test x"$gpu_support" = x"no" ]; then
  echo "*    gpu: no                      *"
else
  echo "*    gpu: yes                     *"
fi
echo   "*                                 *"
echo   "***********************************"