 Detect and subst all needed Android and iOS INCLUDES/LIBS in configure.ac, and
 do Android-specific quirks
 ---
- configure.ac    | 47 ++++++++++++++++++++++++++++++++++++++++-------
+ configure.ac    | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
  owr/Makefile.am |  3 ++-
- 2 files changed, 42 insertions(+), 8 deletions(-)
+ 2 files changed, 60 insertions(+), 8 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
-index 992540e..a603ce6 100644
+index 992540e..0a5bed3 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -84,9 +84,15 @@ dnl pick dependencies and build flags based on OS
+@@ -84,9 +84,33 @@ dnl pick dependencies and build flags based on OS
  case "$host_os" in
    darwin*)
      is_apple=yes
 -    OWR_DEVICE_LIST_EXT_LIBS="-framework AVFoundation"
-+    OWR_DEVICE_LIST_EXT_LIBS="-framework AssetsLibrary -framework CoreMedia
-+      -framework CoreVideo -framework AVFoundation -framework Foundation
-+      -framework OpenGLES -framework CoreAudio -framework AudioToolbox
-+      -weak_framework VideoToolbox -lc++ "
++    AC_CHECK_HEADER(AVFoundation/AVFoundation.h, ,
++                    AC_MSG_ERROR(AVFoundation is needed while building for OS X or iOS),
++                    [-])
++    AC_CHECK_HEADER(MobileCoreServices/MobileCoreServices.h, is_ios="yes",
++                    is_ios="no", [-])
++    if test "x$is_ios" == "xno"; then
++      dnl OS X frameworks
++      OWR_DEVICE_LIST_EXT_LIBS="-framework AVFoundation "
++    else
++      dnl iOS frameworks
++      m4_foreach([check_header],
++                 [[AssetsLibrary/AssetsLibrary.h], [CoreMedia/CoreMedia.h],
++                  [CoreVideo/CoreVideo.h], [OpenGLES/ES2/gl.h],
++                  [CoreAudio/CoreAudio.h], [AudioToolbox/AudioToolbox.h]],
++                 AC_CHECK_HEADER($check_header, ,
++                                 AC_MSG_ERROR($check_header is needed while building for iOS),
++                                 [-]))
++      OWR_DEVICE_LIST_EXT_LIBS="-framework AssetsLibrary -framework CoreMedia \
++        -framework CoreVideo -framework AVFoundation -framework Foundation \
++        -framework OpenGLES -framework CoreAudio -framework AudioToolbox \
++        -weak_framework VideoToolbox -lc++ "
++    fi
      ;;
    linux-android*)
 +    is_android=yes

   fi
   case "$target" in
     i?86-*|x86_64-*)
@@ -201,6 +210,30 @@ if test "x$enable_owr_java" = xyes; then
 fi
 AC_SUBST(ANDROID_NDK_PREFIX)
 

   if test "x$enable_shared" != xyes; then
     AC_MSG_ERROR([--enable-owr-java needs --enabled-shared])
   fi
@@ -156,7 +183,7 @@ AC_ARG_WITH(android-sdk,
             androidsdkdir=${withval}, androidsdkdir=)
 if test "x$enable_owr_java" = xyes; then
   AC_MSG_CHECKING([for android.jar])
