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() else()
list(APPEND yquake2LinkerFlags "-lnetwork") list(APPEND yquake2LinkerFlags "-lnetwork")
endif() endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
list(APPEND yquake2LinkerFlags "-lsocket -lnsl")
endif()
endif() endif()
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

View file

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

View file

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

View file

@ -34,6 +34,12 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/uio.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 <errno.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <net/if.h> #include <net/if.h>