Skip to content

Commit

Permalink
add win and update Rbuildignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Aug 16, 2024
1 parent 476fd3f commit 7aca7c9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
19 changes: 14 additions & 5 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
^LICENSE\.md$
.ccls-cache
.DS_Store
tmp
.Rhistory
.clangd
^\.Rhistory$
^\.clangd$
^\.clang-format$
^README\.Rmd$
^cran-comments\.md$
^CRAN-SUBMISSION$
\.github
^Makefile
^README.html
.*\.tar\.gz$
.*\.tbi$
^.covrignore$
^codecov.yaml$
^\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
43 changes: 43 additions & 0 deletions configure.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

R_HOME=$(R RHOME)

# Function to detect BLAS library
detect_blas() {
blas_info=$(${R_HOME}/bin/R --slave -e "si <- sessionInfo(); cat(si\$BLAS, '\n', si\$LAPACK)")
if echo "$blas_info" | grep -iq "mkl"; then
echo "mkl"
elif echo "$blas_info" | grep -iq "openblas"; then
echo "openblas"
else
echo "default"
fi
}

# Detect BLAS
BLAS_TYPE=$(detect_blas)

# OPENBLAS seems sub-optimal
case $BLAS_TYPE in
mkl)
echo "Using MKL"
BLAS_LAPACK_LIBS="-lmkl_rt"
USE_MKL=true
USE_OPENBLAS=false
USE_LAPACKE=true
;;
*)
echo "Using default BLAS and LAPACK"
BLAS_LAPACK_LIBS="-lblas -llapack"
USE_MKL=false
USE_OPENBLAS=false
USE_LAPACKE=false
;;
esac

# Create Makevars
sed -e "s|@BLAS_LAPACK_LIBS@|$BLAS_LAPACK_LIBS|" \
-e "s|@USE_MKL@|$USE_MKL|" \
-e "s|@USE_OPENBLAS@|$USE_OPENBLAS|" \
-e "s|@USE_LAPACKE@|$USE_LAPACKE|" \
src/Makevars.in > src/Makevars.win
4 changes: 2 additions & 2 deletions src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CXX_STD = CXX17
PKG_CPPFLAGS = -I../inst/include
PKG_CXXFLAGS = -DNDEBUG -DEIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS

ifeq (@USE_MKL@,true)
PKG_CXXFLAGS = -DNDEBUG -DEIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS -DEIGEN_USE_MKL_ALL
PKG_CXXFLAGS += -DEIGEN_USE_MKL_ALL
PKG_LIBS = @BLAS_LAPACK_LIBS@
else
PKG_CXXFLAGS = -DNDEBUG -DEIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
endif

0 comments on commit 7aca7c9

Please sign in to comment.