Index: ports/opencv/nacl.patch |
diff --git a/ports/opencv/nacl.patch b/ports/opencv/nacl.patch |
new file mode 100644 |
index 0000000000000000000000000000000000000000..efa62a35a9557872e48e3021e2890d2833e89225 |
--- /dev/null |
+++ b/ports/opencv/nacl.patch |
@@ -0,0 +1,122 @@ |
+diff --git opencv-v2.4.7/XCompile-nacl.txt opencv-v2.4.7.nacl/XCompile-nacl.txt |
+new file mode 100644 |
+index 0000000..c651a2a |
+--- /dev/null |
++++ opencv-2.4.7.nacl/XCompile-nacl.txt |
+@@ -0,0 +1,17 @@ |
++# the name of the target operating system |
++SET(CMAKE_SYSTEM_NAME Linux) |
++ |
++SET(NACL_CROSS_PREFIX nacl) |
++ |
++# which compilers to use for C and C++ |
++SET(CMAKE_C_COMPILER "${NACLCC}") |
++SET(CMAKE_CXX_COMPILER "${NACLCXX}") |
++set(CMAKE_AR ${NACLAR} CACHE FILEPATH "Archiver") |
++SET(CMAKE_LINKER "${NACLLD}") |
++SET(_CMAKE_TOOLCHAIN_PREFIX ${NACL_CROSS_PREFIX}) |
++ |
++# here is the target environment located |
++SET(CMAKE_FIND_ROOT_PATH ${NACL_TOOLCHAIN_ROOT}) |
++ |
++# nacl abi says 32bits little endian |
++set(CMAKE_SIZEOF_VOID_P 4) |
+diff -Naur opencv-2.4.7/modules/contrib/src/inputoutput.cpp opencv-2.4.7.nacl/modules/contrib/src/inputoutput.cpp |
+--- opencv-2.4.7/modules/contrib/src/inputoutput.cpp 2013-11-06 15:26:39.000000000 +0100 |
++++ opencv-2.4.7.nacl/modules/contrib/src/inputoutput.cpp 2013-11-19 21:00:51.000000000 +0100 |
+@@ -76,7 +76,8 @@ |
+ { |
+ return list; |
+ } |
+- |
++// NaCl does not define struct fields to deal with folders. |
++#ifndef __native_client__ |
+ while ((dirp = readdir(dp)) != NULL) |
+ { |
+ if (dirp->d_type == DT_REG) |
+@@ -89,6 +90,7 @@ |
+ } |
+ } |
+ closedir(dp); |
++#endif //#ifndef __native__client__ |
+ #endif |
+ |
+ return list; |
+@@ -166,7 +168,8 @@ |
+ { |
+ return list; |
+ } |
+- |
++// NaCl does not define struct fields to deal with folders. |
++#ifndef __native_client__ |
+ while ((dirp = readdir(dp)) != NULL) |
+ { |
+ if (dirp->d_type == DT_DIR && |
+@@ -181,6 +184,8 @@ |
+ } |
+ } |
+ closedir(dp); |
++#endif //#ifndef __native__client__ |
++ |
+ #endif |
+ |
+ return list; |
+diff -Naur opencv-2.4.7/modules/core/include/opencv2/core/operations.hpp opencv-2.4.7.nacl/modules/core/include/opencv2/core/operations.hpp |
+--- opencv-2.4.7/modules/core/include/opencv2/core/operations.hpp 2013-11-06 15:26:39.000000000 +0100 |
++++ opencv-2.4.7.nacl/modules/core/include/opencv2/core/operations.hpp 2013-11-19 21:03:40.000000000 +0100 |
+@@ -58,7 +58,13 @@ |
+ |
+ #if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ |
+ #ifdef __ATOMIC_SEQ_CST |
++ // Clang in NaCl "cannot compile this atomic library call yet": use |
++ // instead a programmatic atomic fetch. |
++ #ifndef __native_client__ |
+ #define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST) |
++ #else |
++ int CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; } |
++#endif //#ifndef __native_client__ |
+ #else |
+ #define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), (delta), 5) |
+ #endif |
+diff -Naur opencv-2.4.7/modules/flann/include/opencv2/flann/allocator.h opencv-2.4.7.nacl/modules/flann/include/opencv2/flann/allocator.h |
+--- opencv-2.4.7/modules/flann/include/opencv2/flann/allocator.h 2013-11-06 15:26:39.000000000 +0100 |
++++ opencv-2.4.7.nacl/modules/flann/include/opencv2/flann/allocator.h 2013-11-19 21:04:57.000000000 +0100 |
+@@ -68,7 +68,10 @@ |
+ * |
+ */ |
+ |
++// In NaCl newlib, this variable is declared elsewhere non-const. |
++#if defined(__native_client__) && defined(__GLIBC__) |
+ const size_t WORDSIZE=16; |
++#endif //#ifndef __native__client__ |
+ const size_t BLOCKSIZE=8192; |
+ |
+ class PooledAllocator |
+diff -Naur opencv-2.4.7/modules/legacy/src/calibfilter.cpp opencv-2.4.7.nacl/modules/legacy/src/calibfilter.cpp |
+--- opencv-2.4.7/modules/legacy/src/calibfilter.cpp 2013-11-06 15:26:39.000000000 +0100 |
++++ opencv-2.4.7.nacl/modules/legacy/src/calibfilter.cpp 2013-11-19 21:05:54.000000000 +0100 |
+@@ -42,7 +42,10 @@ |
+ #include "precomp.hpp" |
+ #include <stdio.h> |
+ |
++// NaCl likes this preprocessor definition active, to use a struct field. |
++#ifndef __native_client__ |
+ #undef quad |
++#endif //#ifndef __native_client__ |
+ |
+ CvCalibFilter::CvCalibFilter() |
+ { |
+diff -Naur opencv-2.4.7/modules/legacy/src/epilines.cpp opencv-2.4.7.nacl/modules/legacy/src/epilines.cpp |
+--- opencv-2.4.7/modules/legacy/src/epilines.cpp 2013-11-06 15:26:39.000000000 +0100 |
++++ opencv-2.4.7.nacl/modules/legacy/src/epilines.cpp 2013-11-19 21:06:08.000000000 +0100 |
+@@ -46,7 +46,10 @@ |
+ |
+ /* Valery Mosyagin */ |
+ |
++// NaCl likes this preprocessor definition active, to use a struct field. |
++#ifndef __native_client__ |
+ #undef quad |
++#endif //#ifndef __native_client__ |
+ |
+ #define EPS64D 1e-9 |
+ |