Package: ninja-build
Version: 1.0.0-1
Severity: important
Tags: patch

Hi,

ninja-build does not build on non-Linux archs, such as
GNU/kFreeBSD[1][2] and GNU/Hurd[3].

The problem is that the GetProcessorCount() implementation for these
architectures is the sysconf() one, but <unistd.h> has not been
included, causing sysconf() and _SC_NPROCESSORS_ONLN to not be
declared. Another solution (which is the one I chose) is to make use
of the "linux" implementation which uses get_nprocs(), which is a GNU
extension and thus available for anything using GNU libc.
If this solution is not deemed wanted, the other solution is to just add
  #ifndef _WIN32
  #include <unistd.h>
  #endif
among the other includes in src/util.cc.

[1] 
https://buildd.debian.org/status/fetch.php?pkg=ninja-build&arch=kfreebsd-i386&ver=1.0.0-1&stamp=1355174935
[2] 
https://buildd.debian.org/status/fetch.php?pkg=ninja-build&arch=kfreebsd-amd64&ver=1.0.0-1&stamp=1355175958
[3] 
https://buildd.debian.org/status/fetch.php?pkg=ninja-build&arch=hurd-i386&ver=1.0.0-1&stamp=1355180120

Thanks,
-- 
Pino
--- a/src/util.cc
+++ b/src/util.cc
@@ -39,7 +39,7 @@
 #elif defined(__SVR4) && defined(__sun)
 #include <unistd.h>
 #include <sys/loadavg.h>
-#elif defined(linux)
+#elif defined(linux) || defined(__GLIBC__)
 #include <sys/sysinfo.h>
 #endif
 
@@ -295,7 +295,7 @@ string StripAnsiEscapeCodes(const string
   return stripped;
 }
 
-#if defined(linux)
+#if defined(linux) || defined(__GLIBC__)
 int GetProcessorCount() {
   return get_nprocs();
 }

Reply via email to