From 415f423af64e9553e791448319d948a54df6ae61 Mon Sep 17 00:00:00 2001 From: boB Rudis Date: Mon, 15 Aug 2016 14:56:34 -0400 Subject: [PATCH] a more robust confiure --- README.md | 5 +++-- configure | 19 +++++++++++++++++-- src/Makevars | 4 ++-- src/Makevars.in | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 src/Makevars.in diff --git a/README.md b/README.md index e7f84b0..faa1371 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ The `libmagic` library must be installed on \*nix/macOS and available to use this. -- `apt-get install libmagic-dev` on Debian-ish systems +- `apt-get install libmagic-dev` on Ubuntu/Debian-ish systems - `brew install libmagic` on macOS +- `yum install file-devel` on RHEL/CentOS/Fedora While the package was developed using the 5.28 version of `libmagic` it has been configured to work with older versions. Note that some fields in the resultant data frame might not be available with older library versions. When using the function `magic_wand_file()` it checks for which version of `libmagic` is installed on your system and provides a suitable `magic.mgc` file for it. @@ -105,7 +106,7 @@ library(testthat) date() ``` - ## [1] "Mon Aug 15 11:54:15 2016" + ## [1] "Mon Aug 15 14:56:16 2016" ``` r test_dir("tests/") diff --git a/configure b/configure index 345c33a..8f66523 100755 --- a/configure +++ b/configure @@ -3,7 +3,9 @@ echo "Checking to see if libmagic is available..." : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then + echo echo "could not determine R_HOME" + echo exit 1 fi @@ -15,6 +17,18 @@ LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS` DYLIB_LDFLAGS=`"${R_HOME}/bin/R" CMD config DYLIB_LDFLAGS` SHLIB_LDFLAGS=`"${R_HOME}/bin/R" CMD config SHLIB_LDFLAGS` +LIBDIRS="/usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/lib64 /usr/lib32 /usr/local/lib /opt/local/lib /usr/lib /lib" +PKG_LD_FLAGS="" +for DIR in ${LIBDIRS} ; do + if test -d ${DIR} ; then PKG_LD_FLAGS="${PKG_LD_FLAGS} -L$DIR" ; fi +done + +INCDIRS="/usr/include/x86_64-linux-gnu /usr/include/i386-linux-gnu /usr/include /usr/local/include /opt/local/include" +PKG_CPP_FLAGS="" +for DIR in ${INCDIRS} ; do + if test -d ${DIR} ; then PKG_CPP_FLAGS="${PKG_CPP_FLAGS} -L$DIR" ; fi +done + temp_src=$(mktemp) cat > ${temp_src} < /dev/null 2>&1 - +${CPP} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} ${PKG_CPP_FLAGS} ${PKG_LD_FLAGS} -o ${temp_exe} -lmagic ${temp_src} > /dev/null 2>&1 ccerr=$? rm ${temp_src} ${temp_exe} @@ -43,4 +56,6 @@ if [ "$ccerr" = 1 ] ; then exit 1 fi +sed -e "s|@cflags@|$PKG_CPP_FLAGS|" -e "s|@libs@|$PKG_LD_FLAGS|" src/Makevars.in > src/Makevars + exit 0 diff --git a/src/Makevars b/src/Makevars index dc62823..073ba9f 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1,2 +1,2 @@ -PKG_LIBS = -lmagic - +PKG_CPPFLAGS= -L/usr/local/include +PKG_LIBS= -L/usr/local/lib -L/usr/lib -lmagic diff --git a/src/Makevars.in b/src/Makevars.in new file mode 100644 index 0000000..7b1840d --- /dev/null +++ b/src/Makevars.in @@ -0,0 +1,2 @@ +PKG_CPPFLAGS=@cflags@ +PKG_LIBS=@libs@ -lmagic