| 1 |
#! /usr/bin/env sh |
| 2 |
|
| 3 |
# Check that this is not just ./configure. We need to run this |
| 4 |
# from R CMD INSTALL, to have the R env vars set. |
| 5 |
|
| 6 |
if [ -z "$R_HOME" ]; then |
| 7 |
echo >&2 R_HOME is not set, are you running R CMD INSTALL? |
| 8 |
exit 1 |
| 9 |
fi |
| 10 |
|
| 11 |
# Find the R binary we need to use. This is a bit trickier on |
| 12 |
# Windows, because it has two architectures. On windows R_ARCH_BIN |
| 13 |
# is set, so this should work everywhere. |
| 14 |
RBIN="${R_HOME}/bin${R_ARCH_BIN}/R" |
| 15 |
|
| 16 |
# ------------------------------------------------------------------------ |
| 17 |
# Detect system |
| 18 |
# ------------------------------------------------------------------------ |
| 19 |
|
| 20 |
unset POSIX |
| 21 |
if [ "$R_OSTYPE" = "unix" ]; then |
| 22 |
UNAME=`uname` |
| 23 |
else |
| 24 |
UNAME=Windows |
| 25 |
fi |
| 26 |
|
| 27 |
if [ -n "$EMSCRIPTEN" ] && [ -n "$CROSS_COMPILE" ]; then |
| 28 |
UNAME=Emscripten |
| 29 |
fi |
| 30 |
|
| 31 |
unset WINDOWS |
| 32 |
if [ "$R_OSTYPE" = "windows" ]; then WINDOWS=true; fi |
| 33 |
|
| 34 |
unset LINUX |
| 35 |
if [ "$UNAME" = "Linux" ]; then LINUX=true; POSIX=true; fi |
| 36 |
|
| 37 |
unset MACOS |
| 38 |
if [ "$UNAME" = "Darwin" ]; then MACOS=true; POSIX=true; fi |
| 39 |
|
| 40 |
unset FREEBSD |
| 41 |
if [ "$UNAME" = "FreeBSD" ]; then FREEBSD=true; POSIX=true; fi |
| 42 |
|
| 43 |
unset OPENBSD |
| 44 |
if [ "$UNAME" = "OpenBSD" ]; then OPENBSD=true; POSIX=true; fi |
| 45 |
|
| 46 |
unset NETBSD |
| 47 |
## if [ "$UNAME" = "NetBSD" ]; then NETBSD=true; POSIX=true; fi |
| 48 |
|
| 49 |
unset DRAGONFLY |
| 50 |
if [ "$UNAME" = "DragonFly" ]; then DRAGONFLY=true; POSIX=true; fi |
| 51 |
|
| 52 |
unset BSD |
| 53 |
if [ -n "$FREEBSD" ] || [ -n "$OPENBSD" ] || [ -n "$NETBSD" ] || [ -n "$DRAGONFLY" ]; then |
| 54 |
BSD=true |
| 55 |
fi |
| 56 |
|
| 57 |
unset SUNOS |
| 58 |
## if [ "UNAME" = "SunOS" ]; then SUNOS=true; POSIX=true; fi |
| 59 |
|
| 60 |
unset AIX |
| 61 |
## if [ "UNAME" = "AIX" ]; then AIX=true; POSIX=true; fi |
| 62 |
|
| 63 |
# ------------------------------------------------------------------------ |
| 64 |
# Set source files, macros, libs, compile flags |
| 65 |
# ------------------------------------------------------------------------ |
| 66 |
|
| 67 |
CPPFLAGS= |
| 68 |
|
| 69 |
if [ -n "$WINDOWS" ]; then |
| 70 |
LIBRARIES= |
| 71 |
|
| 72 |
elif [ -n "$FREEBSD" ]; then |
| 73 |
LIBRARIES= |
| 74 |
|
| 75 |
elif [ -n "$DRAGONFLY" ]; then |
| 76 |
LIBRARIES= |
| 77 |
|
| 78 |
elif [ -n "$OPENBSD" ]; then |
| 79 |
LIBRARIES=bind |
| 80 |
LIBDIRS=-L/usr/local/lib/libbind |
| 81 |
CPPFLAGS=-I/usr/local/include/bind |
| 82 |
|
| 83 |
else |
| 84 |
LIBRARIES=resolv |
| 85 |
fi |
| 86 |
|
| 87 |
# ------------------------------------------------------------------------ |
| 88 |
# Create Makevars file |
| 89 |
# ------------------------------------------------------------------------ |
| 90 |
|
| 91 |
# OBJECTS (= source files) |
| 92 |
# LIBRARIES -> PKG_LIBS |
| 93 |
|
| 94 |
LIBS=`for l in $LIBRARIES; do echo "-l${l}"; done | tr "\n", " "` |
| 95 |
LIBS="$LIBDIRS ${LIBS} $FRAMEWORKS" |
| 96 |
|
| 97 |
cat src/Makevars.in | \ |
| 98 |
sed "s|@OBJECTS@|${OBJECTS}|" | \ |
| 99 |
sed "s|@LIBS@|${LIBS}|" | \ |
| 100 |
sed "s|@TARGETS@|${TARGETS}|" | \ |
| 101 |
sed "s|@CPPFLAGS@|${CPPFLAGS}|" | \ |
| 102 |
sed "s|@EXTRA@|${EXTRA}|" > src/Makevars |