Skip to content

Commit

Permalink
macos debugging (#4)
Browse files Browse the repository at this point in the history
macos fix
  • Loading branch information
lschneiderbauer authored Jun 1, 2024
1 parent a65092f commit 290e737
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 17 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ jobs:
if: runner.os == 'macOS'
run: |
brew install fftw
export LDFLAGS="${LDFLAGS} -L/opt/homebrew/lib"
export CPPFLAGS="${CPPFLAGS} -I/opt/homebrew/include"
brew install libomp
export LDFLAGS="${LDFLAGS} -L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="${CPPFLAGS} -I/opt/homebrew/opt/libomp/include"
- name: Install fftw3 on Windows
if: runner.os == 'Windows'
Expand Down
71 changes: 67 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,14 @@ ac_header_cxx_list=
ac_subst_vars='LTLIBOBJS
LIBOBJS
PKG_LIBS
PKG_LDFLAGS
PKG_CXXFLAGS
PKG_CPPFLAGS
OPENMP_CXXFLAGS
ac_ct_CXX
CXXFLAGS
CXX
BREW
CPP
OBJEXT
EXEEXT
Expand Down Expand Up @@ -2523,6 +2525,8 @@ 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
Expand All @@ -2531,7 +2535,8 @@ if test -z "${R_HOME}"; then
fi
CXX=`"${R_HOME}/bin/R" CMD config CXX`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
CPPFLAGS="`"${R_HOME}/bin/R" CMD config CPPFLAGS`"
LDFLAGS="`"${R_HOME}/bin/R" CMD config LDFLAGS`"
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
Expand Down Expand Up @@ -3666,6 +3671,61 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex
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
{ 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}
then :
printf %s "(cached) " >&6
else $as_nop
if test -n "$BREW"; then
ac_cv_prog_BREW="$BREW" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
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"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

fi
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; }
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"
fi


# Check for fftw3.h header


Expand Down Expand Up @@ -4082,7 +4142,7 @@ printf "%s\n" "#define HAVE_FFTW3_H 1" >>confdefs.h

else $as_nop

as_fn_error $? "fftw3.h header file not found" "$LINENO" 5
as_fn_error $? "fftw3.h header file not found in: $CPPFLAGS" "$LINENO" 5

fi

Expand Down Expand Up @@ -4315,6 +4375,8 @@ PKG_CPPFLAGS="${PKG_CPPFLAGS} ${FFTW_CPPFLAGS} ${FFTW_OMP_CPPFLAGS} ${OPENMP_CPP

PKG_CXXFLAGS="${PKG_CXXFLAGS} ${FFTW_CXXFLAGS} ${FFTW_OMP_CXXFLAGS} ${OPENMP_CXXFLAGS}"

PKG_LDFLAGS="${PKG_LDFLAGS}"

PKG_LIBS="${LIBS} ${PKG_LIBS} ${FFTW_LIBS} ${FFTW_OMP_LIBS}"

ac_config_files="$ac_config_files src/Makevars"
Expand Down Expand Up @@ -5474,8 +5536,9 @@ echo "
--------------------------------------------------
Configuration for ${PACKAGE_NAME} ${PACKAGE_VERSION}
cppflags: ${CPPFLAGS} ${PKG_CPPFLAGS}
cxxflags: ${CXXFLAGS} ${PKG_CXXFLAGS}
cppflags: ${PKG_CPPFLAGS}
cxxflags: ${PKG_CXXFLAGS}
ldflags: ${PKG_LDFLAGS}
libs: ${PKG_LIBS}
--------------------------------------------------
Expand Down
29 changes: 24 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
AC_INIT(fcwtr, 0.2.0)
AC_INIT([fcwtr],[0.2.0])



# Find the compiler and compiler flags used by R.
: ${R_HOME=`R RHOME`}
Expand All @@ -8,15 +10,30 @@ if test -z "${R_HOME}"; then
fi
CXX=`"${R_HOME}/bin/R" CMD config CXX`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
CPPFLAGS="`"${R_HOME}/bin/R" CMD config CPPFLAGS`"
LDFLAGS="`"${R_HOME}/bin/R" CMD config LDFLAGS`"
AC_LANG(C++)
AC_PROG_CPP



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

LDFLAGS="${LDFLAGS} -L`brew --prefix`/lib"
PKG_LDFLAGS="-L`brew --prefix`/lib"
fi


# Check for fftw3.h header
AC_CHECK_HEADER([fftw3.h], [
AC_DEFINE([HAVE_FFTW3_H], [1], [Define if you have the fftw3.h header file])
], [
AC_MSG_ERROR([fftw3.h header file not found])
AC_MSG_ERROR([fftw3.h header file not found in: $CPPFLAGS])
])

have_fftw=no
Expand Down Expand Up @@ -51,6 +68,7 @@ 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}"])
AC_SUBST([PKG_LIBS], ["${LIBS} ${PKG_LIBS} ${FFTW_LIBS} ${FFTW_OMP_LIBS}"])
AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT
Expand All @@ -59,8 +77,9 @@ echo "
--------------------------------------------------
Configuration for ${PACKAGE_NAME} ${PACKAGE_VERSION}

cppflags: ${CPPFLAGS} ${PKG_CPPFLAGS}
cxxflags: ${CXXFLAGS} ${PKG_CXXFLAGS}
cppflags: ${PKG_CPPFLAGS}
cxxflags: ${PKG_CXXFLAGS}
ldflags: ${PKG_LDFLAGS}
libs: ${PKG_LIBS}

--------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CXX_STD = CXX17
PKG_CPPFLAGS = -I. @PKG_CPPFLAGS@
PKG_CXXFLAGS = -I. @PKG_CXXFLAGS@
PKG_LIBS = @PKG_LIBS@
PKG_LIBS = @PKG_LDFLAGS@ @PKG_LIBS@
9 changes: 6 additions & 3 deletions src/fcwt.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ limitations under the License.
#include <iostream>
#include <sstream>

#ifndef _OPENMP
// if we have no platform support, enable single_threading
#define SINGLE_THREAD
#endif
#ifdef _WIN32
#include <windows.h>

Expand All @@ -55,10 +59,9 @@ limitations under the License.
#include <unistd.h>
#endif
#ifndef SINGLE_THREAD
#ifdef _OPENMP
#include <omp.h>
#endif
#include <omp.h>
#endif

#include "fftw3.h"
#include <memory>
//check if avx is supported and include the header
Expand Down

0 comments on commit 290e737

Please sign in to comment.