diff --git a/DESCRIPTION b/DESCRIPTION index 430cecb..6eb8865 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: fCWTr Type: Package Title: Fast Continuous Wavelet Transform -Version: 0.2.9000 +Version: 0.3.0 Authors@R: c( person("Lukas", "Schneiderbauer", email = "lukas.schneiderbauer@gmail.com", @@ -33,7 +33,7 @@ Suggests: LinkingTo: cpp11 SystemRequirements: - fftw3 (including single precision support fftw3f), fftw3f_omp (optional), OpenMP (optional) + fftw3 (including single precision support fftw3f; 'fftw-s' macOS recipe), fftw3f_omp (optional), OpenMP (optional) Config/testthat/edition: 3 URL: https://lschneiderbauer.github.io/fCWTr/, https://github.com/lschneiderbauer/fCWTr Roxygen: list(markdown = TRUE) diff --git a/NEWS.md b/NEWS.md index 49aad3a..0254748 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# fCWTr 0.2.9000 +# fCWTr 0.3.0 - `fcwt():` diff --git a/configure b/configure index 2264d83..9985f2d 100755 --- a/configure +++ b/configure @@ -647,7 +647,7 @@ OPENMP_CXXFLAGS ac_ct_CXX CXXFLAGS CXX -BREW +PKG_CONFIG CPP OBJEXT EXEEXT @@ -1544,41 +1544,6 @@ fi } # ac_fn_cxx_try_compile -# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES -# --------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_cxx_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - eval "$3=yes" -else case e in #( - e) eval "$3=no" ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi -eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_cxx_check_header_compile - # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. @@ -1626,6 +1591,41 @@ fi as_fn_set_status $ac_retval } # ac_fn_cxx_try_link + +# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES +# --------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_cxx_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +printf %s "checking for $2... " >&6; } +if eval test \${$3+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_cxx_try_compile "$LINENO" +then : + eval "$3=yes" +else case e in #( + e) eval "$3=no" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi +eval ac_res=\$$3 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_cxx_check_header_compile ac_configure_args_raw= for ac_arg do @@ -2542,7 +2542,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu - # Find the compiler and compiler flags used by R. : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then @@ -3722,22 +3721,20 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - -# extra check for macos brew -# Extract the first word of "brew", so it can be a program name with args. -set dummy brew; ac_word=$2 +# Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_BREW+y} +if test ${ac_cv_path_PKG_CONFIG+y} then : printf %s "(cached) " >&6 else case e in #( - e) if test -n "$BREW"; then - ac_cv_prog_BREW="$BREW" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + e) case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS @@ -3748,7 +3745,7 @@ do esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_BREW="yes" + ac_cv_path_PKG_CONFIG="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi @@ -3756,32 +3753,25 @@ done done IFS=$as_save_IFS -fi ;; + ;; +esac ;; esac fi -BREW=$ac_cv_prog_BREW -if test -n "$BREW"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BREW" >&5 -printf "%s\n" "$BREW" >&6; } +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +printf "%s\n" "$PKG_CONFIG" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi -if test "x${BREW}" = xyes; then - # in order for AC_CHECK_HEADER to work - CPPFLAGS="${CPPFLAGS} -I`brew --prefix`/include" - PKG_CPPFLAGS="-I`brew --prefix`/include" - - LDFLAGS="${LDFLAGS} -L`brew --prefix`/lib" - PKG_LDFLAGS="-L`brew --prefix`/lib" +if test -e penmp || test -e mp; then + as_fn_error $? "AC_OPENMP clobbers files named 'mp' and 'penmp'. Aborting configure because one of these files already exists." "$LINENO" 5 fi -# Check for fftw3.h header - - @@ -4169,6 +4159,117 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +# Check whether --enable-openmp was given. +if test ${enable_openmp+y} +then : + enableval=$enable_openmp; +fi + + OPENMP_CXXFLAGS= + if test "$enable_openmp" != no; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to support OpenMP" >&5 +printf %s "checking for $CXX option to support OpenMP... " >&6; } +if test ${ac_cv_prog_cxx_openmp+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_cv_prog_cxx_openmp='not found' + for ac_option in '' -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \ + -Popenmp --openmp; do + + ac_save_CXXFLAGS=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $ac_option" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef _OPENMP +#error "OpenMP not supported" +#endif +#include +int main (void) { return omp_get_num_threads (); } + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO" +then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef _OPENMP +#error "OpenMP not supported" +#endif +#include +int main (void) { return omp_get_num_threads (); } + +_ACEOF +if ac_fn_cxx_try_link "$LINENO" +then : + ac_cv_prog_cxx_openmp=$ac_option +else case e in #( + e) ac_cv_prog_cxx_openmp='unsupported' ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CXXFLAGS=$ac_save_CXXFLAGS + + if test "$ac_cv_prog_cxx_openmp" != 'not found'; then + break + fi + done + if test "$ac_cv_prog_cxx_openmp" = 'not found'; then + ac_cv_prog_cxx_openmp='unsupported' + elif test "$ac_cv_prog_cxx_openmp" = ''; then + ac_cv_prog_cxx_openmp='none needed' + fi + rm -f penmp mp ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_openmp" >&5 +printf "%s\n" "$ac_cv_prog_cxx_openmp" >&6; } + if test "$ac_cv_prog_cxx_openmp" != 'unsupported' && \ + test "$ac_cv_prog_cxx_openmp" != 'none needed'; then + OPENMP_CXXFLAGS="$ac_cv_prog_cxx_openmp" + fi + fi + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pkg-config" >&5 +printf %s "checking for pkg-config... " >&6; } + +if "$PKG_CONFIG" --version +then : + +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + as_fn_error $? "Provided flags don't work and pkg-config is not present." "$LINENO" 5 ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pkg-config knows about fftw3f" >&5 +printf %s "checking whether pkg-config knows about fftw3f... " >&6; } + +if $PKG_CONFIG fftw3f +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + as_fn_error $? "Install libfftw3-dev or equivalent first" "$LINENO" 5 ;; +esac +fi + +CPPFLAGS="${CPPFLAGS} `$PKG_CONFIG --cflags fftw3f`" +LIBS="${LIBS} `$PKG_CONFIG --libs fftw3f`" + +# needs to be after pkg-config checks +# to have correct paths already + +# Check for fftw3.h header ac_header= ac_cache= for ac_item in $ac_header_cxx_list do @@ -4214,92 +4315,9 @@ esac fi -have_fftw=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing fftwf_free" >&5 -printf %s "checking for library containing fftwf_free... " >&6; } -if test ${ac_cv_search_fftwf_free+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -namespace conftest { - extern "C" int fftwf_free (); -} -int -main (void) -{ -return conftest::fftwf_free (); - ; - return 0; -} -_ACEOF -for ac_lib in '' fftw3f -do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_cxx_try_link "$LINENO" -then : - ac_cv_search_fftwf_free=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext - if test ${ac_cv_search_fftwf_free+y} -then : - break -fi -done -if test ${ac_cv_search_fftwf_free+y} -then : - -else case e in #( - e) ac_cv_search_fftwf_free=no ;; -esac -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_fftwf_free" >&5 -printf "%s\n" "$ac_cv_search_fftwf_free" >&6; } -ac_res=$ac_cv_search_fftwf_free -if test "$ac_res" != no -then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - have_fftw=yes -else case e in #( - e) as_fn_error $? "The fftw3 library with single precision support is required. In case fftw is already installed, you might need to enable fftw's single precision support with './configure --enable-type-prefix --enable-float'." "$LINENO" 5 - ;; -esac -fi - - -# Check for omp.h header -ac_fn_cxx_check_header_compile "$LINENO" "omp.h" "ac_cv_header_omp_h" "$ac_includes_default" -if test "x$ac_cv_header_omp_h" = xyes -then : - - -printf "%s\n" "#define HAVE_OMP_H 1" >>confdefs.h - - -else case e in #( - e) - -printf "%s\n" "#define HAVE_OMP_H 0" >>confdefs.h - - ;; -esac -fi - - -have_fftw_omp=no +# there are no pkg-config files for fftw3-omp, +# so check like this. +# have_fftw_omp=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing fftwf_plan_with_nthreads" >&5 printf %s "checking for library containing fftwf_plan_with_nthreads... " >&6; } if test ${ac_cv_search_fftwf_plan_with_nthreads+y} @@ -4366,94 +4384,15 @@ esac fi -if test -e penmp || test -e mp; then - as_fn_error $? "AC_OPENMP clobbers files named 'mp' and 'penmp'. Aborting configure because one of these files already exists." "$LINENO" 5 -fi -# Check whether --enable-openmp was given. -if test ${enable_openmp+y} -then : - enableval=$enable_openmp; -fi - - OPENMP_CXXFLAGS= - if test "$enable_openmp" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to support OpenMP" >&5 -printf %s "checking for $CXX option to support OpenMP... " >&6; } -if test ${ac_cv_prog_cxx_openmp+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_cv_prog_cxx_openmp='not found' - for ac_option in '' -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \ - -Popenmp --openmp; do - - ac_save_CXXFLAGS=$CXXFLAGS - CXXFLAGS="$CXXFLAGS $ac_option" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifndef _OPENMP -#error "OpenMP not supported" -#endif -#include -int main (void) { return omp_get_num_threads (); } - -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifndef _OPENMP -#error "OpenMP not supported" -#endif -#include -int main (void) { return omp_get_num_threads (); } - -_ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : - ac_cv_prog_cxx_openmp=$ac_option -else case e in #( - e) ac_cv_prog_cxx_openmp='unsupported' ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CXXFLAGS=$ac_save_CXXFLAGS - - if test "$ac_cv_prog_cxx_openmp" != 'not found'; then - break - fi - done - if test "$ac_cv_prog_cxx_openmp" = 'not found'; then - ac_cv_prog_cxx_openmp='unsupported' - elif test "$ac_cv_prog_cxx_openmp" = ''; then - ac_cv_prog_cxx_openmp='none needed' - fi - rm -f penmp mp ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_openmp" >&5 -printf "%s\n" "$ac_cv_prog_cxx_openmp" >&6; } - if test "$ac_cv_prog_cxx_openmp" != 'unsupported' && \ - test "$ac_cv_prog_cxx_openmp" != 'none needed'; then - OPENMP_CXXFLAGS="$ac_cv_prog_cxx_openmp" - fi - fi - - # Write the flags into the src/Makevars file. -PKG_CPPFLAGS="${PKG_CPPFLAGS} ${FFTW_CPPFLAGS} ${FFTW_OMP_CPPFLAGS} ${OPENMP_CPPFLAGS}" +PKG_CPPFLAGS="${CPPFLAGS} ${OPENMP_CFLAGS}" -PKG_CXXFLAGS="${PKG_CXXFLAGS} ${FFTW_CXXFLAGS} ${FFTW_OMP_CXXFLAGS} ${OPENMP_CXXFLAGS}" +PKG_CXXFLAGS="${CXXFLAGS} ${OPENMP_CXXFLAGS}" -PKG_LDFLAGS="${PKG_LDFLAGS} ${OPENMP_CXXFLAGS}" +PKG_LDFLAGS="${LDFLAGS} ${OPENMP_CXXFLAGS}" -PKG_LIBS="${LIBS} ${PKG_LIBS} ${FFTW_LIBS} ${FFTW_OMP_LIBS}" +PKG_LIBS="${LIBS}" ac_config_files="$ac_config_files src/Makevars" diff --git a/configure.ac b/configure.ac index 6384961..517dfe4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,6 @@ AC_INIT([fCWTr],[0.2.9000]) - # Find the compiler and compiler flags used by R. : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then @@ -14,20 +13,24 @@ CPPFLAGS="`"${R_HOME}/bin/R" CMD config CPPFLAGS`" LDFLAGS="`"${R_HOME}/bin/R" CMD config LDFLAGS`" AC_LANG(C++) AC_PROG_CPP +AC_PATH_PROG([PKG_CONFIG], [pkg-config]) +AC_OPENMP +AC_MSG_CHECKING([for pkg-config]) +AS_IF(["$PKG_CONFIG" --version], , [AC_MSG_RESULT([no]) + AC_MSG_ERROR([Provided flags don't work and pkg-config is not present.])]) -# extra check for macos brew -AC_CHECK_PROG(BREW,brew,yes) -if test "x${BREW}" = xyes; then - # in order for AC_CHECK_HEADER to work - CPPFLAGS="${CPPFLAGS} -I`brew --prefix`/include" - PKG_CPPFLAGS="-I`brew --prefix`/include" +AC_MSG_CHECKING([whether pkg-config knows about fftw3f]) - LDFLAGS="${LDFLAGS} -L`brew --prefix`/lib" - PKG_LDFLAGS="-L`brew --prefix`/lib" -fi +AS_IF([$PKG_CONFIG fftw3f], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT([no]) + AC_MSG_ERROR([Install libfftw3-dev or equivalent first])]) +CPPFLAGS="${CPPFLAGS} `$PKG_CONFIG --cflags fftw3f`" +LIBS="${LIBS} `$PKG_CONFIG --libs fftw3f`" + +# needs to be after pkg-config checks +# to have correct paths already # Check for fftw3.h header AC_CHECK_HEADER([fftw3.h], [ @@ -36,36 +39,22 @@ AC_CHECK_HEADER([fftw3.h], [ AC_MSG_ERROR([fftw3.h header file not found in: $CPPFLAGS]) ]) -have_fftw=no +# there are no pkg-config files for fftw3-omp, +# so check like this. +# have_fftw_omp=no AC_SEARCH_LIBS( - fftwf_free, - fftw3f, - [have_fftw=yes], - [AC_MSG_ERROR([The fftw3 library with single precision support is required. In case fftw is already installed, you might need to enable fftw's single precision support with './configure --enable-type-prefix --enable-float'.])] + fftwf_plan_with_nthreads, + fftw3f_omp, + [have_fftw_omp=yes], + [AC_MSG_RESULT([The fftw3-omp support not found.])] ) -# Check for omp.h header -AC_CHECK_HEADER([omp.h], [ - AC_DEFINE([HAVE_OMP_H], [1], [Define if you have the omp.h header file]) -], [ - AC_DEFINE([HAVE_OMP_H], [0], [Define if you have the omp.h header file]) -]) - -have_fftw_omp=no -AC_SEARCH_LIBS( - fftwf_plan_with_nthreads, - fftw3f_omp, - [have_fftw_omp=yes], - [AC_MSG_RESULT([The fftw3-omp support not found.])] -) - -AC_OPENMP # Write the flags into the src/Makevars file. -AC_SUBST([PKG_CPPFLAGS], ["${PKG_CPPFLAGS} ${FFTW_CPPFLAGS} ${FFTW_OMP_CPPFLAGS} ${OPENMP_CPPFLAGS}"]) -AC_SUBST([PKG_CXXFLAGS], ["${PKG_CXXFLAGS} ${FFTW_CXXFLAGS} ${FFTW_OMP_CXXFLAGS} ${OPENMP_CXXFLAGS}"]) -AC_SUBST([PKG_LDFLAGS], ["${PKG_LDFLAGS} ${OPENMP_CXXFLAGS}"]) -AC_SUBST([PKG_LIBS], ["${LIBS} ${PKG_LIBS} ${FFTW_LIBS} ${FFTW_OMP_LIBS}"]) +AC_SUBST([PKG_CPPFLAGS], ["${CPPFLAGS} ${OPENMP_CFLAGS}"]) +AC_SUBST([PKG_CXXFLAGS], ["${CXXFLAGS} ${OPENMP_CXXFLAGS}"]) +AC_SUBST([PKG_LDFLAGS], ["${LDFLAGS} ${OPENMP_CXXFLAGS}"]) +AC_SUBST([PKG_LIBS], ["${LIBS}"]) AC_CONFIG_FILES([src/Makevars]) AC_OUTPUT