From b731f6ab033d50878d1e77541b13ccfe8fc4052f Mon Sep 17 00:00:00 2001 From: nia Date: Mon, 27 Jul 2020 00:17:22 +0100 Subject: [PATCH] Fix build on NetBSD. The NetBSD C library's headers do not expose extensions when compiling with -std=c99 (as opposed to -std=gnu99 or no -std= option), so define _NETBSD_SOURCE to get timegm, and functions that would otherwise require an _XOPEN_SOURCE definition, e.g. realpath. Note that, as with FreeBSD, you need gmake to compile janet on NetBSD, and can also install it from packages. --- README.md | 5 +++++ src/core/features.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 55b4fe71..7ae129b0 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,11 @@ gmake test gmake repl ``` +### NetBSD + +NetBSD build instructions are the same as the FreeBSD build instuctions. +Alternatively, install directly from packages, using `pkgin install janet`. + ### 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/features.h b/src/core/features.h index c594c1fc..ef9a0aea 100644 --- a/src/core/features.h +++ b/src/core/features.h @@ -38,4 +38,11 @@ #define _XOPEN_SOURCE 500 #endif +/* Needed for timegm and other extensions when building with -std=c99. + * It also defines realpath, etc, which would normally require + * _XOPEN_SOURCE >= 500. */ +#if !defined(_NETBSD_SOURCE) && defined(__NetBSD__) +#define _NETBSD_SOURCE +#endif + #endif