solairs/illumos build fix proposal.

This commit is contained in:
David Carlier 2021-06-13 08:25:56 +01:00
parent f4e7ee59c4
commit 53c684525f
4 changed files with 17 additions and 2 deletions

View File

@ -160,6 +160,9 @@ else()
else()
list(APPEND yquake2LinkerFlags "-lnetwork")
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
list(APPEND yquake2LinkerFlags "-lsocket -lnsl")
endif()
endif()
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

View File

@ -339,6 +339,8 @@ else ifeq ($(YQ2_OSTYPE), Darwin)
override LDFLAGS += -arch $(YQ2_ARCH)
else ifeq ($(YQ2_OSTYPE), Haiku)
override LDFLAGS += -lm -lnetwork
else ifeq ($(YQ2_OSTYPE), SunOS)
override LDFLAGS += -lm -lsocket -lnsl
endif
ifneq ($(YQ2_OSTYPE), Darwin)

View File

@ -29,7 +29,7 @@
#include "../../common/header/shared.h"
#if defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun)
#include <unistd.h> // readlink(), amongst others
#endif
@ -73,14 +73,18 @@ static void SetExecutablePath(char* exePath)
exePath[0] = '\0';
}
#elif defined(__linux)
#elif defined(__linux) || defined(__sun)
// all the platforms that have /proc/$pid/exe or similar that symlink the
// real executable - basiscally Linux and the BSDs except for FreeBSD which
// doesn't enable proc by default and has a sysctl() for this. OpenBSD once
// had /proc but removed it for security reasons.
char buf[PATH_MAX] = {0};
#if defined(__linux)
snprintf(buf, sizeof(buf), "/proc/%d/exe", getpid());
#else
snprintf(buf, sizeof(buf), "/proc/%ld/path/a.out", getpid());
#endif
// readlink() doesn't null-terminate!
int len = readlink(buf, exePath, PATH_MAX-1);
if (len <= 0)

View File

@ -34,6 +34,12 @@
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#if defined(__sun)
#include <sys/filio.h>
#if !defined(MAX)
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#endif
#include <errno.h>
#include <arpa/inet.h>
#include <net/if.h>