From c3b2892ef98e67dcd4443386c0ba7261bb1c6527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Wed, 23 Oct 2024 12:55:20 +0200 Subject: [PATCH] Fix install on FreeBSD Need a configure script, unfortunately. --- .Rbuildignore | 1 + .gitignore | 1 + DESCRIPTION | 1 + Makefile | 5 --- cleanup | 3 ++ configure | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ configure.win | 3 ++ src/Makevars | 1 - src/Makevars.in | 1 + src/rping.c | 1 + 10 files changed, 99 insertions(+), 6 deletions(-) delete mode 100644 Makefile create mode 100755 cleanup create mode 100755 configure create mode 100755 configure.win delete mode 100644 src/Makevars create mode 100644 src/Makevars.in diff --git a/.Rbuildignore b/.Rbuildignore index 6ea7e0e..b003cdb 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -15,3 +15,4 @@ ^pkgdown$ ^\.github$ ^codecov\.yml$ +^src/Makevars$ diff --git a/.gitignore b/.gitignore index 5a074d7..1dd1f75 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /revdep .Rproj.user docs +/src/Makevars diff --git a/DESCRIPTION b/DESCRIPTION index 093f193..cdc9bb9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,3 +26,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 +Biarch: true diff --git a/Makefile b/Makefile deleted file mode 100644 index dd7836b..0000000 --- a/Makefile +++ /dev/null @@ -1,5 +0,0 @@ - -all: README.md - -README.md: README.Rmd - Rscript -e "library(knitr); knit('$<', output = '$@', quiet = TRUE)" diff --git a/cleanup b/cleanup new file mode 100755 index 0000000..030f84d --- /dev/null +++ b/cleanup @@ -0,0 +1,3 @@ +#' !/usr/bin/env sh + +rm -f src/Makevars diff --git a/configure b/configure new file mode 100755 index 0000000..71336fa --- /dev/null +++ b/configure @@ -0,0 +1,88 @@ +#! /usr/bin/env sh + +# Check that this is not just ./configure. We need to run this +# from R CMD INSTALL, to have the R env vars set. + +if [ -z "$R_HOME" ]; then + echo >&2 R_HOME is not set, are you running R CMD INSTALL? + exit 1 +fi + +# Find the R binary we need to use. This is a bit trickier on +# Windows, because it has two architectures. On windows R_ARCH_BIN +# is set, so this should work everywhere. +RBIN="${R_HOME}/bin${R_ARCH_BIN}/R" + +# ------------------------------------------------------------------------ +# Detect system +# ------------------------------------------------------------------------ + +unset POSIX +if [ "$R_OSTYPE" = "unix" ]; then + UNAME=`uname` +else + UNAME=Windows +fi + +if [ -n "$EMSCRIPTEN" ] && [ -n "$CROSS_COMPILE" ]; then + UNAME=Emscripten +fi + +unset WINDOWS +if [ "$R_OSTYPE" = "windows" ]; then WINDOWS=true; fi + +unset LINUX +if [ "$UNAME" = "Linux" ]; then LINUX=true; POSIX=true; fi + +unset MACOS +if [ "$UNAME" = "Darwin" ]; then MACOS=true; POSIX=true; fi + +unset FREEBSD +if [ "$UNAME" = "FreeBSD" ]; then FREEBSD=true; POSIX=true; fi + +unset OPENBSD +## if [ "$UNAME" = "OpenBSD" ]; then OPENBSD=true; POSIX=true; fi + +unset NETBSD +## if [ "$UNAME" = "NetBSD" ]; then NETBSD=true; POSIX=true; fi + +unset BSD +if [ -n "$FREEBSD" ] || [ -n "$OPENBSD" ] || [ -n "$NETBSD" ]; then + BSD=true +fi + +unset SUNOS +## if [ "UNAME" = "SunOS" ]; then SUNOS=true; POSIX=true; fi + +unset AIX +## if [ "UNAME" = "AIX" ]; then AIX=true; POSIX=true; fi + +# ------------------------------------------------------------------------ +# Set source files, macros, libs, compile flags +# ------------------------------------------------------------------------ + +if [ -n "$WINDOWS" ]; then + LIBRARIES= + +elif [ -n "$FREEBSD" ]; then + LIBRARIES= + +else + LIBRARIES=resolv +fi + +# ------------------------------------------------------------------------ +# Create Makevars file +# ------------------------------------------------------------------------ + +# OBJECTS (= source files) +# LIBRARIES -> PKG_LIBS + +LIBS=`for l in $LIBRARIES; do echo "-l${l}"; done | tr "\n", " "` +LIBS="${LIBS} $FRAMEWORKS" + +cat src/Makevars.in | \ + sed "s|@OBJECTS@|${OBJECTS}|" | \ + sed "s/@LIBS@/${LIBS}/" | \ + sed "s/@TARGETS@/${TARGETS}/" | \ + sed "s|@EXTRA@|${EXTRA}|" > src/Makevars diff --git a/configure.win b/configure.win new file mode 100755 index 0000000..994f9fd --- /dev/null +++ b/configure.win @@ -0,0 +1,3 @@ +#! /usr/bin/env sh + +sh ./configure diff --git a/src/Makevars b/src/Makevars deleted file mode 100644 index b29f8bd..0000000 --- a/src/Makevars +++ /dev/null @@ -1 +0,0 @@ -PKG_LIBS = -lresolv diff --git a/src/Makevars.in b/src/Makevars.in new file mode 100644 index 0000000..ee8b035 --- /dev/null +++ b/src/Makevars.in @@ -0,0 +1 @@ +PKG_LIBS = @LIBS@ diff --git a/src/rping.c b/src/rping.c index 0cb19ef..a9ab8cb 100644 --- a/src/rping.c +++ b/src/rping.c @@ -35,6 +35,7 @@ void usleep(__int64 usec) { # include # include # include +# include # include # define WINSTARTUP() # define WINCLEANUP()