Index: modules/highgui/CMakeLists.txt
===================================================================
--- modules/highgui/CMakeLists.txt	(revision 3454)
+++ modules/highgui/CMakeLists.txt	(working copy)
@@ -1,3 +1,21 @@
+if(ANDROID)
+
+set(high_gui_android_srcs src/bitstrm.cpp
+    src/cap.cpp 
+    src/grfmt_base.cpp 
+    src/grfmt_bmp.cpp 
+    src/grfmt_jpeg.cpp 
+    src/grfmt_png.cpp 
+    src/grfmt_tiff.cpp 
+    src/loadsave.cpp 
+    src/precomp.cpp 
+    src/utils.cpp 
+    src/grfmt_sunras.cpp 
+    src/grfmt_pxm.cpp 
+    src/window.cpp )
+define_android_manual(highgui "${high_gui_android_srcs}" "$(OpenCVInclude) $(LOCAL_PATH)/include")	
+
+else()
 # ----------------------------------------------------------------------------
 #  CMake file for highgui. See root CMakeLists.txt
 #   Some parts taken from version of Hartmut Seichter, HIT Lab NZ.
@@ -332,3 +350,5 @@
 install(FILES ${highgui_ext_hdrs}
         DESTINATION include/opencv2/highgui
         COMPONENT main)
+        
+endif()#android
Index: modules/features2d/src/sift.cpp
===================================================================
--- modules/features2d/src/sift.cpp	(revision 3454)
+++ modules/features2d/src/sift.cpp	(working copy)
@@ -172,6 +172,7 @@
   typedef Keypoints::iterator       KeypointsIter ;      ///< Keypoint list iter datatype
   typedef Keypoints::const_iterator KeypointsConstIter ; ///< Keypoint list const iter datatype
 
+#undef _S
   /** @brief Constructors and destructors */
   /*@{*/
   Sift(const pixel_t* _im_pt, int _width, int _height,
Index: modules/features2d/CMakeLists.txt
===================================================================
--- modules/features2d/CMakeLists.txt	(revision 3454)
+++ modules/features2d/CMakeLists.txt	(working copy)
@@ -1 +1,2 @@
-define_opencv_module(features2d opencv_core opencv_imgproc opencv_calib3d opencv_highgui)
\ No newline at end of file
+define_opencv_module(features2d opencv_core opencv_imgproc opencv_calib3d opencv_highgui)
+
Index: modules/CMakeLists.txt
===================================================================
--- modules/CMakeLists.txt	(revision 3454)
+++ modules/CMakeLists.txt	(working copy)
@@ -1,3 +1,7 @@
+if(ANDROID)
+ configure_file("${CMAKE_SOURCE_DIR}/Android.mk.modules.in" "${CMAKE_CURRENT_BINARY_DIR}/Android.mk")
+endif()
+
 add_subdirectory(calib3d)
 add_subdirectory(core)
 add_subdirectory(features2d)
@@ -20,8 +24,11 @@
 endif()
 
 add_subdirectory(video)
+
+if(!ANDROID)
 add_subdirectory(haartraining)
 add_subdirectory(traincascade)
+endif()
 
 
 #add_subdirectory(gpu)
Index: 3rdparty/zlib/CMakeLists.txt
===================================================================
--- 3rdparty/zlib/CMakeLists.txt	(revision 3454)
+++ 3rdparty/zlib/CMakeLists.txt	(working copy)
@@ -1,3 +1,7 @@
+if(ANDROID)
+define_3rdparty_module(zlib)
+else()
+
 # ----------------------------------------------------------------------------
 #  CMake file for zlib. See root CMakeLists.txt
 #
@@ -35,3 +39,5 @@
         DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
         ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/3rdparty/lib"
     )
+    
+endif()
Index: 3rdparty/lapack/CMakeLists.txt
===================================================================
--- 3rdparty/lapack/CMakeLists.txt	(revision 3454)
+++ 3rdparty/lapack/CMakeLists.txt	(working copy)
@@ -2,6 +2,10 @@
 #  CMake file for opencv_lapack. See root CMakeLists.txt
 #
 # ----------------------------------------------------------------------------
