diff --git a/DESCRIPTION b/DESCRIPTION index 77c63f09..7ac90214 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,10 @@ Package: myTAI Type: Package Title: Evolutionary Transcriptomics -Version: 1.0.2.9000 -Date: 2023-07-08 +Version: 2.0.0.0 +Date: 2024-09-30 +Maintainer: Jane Doe +Author: Jane Doe [aut], John Smith [aut] Authors@R: c(person("Hajk-Georg", "Drost", role = c("aut", "cre"), email = "hajk-georg.drost@tuebingen.mpg.de", diff --git a/cleanup b/cleanup new file mode 100755 index 00000000..3c020d38 --- /dev/null +++ b/cleanup @@ -0,0 +1,2 @@ +#!/bin/sh +rm -f src/Makevars diff --git a/configure b/configure new file mode 100755 index 00000000..8d0d7404 --- /dev/null +++ b/configure @@ -0,0 +1,190 @@ +#!/usr/bin/env sh + +# Find R compilers +CC=`${R_HOME}/bin/R CMD config CC` +CFLAGS=`${R_HOME}/bin/R CMD config CFLAGS` +# compiler and flags to 'cc' file +echo "CC=${CC}" > inst/cc +echo "CFLAGS=${CFLAGS}" >> inst/cc + +# gcc compiler info to output #3291 +case $CC in gcc*) + GCCV=`${CC} -dumpfullversion -dumpversion` + echo "$CC $GCCV" +esac + +# Let's keep this simple. If pkg-config is available, use it. Otherwise print +# the helpful message to aid user if compilation does fail. Note 25 of R-exts: +# "[pkg-config] is available on the machines used to produce the CRAN binary packages" +# This script should pass `checkbashisms` for portability; e.g. CRAN's Solaris 10, +# and R-exts note 24 now suggests 'checkbashisms' as we proposed. + +msg=0 +NOZLIB=1 # if pkg-config is not available then zlib will be disabled for higher chance of compilation success +pkg-config --version > config.log 2>&1 +if [ $? -ne 0 ]; then + echo "*** pkg-config is not installed." + msg=1 +else + pkg-config --exists zlib + if [ $? -ne 0 ]; then + echo "*** pkg-config is installed but 'pkg-config --exists zlib' did not return 0." + msg=1 + else + NOZLIB=0 + lib=`pkg-config --libs zlib` + cflag=`pkg-config --cflags zlib` + expr -- "$lib" : ".*-lz$" >> config.log # -- for FreeBSD, #4652 + if [ $? -ne 0 ]; then + expr -- "$lib" : ".*-lz " >> config.log + # would use \b in one expr but MacOS does not support \b + if [ $? -ne 0 ]; then + echo "*** pkg-config is installed and 'pkg-config --exists zlib' succeeds but" + echo "*** 'pkg-config --libs zlib' returns '${lib}' which does not include the standard -lz." + msg=1 + fi + fi + fi +fi + +if [ $msg -ne 0 ]; then + echo "*** Compilation will now be attempted and if it works you can ignore this message. In" + echo "*** particular, this should be the case on Mac where zlib is built in or pkg-config" + echo "*** is not installed. However, if compilation fails, try 'locate zlib.h zconf.h' and" + echo "*** ensure the zlib development library is installed :" + echo "*** deb: zlib1g-dev (Debian, Ubuntu, ...)" + echo "*** rpm: zlib-devel (Fedora, EPEL, ...)" + echo "*** There is a zlib in brew for OSX but the built in zlib should work." + echo "*** Note that zlib is required to compile R itself so you may find the advice in the R-admin" + echo "*** guide helpful regarding zlib. On Debian/Ubuntu, zlib1g-dev is a dependency of r-base as" + echo "*** shown by 'apt-cache showsrc r-base | grep ^Build-Depends | grep zlib', and therefore" + echo "*** 'sudo apt-get build-dep r-base' should be sufficient too." + echo "*** To silence this message, please ensure that :" + echo "*** 1) 'pkg-config --exists zlib' succeeds (i.e. \$? -eq 0)" + echo "*** 2) 'pkg-config --libs zlib' contains -lz" + echo "*** Compilation will now be attempted ..." +else + version=`pkg-config --modversion zlib` + echo "zlib ${version} is available ok" +fi + +# Test if we have a OPENMP compatible compiler +# Aside: ${SHLIB_OPENMP_CFLAGS} does not appear to be defined at this point according to Matt's testing on +# Linux, and R CMD config SHLIB_OPENMP_CFLAGS also returns 'no information for variable'. That's not +# inconsistent with R-exts$1.2.1.1, though, which states it's 'available for use in Makevars' (so not +# necessarily here in configure). Hence use -fopenmp directly for this detection step. +# printf not echo to pass checkbashisms w.r.t. to the \n + +cat < test-omp.c +#include +int main() { + return omp_get_num_threads(); +} +EOF + +detect_openmp () { + export PKG_CXXFLAGS="" + if [ "$(uname)" = "Linux" ]; then + + printf "%s" "* checking if R installation supports OpenMP without any extra hints... " + if "${R_HOME}/bin/R" CMD SHLIB test-omp.c >> config.log 2>&1; then + echo "yes" + export R_OPENMP_ENABLED=1 + return + else + echo "no" + fi + + + printf "%s" "* checking if R installation supports openmp with \"-fopenmp\" flag... " + if ${CC} ${CFLAGS} -fopenmp test-omp.c >> config.log 2>&1; then + echo "yes" + export PKG_CFLAGS="${PKG_CFLAGS} -fopenmp" + export R_OPENMP_ENABLED=1 + return + else + echo "no" + fi + fi # uname=Linux + + if [ "$(uname)" = "Darwin" ]; then + export openmapp="-fopenmp" + + # https://mac.r-project.org/openmp + printf "%s" "* checking if R installation supports OpenMP with \"-Xclang -fopenmp\" ... " + + echo "yes" + export PKG_CFLAGS="${PKG_CFLAGS} -Xclang -fopenmp" + export PKG_LIBS="${PKG_LIBS} -lomp" + export R_OPENMP_ENABLED=1 + export PKG_CXXFLAGS="-Xpreprocessor -fopenmp" + return + + printf "%s" "* checking if R installation supports OpenMP with \"-fopenmp\" ... " + + echo "yes" + export PKG_CFLAGS="${PKG_CFLAGS} -fopenmp" + export R_OPENMP_ENABLED=1 + export PKG_CXXFLAGS="-Xpreprocessor -fopenmp" + return + + if [ "$(uname -m)" = "arm64" ]; then + HOMEBREW_PREFIX=/usr/local + else + HOMEBREW_PREFIX=/usr/local + fi + + if [ -e "${HOMEBREW_PREFIX}/opt/libomp" ]; then + printf "%s" "* checking if libomp installation at ${HOMEBREW_PREFIX}/opt/libomp can be used... +" + LIBOMP_INCLUDE="-I${HOMEBREW_PREFIX}/opt/libomp/include -Xclang -fopenmp" + LIBOMP_LINK="-L${HOMEBREW_PREFIX}/opt/libomp/lib -lomp" + if ${CC} ${CFLAGS} ${LIBOMP_INCLUDE} ${LIBOMP_LINK} test-omp.c >> config.log 2>&1; then + echo "yes" + export PKG_CFLAGS="${PKG_CFLAGS} ${LIBOMP_INCLUDE}" + export PKG_LIBS="${PKG_LIBS} ${LIBOMP_LINK}" + export R_OPENMP_ENABLED=1 + return + else + echo "no" + fi + fi + + fi # uname=Darwin + + # No support for OpenMP available + export R_OPENMP_ENABLED=0 +} + +detect_openmp + +# Clean up. +rm -f test-omp.* a.out + +if [ "${R_OPENMP_ENABLED}" = "0" ]; then + echo "***" + echo "*** OpenMP not supported!" + echo "*** parallelize operations like sorting, grouping, file reading, etc." + echo "*** Continuing installation without OpenMP support..." + echo "***" + sed -e "s|@openmp_cflags@||" src/Makevars.in > src/Makevars +else + sed -e "s|@openmp_cflags@|\$(SHLIB_OPENMP_CFLAGS)|" src/Makevars.in > src/Makevars +fi + +# retain user supplied PKG_ env variables, #4664. See comments in Makevars.in too. +sed -e "s|@PKG_CFLAGS@|$PKG_CFLAGS|" src/Makevars > src/Makevars.tmp && mv src/Makevars.tmp src/Makevars +sed -e "s|@PKG_CXXFLAGS@|$PKG_CXXFLAGS|" src/Makevars > src/Makevars.tmp && mv src/Makevars.tmp src/Makevars +sed -e "s|@PKG_LIBS@|$PKG_LIBS|" src/Makevars > src/Makevars.tmp && mv src/Makevars.tmp src/Makevars + +# optional dependency on zlib +if [ "$NOZLIB" = "1" ]; then + echo "*** Compilation without compression support in fwrite" + sed -e "s|@zlib_cflags@|-DNOZLIB|" src/Makevars > src/Makevars.tmp && mv src/Makevars.tmp src/Makevars + sed -e "s|@zlib_libs@||" src/Makevars > src/Makevars.tmp && mv src/Makevars.tmp src/Makevars +else + sed -e "s|@zlib_cflags@|${cflag}|" src/Makevars > src/Makevars.tmp && mv src/Makevars.tmp src/Makevars + sed -e "s|@zlib_libs@|${lib}|" src/Makevars > src/Makevars.tmp && mv src/Makevars.tmp src/Makevars +fi + +exit 0 diff --git a/src/.Rapp.history b/src/.Rapp.history old mode 100644 new mode 100755 diff --git a/src/Makevars b/src/Makevars deleted file mode 100644 index 407931f3..00000000 --- a/src/Makevars +++ /dev/null @@ -1,13 +0,0 @@ -# Disable long types from C99 or CPP11 extensions -PKG_CPPFLAGS = -I../src -DRCPP_DEFAULT_INCLUDE_CALL=false -DCOMPILING_MYTAI -DBOOST_NO_INT64_T -DBOOST_NO_INTEGRAL_INT64_T -DBOOST_NO_LONG_LONG -DRCPP_USING_UTF8_ERROR_STRING -DRCPP_USE_UNWIND_PROTECT ${MYTAI_COMPILER_FLAGS} - -OPENMP_SUPPORTED := $(shell $(CC) -fopenmp -dM -E - < /dev/null 2>&1 | grep -c "openmp") -LIBOMP_SUPPORTED := $(shell [ -d /usr/local/opt/libomp/include ] && echo 1) -ifeq ($(OPENMP_SUPPORTED),1) - ifeq ($(LIBOMP_SUPPORTED),1) - PKG_CPPFLAGS += -I/usr/local/opt/libomp/include - LDFLAGS=-L/usr/local/opt/libomp/lib - PKG_CXXFLAGS += -Xpreprocessor -fopenmp - PKG_LIBS += -lomp - endif -endif \ No newline at end of file diff --git a/src/Makevars.in b/src/Makevars.in new file mode 100755 index 00000000..b3fd95f4 --- /dev/null +++ b/src/Makevars.in @@ -0,0 +1,10 @@ +PKG_CPPFLAGS = -I/usr/local/opt/libomp/include +PKG_CXXFLAGS = @PKG_CXXFLAGS@ +#PKG_CFLAGS = @PKG_CFLAGS@ @openmp_cflags@ @zlib_cflags@ +PKG_LIBS = @PKG_LIBS@ @openmp_cflags@ @zlib_libs@ +all: $(SHLIB) +# @echo PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) +# @echo PKG_LIBS = $(PKG_LIBS) + if [ "$(SHLIB)" != "myTAI$(SHLIB_EXT)" ]; then mv $(SHLIB) myTAI$(SHLIB_EXT); fi + if [ "$(OS)" != "Windows_NT" ] && [ `uname -s` = 'Darwin' ]; then install_name_tool -id myTAI$(SHLIB_EXT) myTAI$(SHLIB_EXT); fi + diff --git a/src/Makevars.win b/src/Makevars.win new file mode 100755 index 00000000..045cd086 --- /dev/null +++ b/src/Makevars.win @@ -0,0 +1,6 @@ +#PKG_CFLAGS = $(SHLIB_OPENMP_CFLAGS) +#PKG_LIBS = $(SHLIB_OPENMP_CFLAGS) -lz + + +#all: $(SHLIB) +# mv $(SHLIB) myTAI$(SHLIB_EXT) diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp old mode 100644 new mode 100755 diff --git a/src/code.cpp b/src/code.cpp old mode 100644 new mode 100755 diff --git a/src/cpp11.cpp b/src/cpp11.cpp old mode 100644 new mode 100755 diff --git a/src/rcpp_funcs.cpp b/src/rcpp_funcs.cpp old mode 100644 new mode 100755 diff --git a/src/symbols.rds b/src/symbols.rds new file mode 100644 index 00000000..7eeaf82f Binary files /dev/null and b/src/symbols.rds differ