configure.ac
8269c03c
 # get version of CoGAPS from DESCRIPTION file
e9a91972
 AC_INIT(CoGAPS, m4_esyscmd_s([awk -e '/^Version:/ {print $2}' DESCRIPTION]))
1c203467
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
8269c03c
 
 # get C++ compiler from R configuration
 CXX=`"${R_HOME}/bin/R" CMD config CXX`
 
 # Switch to a C++ compiler, and check if it works.
 AC_LANG(C++)
 AC_REQUIRE_CPP
 AC_PROG_CXX
 
 # Check if compiling debug version
 AC_ARG_ENABLE(debug, [AC_HELP_STRING([--enable-debug],
     [build debug version of CoGAPS])], [build_debug=yes], [build_debug=no])
 
552f115a
 # Check if running internal tests
 AC_ARG_ENABLE(internal-tests, [AC_HELP_STRING([--enable-internal-tests],
     [allow for testing private data])], [internal_tests=yes], [internal_tests=no])
 
8269c03c
 # Check if compiler warnings should be turned on
 AC_ARG_ENABLE(warnings, [AC_HELP_STRING([--enable-warnings],
     [compile CoGAPS with warning messages])], [warnings=yes], [warnings=no])
 
 # Check if specific version of SIMD instructions requested
 AC_ARG_ENABLE(simd, [AC_HELP_STRING([--enable-simd],
     [specify simd instruction set (sse, avx)])],
f31a2138
     [simd_version=$enableval], [simd_version=avx])
8269c03c
 
 # default CoGAPS specific flags
16472f10
 GAPS_CPP_FLAGS=" -DBOOST_MATH_PROMOTE_DOUBLE_POLICY=0 -D__GAPS_R_BUILD__ "
8269c03c
 GAPS_CXX_FLAGS=
 GAPS_LIBS=
 
 # get compiler info
 AX_COMPILER_VENDOR
 AX_COMPILER_VERSION
 
b5375b0a
 # set openmp flags, disable only if requested
 AC_ARG_ENABLE(openmp, [AC_HELP_STRING([--enable-openmp],
     [compile with openMP support if available])],
     [use_openmp=$enableval], [use_openmp=yes])
 
096a7e2b
 AX_OPENMP
b5375b0a
 if test "x$use_openmp" != "xno" ; then
     GAPS_CXX_FLAGS+=" $OPENMP_CXXFLAGS "
     GAPS_LIBS+=" $OPENMP_CXXFLAGS "
 fi
8269c03c
 
f31a2138
 # detect SIMD support
 AX_EXT
 
8269c03c
 echo "building on $ax_cv_cxx_compiler_vendor compiler version $ax_cv_cxx_compiler_version"
 
 # set compile flags for debug build
 if test "x$build_debug" = "xyes" ; then
     echo "Building Debug Version of CoGAPS"
60aa5fe9
     GAPS_CPP_FLAGS+=" -DGAPS_DEBUG "
8269c03c
 fi
 
552f115a
 # set compile flags for internal tests
 if test "x$internal_tests" = "xyes" ; then
     echo "Enabling Internal Tests"
     GAPS_CPP_FLAGS+=" -DGAPS_INTERNAL_TESTS "
 fi
 
8269c03c
 # set compile flags if warnings enabled
 if test "x$warnings" = "xyes" ; then
096a7e2b
     if test "x$ax_cv_cxx_compiler_vendor" = "xgnu" || test "x$ax_cv_cxx_compiler_vendor" = "xclang"; then
         GAPS_CXX_FLAGS+=" -Wall -Wextra -Werror -Wno-unused-parameter "
     fi
8269c03c
 fi
 
 # set compile flags for SIMD
096a7e2b
 echo "Supported SIMD flags: " $SIMD_FLAGS
 
 if test "x$simd_version" != "xavx" && test "x$simd_version" != "xsse" && test "x$simd_version" != "xno" && test "x$simd_version" != "xyes" ; then
     echo "Invalid SIMD Type, Defaulting to AVX"
     simd_version=avx
 fi
 
 avx_supported=false
 if test "x$simd_version" = "xavx" || test "x$simd_version" = "xyes" ; then
     for s in $SIMD_FLAGS; do
         if test "x$s" = "x-mavx"; then
             avx_supported=true
             echo "Building with AVX instructions"
             GAPS_CXX_FLAGS+=" -mavx "
         fi
     done
     if test "x$avx_supported" = "xfalse" ; then
         echo "Note: AVX not supported, trying for SSE"
         simd_version=sse
     fi
 fi
 
 sse_supported=false
8269c03c
 if test "x$simd_version" = "xsse" ; then
096a7e2b
     for s in $SIMD_FLAGS; do
         if test "x$s" = "x-msse4.2"; then
             sse_supported=true
             echo "Building with SSE instructions"
             GAPS_CXX_FLAGS+=" -msse4.2 "
         fi
     done
     if test "x$sse_supported" = "xfalse" ; then
         echo "Note: SSE not supported"
         simd_version=no
     fi
 fi
 
 if test "x$simd_version" = "xno" ; then
     echo "Building without SIMD instructions"
8269c03c
 fi
 
 # export variables containing flags
 AC_SUBST(GAPS_CPP_FLAGS)
 AC_SUBST(GAPS_CXX_FLAGS)
 AC_SUBST(GAPS_LIBS)
 
 # create makefile, output configure file
 AC_CONFIG_FILES([src/Makevars])
 AC_OUTPUT