Browse Source

a more robust confiure

tags/v0.3.0
boB Rudis 6 years ago
parent
commit
415f423af6
  1. 5
      README.md
  2. 19
      configure
  3. 4
      src/Makevars
  4. 2
      src/Makevars.in

5
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/")

19
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} <<EOF
#include "src/magic.h"
@ -26,8 +40,7 @@ EOF
temp_exe=$(mktemp)
${CC} ${CFLAGS} ${CPPFLAGS} ${LD_FLAGS} ${CXXFLAGS} ${DYLIB_LDFLAGS} ${SHLIB_LDFLAGS} -L/usr/local/lib -L/opt/local/lib -L/usr/lib -lmagic -o ${temp_exe} ${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

4
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

2
src/Makevars.in

@ -0,0 +1,2 @@
PKG_CPPFLAGS=@cflags@
PKG_LIBS=@libs@ -lmagic
Loading…
Cancel
Save