Skip to content

Commit

Permalink
Trialing building without an R library to link against
Browse files Browse the repository at this point in the history
  • Loading branch information
grimbough committed Oct 18, 2023
1 parent 3d4192f commit bf2f1ce
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 19 deletions.
26 changes: 16 additions & 10 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,14 @@ SSE2_BITSHUFFLE
MSSE2
SSE2
ZSTD_LIB
ZSTD_INCLUDE
BUILD_ZSTD
OBJEXT
EXEEXT
ac_ct_CC
LDFLAGS
AR
NO_RLIB
R_CPPFLAGS
AR
RANLIB
MAKE
CPPFLAGS
Expand Down Expand Up @@ -2419,8 +2419,6 @@ MAKE=`"${R_HOME}/bin/R" CMD config MAKE`
RANLIB=`"${R_HOME}/bin/R" CMD config RANLIB`
R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config --cppflags`
AR=`"${R_HOME}/bin/R" CMD config AR`
if test "x$AR" = "xERROR: no information for variable 'AR'"
Expand Down Expand Up @@ -2473,6 +2471,18 @@ fi
fi
R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config --cppflags`
if [ -z "$R_CPPFLAGS" ]; then
R_CPPFLAGS=""
NO_RLIB="-DNO_RLIB"
else
NO_RLIB=""
fi
ac_config_files="$ac_config_files src/Makevars"
Expand Down Expand Up @@ -3607,25 +3617,20 @@ if test -z "$HAVE_ZSTD"; then
printf "%s\n" "$as_me: compiling bundled Zstd library" >&6;}
BUILD_ZSTD=libzstd.a
ZSTD_INCLUDE="-I. -Icommon"
ZSTD_LIB=compression_tools/zstd/libzstd.a
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Using system Zstd library" >&5
printf "%s\n" "$as_me: Using system Zstd library" >&6;}
BUILD_ZSTD=""
ZSTD_INCLUDE=""
ZSTD_LIB=-lzstd
fi
##############################
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: configuring the BLOSC filter..." >&5
Expand Down Expand Up @@ -4098,7 +4103,7 @@ printf "%s\n" "$as_me: Using system BLOSC library" >&6;}
fi
ac_config_files="$ac_config_files src/compression_tools/blosc/lib/blosc-1.20.1/Makefile src/compression_tools/blosc/Makefile"
ac_config_files="$ac_config_files src/compression_tools/blosc/lib/blosc-1.20.1/Makefile src/compression_tools/blosc/Makefile src/compression_tools/blosc/lib/snappy-1.1.1/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Expand Down Expand Up @@ -4803,6 +4808,7 @@ do
"src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;;
"src/compression_tools/blosc/lib/blosc-1.20.1/Makefile") CONFIG_FILES="$CONFIG_FILES src/compression_tools/blosc/lib/blosc-1.20.1/Makefile" ;;
"src/compression_tools/blosc/Makefile") CONFIG_FILES="$CONFIG_FILES src/compression_tools/blosc/Makefile" ;;
"src/compression_tools/blosc/lib/snappy-1.1.1/Makefile") CONFIG_FILES="$CONFIG_FILES src/compression_tools/blosc/lib/snappy-1.1.1/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
Expand Down
18 changes: 13 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ AC_SUBST(CXXPICFLAGS, `"${R_HOME}/bin/R" CMD config CXXPICFLAGS`)
AC_SUBST(CPPFLAGS, `"${R_HOME}/bin/R" CMD config CPPFLAGS`)
AC_SUBST(MAKE, `"${R_HOME}/bin/R" CMD config MAKE`)
AC_SUBST(RANLIB, `"${R_HOME}/bin/R" CMD config RANLIB`)
AC_SUBST(R_CPPFLAGS, `"${R_HOME}/bin/R" CMD config --cppflags`)

dnl seems unreliable as to whether this information is available
AR=`"${R_HOME}/bin/R" CMD config AR`
AS_IF([test "x$AR" = "xERROR: no information for variable 'AR'"], [AC_PATH_PROG([AR], [ar])], [])
AC_SUBST(AR)

R_CPPFLAGS=`"${R_HOME}/bin/R" CMD config --cppflags`

if [[ -z "$R_CPPFLAGS" ]]; then
R_CPPFLAGS=""
NO_RLIB="-DNO_RLIB"
else
NO_RLIB=""
fi

AC_SUBST(R_CPPFLAGS)
AC_SUBST(NO_RLIB)

AC_CONFIG_FILES([src/Makevars])

