Add more values for (os/which)

Some bsd flavors.
This commit is contained in:
Calvin Rose 2019-07-27 11:29:40 -05:00
parent b0b1024f8a
commit 3c133bd677
2 changed files with 15 additions and 5 deletions

View File

@ -296,11 +296,12 @@
(def lflags [;(opt opts :lflags default-lflags)
;(if (opts :static) [] dynamic-lflags)
;(if standalone (case (os/which)
:posix ["-ldl" "-lm"]
:macos ["-ldl" "-lm"]
:windows []
:linux ["-lm" "-ldl" "-lrt"]
[]) [])])
:openbsd ["-lm"]
#default
["-ldl" "-lm"]) [])])
(rule target objects
(print "linking " target "...")
(if is-win

View File

@ -75,6 +75,12 @@ static Janet os_which(int32_t argc, Janet *argv) {
return janet_ckeywordv("web");
#elif defined(__linux__)
return janet_ckeywordv("linux");
#elif define(__FreeBSD__)
return janet_ckeywordv("freebsd");
#elif define(__NetBSD__)
return janet_ckeywordv("netbsd");
#elif define(__OpenBSD__)
return janet_ckeywordv("openbsd");
#else
return janet_ckeywordv("posix");
#endif
@ -763,10 +769,13 @@ static const JanetReg os_cfuns[] = {
"os/which", os_which,
JDOC("(os/which)\n\n"
"Check the current operating system. Returns one of:\n\n"
"\t:windows - Microsoft Windows\n"
"\t:macos - Apple macos\n"
"\t:windows\n"
"\t:macos\n"
"\t:web - Web assembly (emscripten)\n"
"\t:linux - Linux\n"
"\t:linux\n"
"\t:freebsd\n"
"\t:openbsd\n"
"\t:netbsd\n"
"\t:posix - A POSIX compatible system (default)")
},
{