Source: opencv Version: 2.4.5+dfsg-0exp1 Severity: serious Tags: patch Justification: fails to build from source (but built successfully in the past)
Hi, opencv 2.4.5+dfsg-0exp1 fails to build on non-Linux archs [1][2][3]. Attached there are two patches fixing the issues: * non-linux.diff: upstream changes - include some Linux headers (and use sysconf to get the active processors count) also when using GNU libc - do not include sys/sysctl.h on Hurd, since this non-standard include does not exist there * non-linux-debian.diff: Debian-only changes - build 1394 and v4l support only on Linux; the v4l support would be detected and enabled on kFreeBSD, but the actual implementation seems Linux-specific [1] https://buildd.debian.org/status/fetch.php?pkg=opencv&arch=kfreebsd-i386&ver=2.4.5%2Bdfsg-0exp1&stamp=1375854567 [2] https://buildd.debian.org/status/fetch.php?pkg=opencv&arch=kfreebsd-amd64&ver=2.4.5%2Bdfsg-0exp1&stamp=1375849913 [3] https://buildd.debian.org/status/fetch.php?pkg=opencv&arch=hurd-i386&ver=2.4.5%2Bdfsg-0exp1&stamp=1376429030 Thanks, -- Pino
--- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -93,13 +93,13 @@ #include <stdarg.h> -#if defined __linux__ || defined __APPLE__ +#if defined __linux__ || defined __APPLE__ || defined __GLIBC__ #include <unistd.h> #include <stdio.h> #include <sys/types.h> #if defined ANDROID #include <sys/sysconf.h> -#else +#elif !defined __GNU__ #include <sys/sysctl.h> #endif #endif --- a/modules/core/src/parallel.cpp +++ b/modules/core/src/parallel.cpp @@ -50,13 +50,13 @@ #undef abs #endif -#if defined __linux__ || defined __APPLE__ +#if defined __linux__ || defined __APPLE__ || defined __GLIBC__ #include <unistd.h> #include <stdio.h> #include <sys/types.h> #if defined ANDROID #include <sys/sysconf.h> - #else + #elif !defined __GNU__ #include <sys/sysctl.h> #endif #endif @@ -451,7 +451,7 @@ int cv::getNumberOfCPUs(void) #elif defined ANDROID static int ncpus = getNumberOfCPUsImpl(); return ncpus; -#elif defined __linux__ +#elif defined __linux__ || defined __GLIBC__ return (int)sysconf( _SC_NPROCESSORS_ONLN ); #elif defined __APPLE__ int numCPU=0;
--- a/debian/rules +++ b/debian/rules @@ -2,6 +2,7 @@ export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie,+fortify DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) +DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS) DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) # SSE options @@ -18,6 +19,13 @@ CMAKE_ARCH_FLAGS += -DWITH_TBB=OFF endif +# Linux-specific stuff +ifeq ($(DEB_HOST_ARCH_OS),linux) +CMAKE_ARCH_FLAGS += -DWITH_1394=ON -DWITH_V4L=ON +else +CMAKE_ARCH_FLAGS += -DWITH_1394=OFF -DWITH_V4L=OFF +endif + CMAKE_FLAGS = \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_LIBDIR="lib/$(DEB_HOST_MULTIARCH)" \ @@ -41,8 +49,6 @@ -DWITH_OPENEXR=ON \ -DWITH_PVAPI=ON \ -DWITH_UNICAP=OFF \ - -DWITH_1394=ON \ - -DWITH_V4L=ON \ -DWITH_EIGEN=ON \ -DWITH_XINE=OFF \ -DBUILD_TESTS=OFF \