Skip to content

Commit fd23446

Browse files
authored
Merge pull request #1628 from snltd/illumos-support
illumos support
2 parents eabb215 + deede6b commit fd23446

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ SPORK_TAG?=master
4747
HAS_SHARED?=1
4848
DEBUGGER=gdb
4949
SONAME_SETTER=-Wl,-soname,
50+
STRIPFLAGS=-x -S
5051

5152
# For cross compilation
5253
HOSTCC?=$(CC)
@@ -80,6 +81,12 @@ ifeq ($(UNAME), Darwin)
8081
LDCONFIG:=true
8182
else ifeq ($(UNAME), Linux)
8283
CLIBS:=$(CLIBS) -lrt -ldl
84+
else ifeq ($(UNAME), SunOS)
85+
BUILD_CFLAGS+=-D__EXTENSIONS__ -DJANET_NO_NANBOX
86+
BOOT_CFLAGS+=-D__EXTENSIONS__ -DJANET_NO_NANBOX
87+
CLIBS:=-lsocket -lm
88+
STRIPFLAGS=-x
89+
LDCONFIG:=false
8390
endif
8491

8592
# For other unix likes, add flags here!
@@ -289,7 +296,7 @@ build/janet-%.tar.gz: $(JANET_TARGET) \
289296
README.md build/c/janet.c build/c/shell.c
290297
mkdir -p build/$(JANET_DIST_DIR)/bin
291298
cp $(JANET_TARGET) build/$(JANET_DIST_DIR)/bin/
292-
strip -x -S 'build/$(JANET_DIST_DIR)/bin/janet'
299+
strip $(STRIPFLAGS) 'build/$(JANET_DIST_DIR)/bin/janet'
293300
mkdir -p build/$(JANET_DIST_DIR)/include
294301
cp build/janet.h build/$(JANET_DIST_DIR)/include/
295302
mkdir -p build/$(JANET_DIST_DIR)/lib/
@@ -336,7 +343,7 @@ build/janet.pc: $(JANET_TARGET)
336343
install: $(JANET_TARGET) $(JANET_LIBRARY) $(JANET_STATIC_LIBRARY) build/janet.pc build/janet.h
337344
mkdir -p '$(DESTDIR)$(BINDIR)'
338345
cp $(JANET_TARGET) '$(DESTDIR)$(BINDIR)/janet'
339-
strip -x -S '$(DESTDIR)$(BINDIR)/janet'
346+
strip $(STRIPFLAGS) '$(DESTDIR)$(BINDIR)/janet'
340347
mkdir -p '$(DESTDIR)$(INCLUDEDIR)/janet'
341348
cp -r build/janet.h '$(DESTDIR)$(INCLUDEDIR)/janet'
342349
ln -sf ./janet/janet.h '$(DESTDIR)$(INCLUDEDIR)/janet.h'

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ gmake install-jpm-git
213213
NetBSD build instructions are the same as the FreeBSD build instructions.
214214
Alternatively, install the package directly with `pkgin install janet`.
215215

216+
### illumos
217+
218+
Building on illumos is exactly the same as building on FreeBSD.
219+
216220
### Windows
217221

218222
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#).

src/core/os.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ JANET_CORE_FN(os_which,
173173
return janet_ckeywordv("dragonfly");
174174
#elif defined(JANET_BSD)
175175
return janet_ckeywordv("bsd");
176+
#elif defined(JANET_ILLUMOS)
177+
return janet_ckeywordv("illumos");
176178
#else
177179
return janet_ckeywordv("posix");
178180
#endif
@@ -312,6 +314,13 @@ JANET_CORE_FN(os_cpu_count,
312314
return dflt;
313315
}
314316
return janet_wrap_integer(result);
317+
#elif defined(JANET_ILLUMOS)
318+
(void) dflt;
319+
long result = sysconf(_SC_NPROCESSORS_CONF);
320+
if (result < 0) {
321+
return dflt;
322+
}
323+
return janet_wrap_integer(result);
315324
#else
316325
return dflt;
317326
#endif

src/include/janet.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ extern "C" {
7777
#define JANET_CYGWIN 1
7878
#endif
7979

80+
/* Check for Illumos */
81+
#if defined(__illumos__)
82+
#define JANET_ILLUMOS 1
83+
#endif
84+
8085
/* Check Unix */
8186
#if defined(_AIX) \
8287
|| defined(__APPLE__) /* Darwin */ \
@@ -162,7 +167,7 @@ extern "C" {
162167
#endif
163168

164169
/* Check sun */
165-
#ifdef __sun
170+
#if defined(__sun) && !defined(JANET_ILLUMOS)
166171
#define JANET_NO_UTC_MKTIME
167172
#endif
168173

0 commit comments

Comments
 (0)