From 25879fc24d96c89e817e7950ec92d6e2cb41e1b3 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 14 Dec 2020 20:37:32 +0100 Subject: [PATCH] Basic changes for GNU/Hurd (#676) * Define OSMINOR & OS_HURD on GNU/Hurd Add a way to identify GNU/Hurd with b2, and also in the Python support. * Use /proc/self/exe for executable_path on Hurd Use the Linux compatibility procfs translator to get the full path of the current executable. * Define _GNU_SOURCE on any GNU libc-based OS Make sure to enable GNU features when building on any OS that uses GNU libc. --- src/engine/jam.cpp | 2 +- src/engine/jam.h | 4 ++++ src/engine/sysinfo.cpp | 2 +- src/tools/builtin.py | 6 +++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/engine/jam.cpp b/src/engine/jam.cpp index c419f1fa1..76acdb6f7 100644 --- a/src/engine/jam.cpp +++ b/src/engine/jam.cpp @@ -747,7 +747,7 @@ char * executable_path( char const * argv0 ) sysctl( mib, 4, buf, &size, NULL, 0 ); return ( !size || size == sizeof( buf ) ) ? NULL : strndup( buf, size ); } -#elif defined(__linux__) || defined(__CYGWIN__) +#elif defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__) # include char * executable_path( char const * argv0 ) { diff --git a/src/engine/jam.h b/src/engine/jam.h index 25e5736fd..f9f139582 100644 --- a/src/engine/jam.h +++ b/src/engine/jam.h @@ -189,6 +189,10 @@ #define OSMINOR "OS=DGUX" #define OS_DGUX #endif +#ifdef __GNU__ + #define OSMINOR "OS=HURD" + #define OS_HURD +#endif #ifdef __hpux #define OSMINOR "OS=HPUX" #define OS_HPUX diff --git a/src/engine/sysinfo.cpp b/src/engine/sysinfo.cpp index c3257e71e..fa2e3c163 100644 --- a/src/engine/sysinfo.cpp +++ b/src/engine/sysinfo.cpp @@ -18,7 +18,7 @@ #include #endif -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(__GLIBC__) // Need to define this in case it's not as that's the only way to get the // sched_* APIs. #ifndef _GNU_SOURCE diff --git a/src/tools/builtin.py b/src/tools/builtin.py index 9eeaaf697..ecec2c9e3 100644 --- a/src/tools/builtin.py +++ b/src/tools/builtin.py @@ -82,9 +82,9 @@ def variant (name, parents_or_properties, explicit_properties = []): feature.compose ("" + name, explicit_properties.all()) __os_names = """ - amiga aix appletv bsd cygwin darwin dos emx freebsd hpux iphone linux netbsd - openbsd osf qnx qnxnto sgi solaris sun sunos svr4 sysv ultrix unix unixware - vms windows + amiga aix appletv bsd cygwin darwin dos emx freebsd hpux hurd iphone linux + netbsd openbsd osf qnx qnxnto sgi solaris sun sunos svr4 sysv ultrix unix + unixware vms windows """.split() # Translates from bjam current OS to the os tags used in host-os and target-os,