Skip to content

Commit

Permalink
Fix install on FreeBSD
Browse files Browse the repository at this point in the history
Need a configure script, unfortunately.
  • Loading branch information
gaborcsardi committed Oct 23, 2024
1 parent ae99e64 commit c3b2892
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 6 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
^pkgdown$
^\.github$
^codecov\.yml$
^src/Makevars$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/revdep
.Rproj.user
docs
/src/Makevars
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Biarch: true
5 changes: 0 additions & 5 deletions Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#' !/usr/bin/env sh

rm -f src/Makevars
88 changes: 88 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions configure.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /usr/bin/env sh

sh ./configure
1 change: 0 additions & 1 deletion src/Makevars

This file was deleted.

1 change: 1 addition & 0 deletions src/Makevars.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PKG_LIBS = @LIBS@
1 change: 1 addition & 0 deletions src/rping.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void usleep(__int64 usec) {
# include <unistd.h>
# include <netdb.h>
# include <arpa/inet.h>
# include <netinet/in.h>
# include <fcntl.h>
# define WINSTARTUP()
# define WINCLEANUP()
Expand Down

0 comments on commit c3b2892

Please sign in to comment.