+if(ANDROID)
+define_3rdparty_module(opencv_lapack)
+else()
+
 project(opencv_lapack)
 
 # List of C++ files:
@@ -57,3 +61,4 @@
 	DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
 	ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty/lib
 	)
+endif() #android
Index: 3rdparty/libjasper/CMakeLists.txt
===================================================================
--- 3rdparty/libjasper/CMakeLists.txt	(revision 3454)
+++ 3rdparty/libjasper/CMakeLists.txt	(working copy)
@@ -1,3 +1,8 @@
+if(ANDROID)
+define_3rdparty_module(jasper)
+else()
+
+
 # ----------------------------------------------------------------------------
 #  CMake file for libjasper. See root CMakeLists.txt
 #
@@ -4,6 +9,7 @@
 # ----------------------------------------------------------------------------
 project(libjasper)
 
+
 add_definitions(-DEXCLUDE_MIF_SUPPORT -DEXCLUDE_PNM_SUPPORT -DEXCLUDE_BMP_SUPPORT -DEXCLUDE_RAS_SUPPORT  -DEXCLUDE_JPG_SUPPORT -DEXCLUDE_PGX_SUPPORT)
 
 # List of C++ files:
@@ -41,6 +47,8 @@
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration -Wno-unused")
 endif()
 
+endif()#!android
+
 set_target_properties(${the_target}
 	PROPERTIES
 	OUTPUT_NAME "${the_target}"
Index: 3rdparty/libpng/CMakeLists.txt
===================================================================
--- 3rdparty/libpng/CMakeLists.txt	(revision 3454)
+++ 3rdparty/libpng/CMakeLists.txt	(working copy)
@@ -1,3 +1,7 @@
+if(ANDROID)
+define_3rdparty_module(png)
+else()
+#endif()#android
 # ----------------------------------------------------------------------------
 #  CMake file for libpng. See root CMakeLists.txt
 #
@@ -38,3 +42,4 @@
 	DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
 	ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/3rdparty/lib"
 	)
+endif()#android
Index: 3rdparty/libjpeg/CMakeLists.txt
===================================================================
--- 3rdparty/libjpeg/CMakeLists.txt	(revision 3454)
+++ 3rdparty/libjpeg/CMakeLists.txt	(working copy)
@@ -1,3 +1,7 @@
+if(ANDROID)
+define_3rdparty_module(jpeg)
+else()
+#endif()#android
 # ----------------------------------------------------------------------------
 #  CMake file for libjpeg. See root CMakeLists.txt
 #
@@ -39,3 +43,4 @@
 	DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
 	ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty/lib
 	)
+endif()#android
Index: 3rdparty/CMakeLists.txt
===================================================================
--- 3rdparty/CMakeLists.txt	(revision 3454)
+++ 3rdparty/CMakeLists.txt	(working copy)
@@ -1,3 +1,10 @@
+if(ANDROID)
+ configure_file("${CMAKE_SOURCE_DIR}/Android.mk.modules.in" "${CMAKE_CURRENT_BINARY_DIR}/Android.mk")
+ 	add_subdirectory(libpng)
+ 	add_subdirectory(libjpeg)
+ 	add_subdirectory(libjasper)
+endif()
+
 add_subdirectory(flann)
 add_subdirectory(lapack)
 add_subdirectory(zlib)
Index: 3rdparty/flann/CMakeLists.txt
===================================================================
--- 3rdparty/flann/CMakeLists.txt	(revision 3454)
+++ 3rdparty/flann/CMakeLists.txt	(working copy)
@@ -1,3 +1,7 @@
+if(ANDROID)
+file(GLOB_RECURSE flann_sources_cpp *.cpp)
+define_android_manual(flann "${flann_sources_cpp}" "$(LOCAL_PATH)/../include $(LOCAL_PATH)/../include/flann $(LOCAL_PATH)/nn $(LOCAL_PATH)/algorithms $(LOCAL_PATH)/util")		
+else()
 if (DEFINED OPENCV_VERSION)
 
 # ----------------------------------------------------------------------------
@@ -105,3 +109,4 @@
 )
 
 ENDIF()
+endif()#android
