Skip to content

Autodetect rcpp rinside #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/build/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
install.txt
exm-settings.sh
swift-t-settings.sh
11 changes: 9 additions & 2 deletions dev/build/swift-t-settings.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,18 @@ MPI_VERSION=3

# Enable Python integration
# ENABLE_PYTHON=1
# PYTHON_INSTALL=/usr/
# PYTHON_INSTALL=/path/to/python
# PYTHON_VERSION_MAJOR=2
# PYTHON_VERSION_MINOR=7
# PYTHON_VERSION_SUFFIX=m

# Enable R integration
# ENABLE_R=1
# R_INSTALL=/usr/
# R_INSTALL=/path/to/R
# Define these if Rcpp and RInside are not
# autodetected
# RCPP_INSTALL=/path/to/Rcpp
# RINSIDE_INSTALL=/path/to/RInside

# Enable Julia integration
# ENABLE_JULIA=1
Expand Down
20 changes: 20 additions & 0 deletions dev/build/turbine-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,33 @@ if [ ! -z "$PYTHON_INSTALL" ]; then
EXTRA_ARGS+=" --with-python=${PYTHON_INSTALL}"
fi

if [ ! -z "$PYTHON_VERSION_MAJOR" ]; then
EXTRA_ARGS+=" --with-python-version-major=${PYTHON_VERSION_MAJOR}"
fi

if [ ! -z "$PYTHON_VERSION_MINOR" ]; then
EXTRA_ARGS+=" --with-python-version-minor=${PYTHON_VERSION_MINOR}"
fi

if [ ! -z "$PYTHON_VERSION_SUFFIX" ]; then
EXTRA_ARGS+=" --with-python-version-suffix=${PYTHON_VERSION_SUFFIX}"
fi

if (( ENABLE_R )); then
EXTRA_ARGS+=" --enable-r"
fi
if [ ! -z "$R_INSTALL" ]; then
EXTRA_ARGS+=" --with-r=${R_INSTALL}"
fi

if [ ! -z "$RINSIDE_INSTALL" ]; then
EXTRA_ARGS+=" --with-rinside=${RINSIDE_INSTALL}"
fi

if [ ! -z "$RCPP_INSTALL" ]; then
EXTRA_ARGS+=" --with-rcpp=${RCPP_INSTALL}"
fi

if (( ENABLE_JULIA )); then
if [ ! -z "$JULIA_INSTALL" ]; then
EXTRA_ARGS+=" --with-julia=${JULIA_INSTALL}"
Expand Down
47 changes: 39 additions & 8 deletions turbine/code/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ USE_PYTHON_NAME = @USE_PYTHON_NAME@

HAVE_R = @HAVE_R@
USE_R = @USE_R@
RCPP_PATH = @RCPP_PATH@
RINSIDE_PATH = @RINSIDE_PATH@

HAVE_JULIA = @HAVE_JULIA@
USE_JULIA = @USE_JULIA@
Expand Down Expand Up @@ -277,10 +279,18 @@ ifeq ($(HAVE_PYTHON),1)
endif
ifeq ($(HAVE_R),1)
ifneq ($(USE_R),)
INCLUDES += -I $(USE_R)/include
R_LIBRARY = $(USE_R)/library
INCLUDES += -I $(R_LIBRARY)/RInside/include
INCLUDES += -I $(R_LIBRARY)/Rcpp/include
INCLUDES += -I $(USE_R)/include
R_LIBRARY = $(USE_R)/library
ifneq ($(RINSIDE_PATH),)
INCLUDES += -I $(RINSIDE_PATH)/include
else
INCLUDES += -I $(R_LIBRARY)/RInside/include
endif
ifneq ($(RCPP_PATH),)
INCLUDES += -I $(RCPP_PATH)/include
else
INCLUDES += -I $(R_LIBRARY)/Rcpp/include
endif
endif
endif
ifeq ($(HAVE_JULIA),1)
Expand Down Expand Up @@ -336,14 +346,33 @@ endif
ifeq ($(HAVE_R),1)
ifneq ($(USE_R),)
R_LIB = $(USE_R)/lib
ifeq ($(filter $(R_LIB),$(SYSTEM_LIBS)),)
LIBS += -L$(R_LIB)
RPATH_R = yes
LIBS += -L$(R_LIB)
RPATH_R = yes
ifneq ($(RINSIDE_PATH),)
RINSIDE_LIB = $(RINSIDE_PATH)/lib
else
RINSIDE_LIB = $(USE_R)/library/RInside/lib
endif
RINSIDE_LIB = $(USE_R)/library/RInside/lib
LIBS += -L$(RINSIDE_LIB)
endif
LIBS += -lRInside -lR

ifeq ($(USE_MAC),yes)
# if mac, the RInside library and python install name can be incorrect
# when installed locally. This will fix that in tclturbine
RINSIDE_INSTALL_NAME=$(shell otool -D $(RINSIDE_PATH)/lib/libRInside.dylib | sed -n 2p)
FIX_RINSIDE_INSTALL_NAME = install_name_tool -change $(RINSIDE_INSTALL_NAME) $(RINSIDE_LIB)/libRInside.dylib $(TCL_TURBINE_SO)

ifneq ($(USE_PYTHON_LIBDIR),)
PYTHON_LIB_NAME = $(USE_PYTHON_LIBDIR)/lib$(USE_PYTHON_NAME).dylib
PYTHON_INSTALL_NAME = $(shell otool -D $(PYTHON_LIB_NAME) | sed -n 2p)
FIX_PYTHON_INSTALL_NAME = install_name_tool -change $(PYTHON_INSTALL_NAME) $(PYTHON_LIB_NAME) $(TCL_TURBINE_SO)
endif
else
FIX_RINSIDE_INSTALL_NAME =
FIX_PYTHON_INSTALL_NAME =
endif

