aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCalvin Rose <calsrose@gmail.com>2025-08-24 16:18:09 -0500
committerGitHub <noreply@github.com>2025-08-24 16:18:09 -0500
commitfd234461d7a3727413bddf1a97557e3120ecc8ba (patch)
tree8d500b8f2acd4ae9ca5c70f09e893300250211bc
parentUse janet_gettime instead of clock_gettime in ev.c (diff)
parentillumos support (diff)
Merge pull request #1628 from snltd/illumos-support
illumos support
-rw-r--r--Makefile11
-rw-r--r--README.md4
-rw-r--r--src/core/os.c9
-rw-r--r--src/include/janet.h7
4 files changed, 28 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 505d1a70..857bf421 100644
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,7 @@ SPORK_TAG?=master
HAS_SHARED?=1
DEBUGGER=gdb
SONAME_SETTER=-Wl,-soname,
+STRIPFLAGS=-x -S
# For cross compilation
HOSTCC?=$(CC)
@@ -80,6 +81,12 @@ ifeq ($(UNAME), Darwin)
LDCONFIG:=true
else ifeq ($(UNAME), Linux)
CLIBS:=$(CLIBS) -lrt -ldl
+else ifeq ($(UNAME), SunOS)
+ BUILD_CFLAGS+=-D__EXTENSIONS__ -DJANET_NO_NANBOX
+ BOOT_CFLAGS+=-D__EXTENSIONS__ -DJANET_NO_NANBOX
+ CLIBS:=-lsocket -lm
+ STRIPFLAGS=-x
+ LDCONFIG:=false
endif
# For other unix likes, add flags here!
@@ -289,7 +296,7 @@ build/janet-%.tar.gz: $(JANET_TARGET) \
README.md build/c/janet.c build/c/shell.c
mkdir -p build/$(JANET_DIST_DIR)/bin
cp $(JANET_TARGET) build/$(JANET_DIST_DIR)/bin/
- strip -x -S 'build/$(JANET_DIST_DIR)/bin/janet'
+ strip $(STRIPFLAGS) 'build/$(JANET_DIST_DIR)/bin/janet'
mkdir -p build/$(JANET_DIST_DIR)/include
cp build/janet.h build/$(JANET_DIST_DIR)/include/
mkdir -p build/$(JANET_DIST_DIR)/lib/
@@ -336,7 +343,7 @@ build/janet.pc: $(JANET_TARGET)
install: $(JANET_TARGET) $(JANET_LIBRARY) $(JANET_STATIC_LIBRARY) build/janet.pc build/janet.h
mkdir -p '$(DESTDIR)$(BINDIR)'
cp $(JANET_TARGET) '$(DESTDIR)$(BINDIR)/janet'
- strip -x -S '$(DESTDIR)$(BINDIR)/janet'
+ strip $(STRIPFLAGS) '$(DESTDIR)$(BINDIR)/janet'
mkdir -p '$(DESTDIR)$(INCLUDEDIR)/janet'
cp -r build/janet.h '$(DESTDIR)$(INCLUDEDIR)/janet'
ln -sf ./janet/janet.h '$(DESTDIR)$(INCLUDEDIR)/janet.h'
diff --git a/README.md b/README.md
index 72c25d40..8324e1dd 100644
--- a/README.md
+++ b/README.md
@@ -213,6 +213,10 @@ gmake install-jpm-git
NetBSD build instructions are the same as the FreeBSD build instructions.
Alternatively, install the package directly with `pkgin install janet`.
+### illumos
+
+Building on illumos is exactly the same as building on FreeBSD.
+
### Windows
1. Install [Visual Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=15#) or [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15#).
diff --git a/src/core/os.c b/src/core/os.c
index 12802a9a..aa052a18 100644
--- a/src/core/os.c
+++ b/src/core/os.c
@@ -173,6 +173,8 @@ JANET_CORE_FN(os_which,
return janet_ckeywordv("dragonfly");
#elif defined(JANET_BSD)
return janet_ckeywordv("bsd");
+#elif defined(JANET_ILLUMOS)
+ return janet_ckeywordv("illumos");
#else
return janet_ckeywordv("posix");
#endif
@@ -312,6 +314,13 @@ JANET_CORE_FN(os_cpu_count,
return dflt;
}
return janet_wrap_integer(result);
+#elif defined(JANET_ILLUMOS)
+ (void) dflt;
+ long result = sysconf(_SC_NPROCESSORS_CONF);
+ if (result < 0) {
+ return dflt;
+ }
+ return janet_wrap_integer(result);
#else
return dflt;
#endif
diff --git a/src/include/janet.h b/src/include/janet.h
index 74d0661f..844884f8 100644
--- a/src/include/janet.h
+++ b/src/include/janet.h
@@ -77,6 +77,11 @@ extern "C" {
#define JANET_CYGWIN 1
#endif
+/* Check for Illumos */
+#if defined(__illumos__)
+#define JANET_ILLUMOS 1
+#endif
+
/* Check Unix */
#if defined(_AIX) \
|| defined(__APPLE__) /* Darwin */ \
@@ -162,7 +167,7 @@ extern "C" {
#endif
/* Check sun */
-#ifdef __sun
+#if defined(__sun) && !defined(JANET_ILLUMOS)
#define JANET_NO_UTC_MKTIME
#endif