##############################
Expand Down Expand Up @@ -67,17 +78,14 @@ fi
if test -z "$HAVE_ZSTD"; then
AC_MSG_NOTICE(compiling bundled Zstd library)
AC_SUBST(BUILD_ZSTD, libzstd.a)
AC_SUBST(ZSTD_INCLUDE, "-I. -Icommon")
AC_SUBST(ZSTD_LIB, compression_tools/zstd/libzstd.a)
else
AC_MSG_NOTICE(Using system Zstd library)
AC_SUBST(BUILD_ZSTD, "")
AC_SUBST(ZSTD_INCLUDE, "")
AC_SUBST(ZSTD_LIB, -lzstd)
fi

AC_SUBST(BUILD_ZSTD)
AC_SUBST(ZSTD_INCLUDE)
AC_SUBST(ZSTD_LIB)

##############################
Expand Down Expand Up @@ -201,5 +209,5 @@ else
AC_SUBST(BLOSC_LIB, -lblosc)
fi

AC_CONFIG_FILES([src/compression_tools/blosc/lib/blosc-1.20.1/Makefile src/compression_tools/blosc/Makefile])
AC_CONFIG_FILES([src/compression_tools/blosc/lib/blosc-1.20.1/Makefile src/compression_tools/blosc/Makefile src/compression_tools/blosc/lib/snappy-1.1.1/Makefile])
AC_OUTPUT
2 changes: 1 addition & 1 deletion src/compression_tools/blosc/lib/blosc-1.20.1/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EXTRA_FLAGS+=-I../lz4-1.9.2 -I../snappy-1.1.1 -I../../../zstd @MSSE2@ @MAVX2@ -DUSING_R
EXTRA_FLAGS+=-I../lz4-1.9.2 -I../snappy-1.1.1 -I../../../zstd @MSSE2@ @MAVX2@ -DUSING_R @NO_RLIB@
FLAGS=$(PKG_CFLAGS) $(PKG_CPICFLAGS) $(PKG_CPPFLAGS) $(PKG_R_CPPFLAGS) $(EXTRA_FLAGS)

BLOSC_FILES := $(sort $(wildcard *.c))
Expand Down
2 changes: 1 addition & 1 deletion src/compression_tools/blosc/lib/snappy-1.1.1/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#SHELL=/bin/sh

FLAGS = $(PKG_CXXFLAGS) $(PKG_CXXPICFLAGS) $(PKG_CPPFLAGS) $(PKG_R_CPPFLAGS) -DUSING_R
FLAGS = $(PKG_CXXFLAGS) $(PKG_CXXPICFLAGS) $(PKG_CPPFLAGS) $(PKG_R_CPPFLAGS) -DUSING_R

SNAPPY_OBJS=snappy.o \
snappy-c.o \
Expand Down
22 changes: 22 additions & 0 deletions src/compression_tools/blosc/lib/snappy-1.1.1/Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#SHELL=/bin/sh

FLAGS = $(PKG_CXXFLAGS) $(PKG_CXXPICFLAGS) $(PKG_CPPFLAGS) $(PKG_R_CPPFLAGS) -DUSING_R @NO_RLIB@

SNAPPY_OBJS=snappy.o \
snappy-c.o \
snappy-sinksource.o \
snappy-stubs-internal.o

all: $(SNAPPY_OBJS)

snappy.o: snappy.cc
$(CXX) $(FLAGS) -c snappy.cc
snappy-c.o: snappy-c.cc
$(CXX) $(FLAGS) -c snappy-c.cc
snappy-sinksource.o: snappy-sinksource.cc
$(CXX) $(FLAGS) -c snappy-sinksource.cc
snappy-stubs-internal.o: snappy-stubs-internal.cc
$(CXX) $(FLAGS) -c snappy-stubs-internal.cc

clean:
rm -f *.o
13 changes: 11 additions & 2 deletions src/compression_tools/blosc/lib/snappy-1.1.1/snappy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@
#include <string>
#include <vector>

#include <R_ext/Error.h>
#include <R_ext/Print.h>
#if !defined(NO_RLIB)
# include <R_ext/Error.h>
# include <R_ext/Print.h>
#else
# ifndef Rprintf
# define Rprintf(x, ...) (printf(x, ...))
# endif
# ifndef error
# define error(x, ...) (fprintf(stderr, x, ...); abort())
# endif
#endif

namespace snappy {

Expand Down

0 comments on commit bf2f1ce

Please sign in to comment.