endif
ifeq ($(HAVE_JVM_SCRIPT),1)
SWIFTTJVM_LIB = $(USE_JVM_SCRIPT_HOME)/src
Expand Down Expand Up @@ -562,6 +591,8 @@ endif
$(LIBS) \
$(RPATHS) \
$(MAC_NAME)
$(FIX_RINSIDE_INSTALL_NAME)
$(FIX_PYTHON_INSTALL_NAME)

$(STATIC_PKG_A): $(STATIC_PKG_OBJS) $(STATIC_PKG_RESOURCE_O)
$(Q) " AR $(@)"
Expand Down
94 changes: 72 additions & 22 deletions turbine/code/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ AC_MSG_CHECKING([checking for ${USE_C_UTILS}/lib/libexmcutils.${AR_SUFFIX}])
if [[ -f "${USE_C_UTILS}/lib/libexmcutils.${AR_SUFFIX}" ]]; then
USE_LIBCUTILS_A="${USE_C_UTILS}/lib/libexmcutils.${AR_SUFFIX}"
AC_MSG_RESULT([yes])
else
else
AC_MSG_RESULT([no])
fi
AC_SUBST(USE_LIBCUTILS_A)
Expand Down Expand Up @@ -688,37 +688,94 @@ fi
# R is optional
HAVE_R=0
USE_R=0
AC_ARG_ENABLE(r,
RCPP_PATH=0
RINSIDE_PATH=0
AC_ARG_ENABLE(r, # Drop this? Almost guaranteed to fail.
AS_HELP_STRING([--enable-r],
[Enable calling R language]),
[
HAVE_R=1
USE_R=""
USE_R="/usr" # Acceptable default?
])

AC_ARG_WITH(rinside,
AS_HELP_STRING([--with-rinside],
[Use this RInside directory]),
[
HAVE_R=1
RINSIDE_PATH=${withval}
])

AC_ARG_WITH(rcpp,
AS_HELP_STRING([--with-rcpp],
[Use this Rcpp directory]),
[
HAVE_R=1
RCPP_PATH=${withval}
])

AC_ARG_WITH(r,
AS_HELP_STRING([--with-r],
[Use this R directory]),
[
HAVE_R=1
USE_R=${withval}
AC_CHECK_FILE(${USE_R}/include/R.h, [],
[AC_MSG_ERROR([Could not find R header!])])
# C++ is only required if we enable R
AC_PROG_CXX
LD=${CXX}
])

if [[ ${HAVE_R} == 1 ]]
then
AC_CHECK_FILE(${USE_R}/include/R.h, [],
[AC_MSG_ERROR([Could not find R header!])])
if [[ ${RINSIDE_PATH} == 0 ]]
then
AC_CHECK_PROG(RSCRIPT, Rscript, Rscript)
if [[ ! -z ${RSCRIPT} ]]
then
R_LIB_PATHS=" ${USE_R} "
# returned in order of precedence so we want to
# reverse so that the last overrides the first
R_LIB_PATHS+="$(Rscript -e 'cat(rev(.libPaths()))')"
for p in $R_LIB_PATHS
do
AC_CHECK_FILE(${p}/RInside, [RINSIDE_PATH=${p}/RInside], [])
done
else
RINSIDE_PATH=${USE_R}/RInside
fi
fi

if [[ ${RCPP_PATH} == 0 ]]
then
AC_CHECK_PROG(RSCRIPT, Rscript, Rscript)
if [[ ! -z ${RSCRIPT} ]]
then
R_LIB_PATHS="${USE_R} "
# returned in order of precedence so we want to
# reverse so that the last overrides the first
R_LIB_PATHS+="$(Rscript -e 'cat(rev(.libPaths()))')"
for p in $R_LIB_PATHS
do
AC_CHECK_FILE(${p}/Rcpp, [RCPP_PATH=${p}/Rcpp], [])
done
else
RCPP_PATH=${USE_R}/Rcpp
fi
fi

AC_CHECK_FILE(${RINSIDE_PATH}/include/RInside.h, [],
[AC_MSG_ERROR([Could not find RInside header!])])
AC_CHECK_FILE(${RCPP_PATH}/include/Rcpp.h, [],
[AC_MSG_ERROR([Could not find Rcpp header!])])

# C++ is only required if we enable R
AC_PROG_CXX
LD=${CXX}
fi # if HAVE_R
AC_DEFINE_UNQUOTED([HAVE_R],$HAVE_R,[Enables R])
AC_SUBST(HAVE_R)
AC_SUBST(USE_R)

if (( HAVE_R ))
then
AC_MSG_RESULT([R enabled])
else
AC_MSG_RESULT([R disabled])
fi
AC_SUBST(RINSIDE_PATH)
AC_SUBST(RCPP_PATH)

# JVM scripting support: Disabled by default
HAVE_JVM_SCRIPT=0
Expand Down Expand Up @@ -783,13 +840,6 @@ AC_DEFINE_UNQUOTED(HAVE_JULIA,${HAVE_JULIA},[Enables Julia])
AC_SUBST(HAVE_JULIA)
AC_SUBST(USE_JULIA)

if (( HAVE_JULIA ))
then
AC_MSG_RESULT([Julia enabled])
else
AC_MSG_RESULT([Julia disabled])
fi

HAVE_COASTER=0
USE_COASTER=0
AC_ARG_WITH(coaster,
Expand Down