Index: pjproject/trunk/configure-android
===================================================================
--- pjproject/trunk/configure-android	(revision 5619)
+++ pjproject/trunk/configure-android	(revision 5620)
@@ -27,5 +27,5 @@
   echo "                   Each grepped flag that satisfies the criteria will"
   echo "                   be ignored. Default:"
-  echo "                   IGNORE_CFLAGS=\"\-M\|\-f*stack\|\-f*alias\""
+  echo "                   IGNORE_CFLAGS=\"\-M\|\-f*stack\|\-f*alias\|\-\<g\>\""
   echo "                   Only used when --use-ndk-cflags is specified."
   echo ""
@@ -59,6 +59,8 @@
   shift
   ADD_CFLAGS="1"
+  ADD_NDK_TOOLCHAIN="0"
+  ADD_NDK_TARGET="0"
   if test "x${IGNORE_CFLAGS}" = "x"; then
-    IGNORE_CFLAGS="\-M\|\-f*stack\|\-f*alias"
+    IGNORE_CFLAGS="\-M\|\-f*stack\|\-f*alias\|\-\<g\>"
   fi
   
@@ -74,4 +76,8 @@
     exit 1
   fi
+
+  echo "====="
+  echo "NDK_OUT : ${NDK_OUT}"
+  echo "====="
 
   for i in $NDK_OUT; do
@@ -85,17 +91,28 @@
       NDK_CXXFLAGS="${NDK_CXXFLAGS} $i"
     fi
-
     # Parse NDK CFLAGS
     if test "x${NDK_CC}" != "x" -a "x`echo $i|grep 'dummy'`" = "x" -a "${ADD_CFLAGS}" = "1"; then
       if test "$i" = "-c"; then ADD_CFLAGS="0"; else
         if test "x`echo $i|grep ${IGNORE_CFLAGS}`" = "x"; then
+          if test "${ADD_NDK_TOOLCHAIN}" = "0" -a "x`echo $i|grep '\-gcc-toolchain'`" != "x"; then
+            ADD_NDK_TOOLCHAIN="1"
+          elif test "${ADD_NDK_TARGET}" = "0" -a "x`echo $i|grep '\-target'`" != "x"; then          
+            ADD_NDK_TARGET="1"
+          elif test "${ADD_NDK_TOOLCHAIN}" = "1"; then
+            NDK_TOOLCHAIN="$i"
+            ADD_NDK_TOOLCHAIN="2"
+          elif test "${ADD_NDK_TARGET}" = "1"; then
+            NDK_TARGET="$i"
+            ADD_NDK_TARGET="2"
+          fi
           NDK_CFLAGS="${NDK_CFLAGS} $i"
         fi
       fi
     fi
-
-    # Find gcc toolchain
-    if test "x${NDK_CC}" = "x" -a "x`echo $i | grep 'gcc'`" != "x"; then
-      NDK_CC=$i
+    # Find gcc or clang toolchain
+    if test "x${NDK_CC}" = "x"; then
+      if test "x`echo $i | grep 'gcc'`" != "x" -o "x`echo $i | grep 'clang'`" != "x"; then
+        NDK_CC=$i
+      fi
     fi
     # Find g++ toolchain
@@ -104,4 +121,6 @@
     fi
   done
+
+  echo "NDK_CC : ${NDK_CC}"
 
   # Get target host from NDK toolchain dir name
@@ -117,11 +136,20 @@
   fi
 
+  # Set the binutils
+  if test "x${NDK_TOOLCHAIN}" = "x"; then
+    export AR=`echo ${NDK_CXX}|sed 's/-g++/-ar/'`;
+    export RANLIB=`echo ${NDK_CXX}|sed 's/-g++/-ranlib/'`;
+    export LDFLAGS="${LDFLAGS} --sysroot=${ANDROID_SYSROOT}"
+  else
+    #export AR="${NDK_TOOLCHAIN}/bin/${NDK_TARGET}-ar"
+    #export RANLIB="${NDK_TOOLCHAIN}/bin/${NDK_TARGET}-ranlib"
+    TARGET_HOST="arm-linux-androideabi"
+    export LDFLAGS="${LDFLAGS} --sysroot=${ANDROID_SYSROOT} -target ${NDK_TARGET} -gcc-toolchain ${NDK_TOOLCHAIN}"
+  fi  
+
   export TARGET_ABI="${TARGET_ABI}"
   export CC="${NDK_CC}"
   export CXX="${NDK_CXX}"
-  export AR=`echo ${NDK_CXX}|sed 's/-g++/-ar/'`;
-  export RANLIB=`echo ${NDK_CXX}|sed 's/-g++/-ranlib/'`;
-
-  export LDFLAGS="${LDFLAGS} --sysroot=${ANDROID_SYSROOT}"
+
   export LIBS="${LIBS} -lc -lgcc -ldl"
   export CFLAGS="${NDK_CFLAGS} ${CFLAGS}"
@@ -173,9 +201,17 @@
 # Note: STL for pjsua2 sample app is specified in pjsip-apps/src/swig/java/android/jni/Application.mk
 
-# gnustl
-STDCPP_TC_VER=`ls -d ${ANDROID_NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/[0-9]* | sort -gr | head -1`
-STDCPP_CFLAGS="-I${STDCPP_TC_VER}/include -I${STDCPP_TC_VER}/libs/${TARGET_ABI}/include"
-STDCPP_LIBS="-lgnustl_static"
-STDCPP_LDFLAGS="-L${STDCPP_TC_VER}/libs/${TARGET_ABI}/"
+if test "x${NDK_TOOLCHAIN}" = "x"; then
+  # gnustl
+  STDCPP_TC_VER=`ls -d ${ANDROID_NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/[0-9]* | sort -gr | head -1`
+  STDCPP_CFLAGS="-I${STDCPP_TC_VER}/include -I${STDCPP_TC_VER}/libs/${TARGET_ABI}/include"
+  STDCPP_LIBS="-lgnustl_static"
+  STDCPP_LDFLAGS="-L${STDCPP_TC_VER}/libs/${TARGET_ABI}/"
+else
+  # llvm
+  STDCPP_TC="${ANDROID_NDK_ROOT}/sources/cxx-stl/llvm-libc++"
+  STDCPP_CFLAGS="-I${STDCPP_TC}/include"
+  STDCPP_LIBS="-lc++_static -lc++abi"
+  STDCPP_LDFLAGS="-L${STDCPP_TC}/libs/${TARGET_ABI}/"
+fi
 
 # stlport
Index: pjproject/trunk/pjsip-apps/build/Samples.mak
===================================================================
--- pjproject/trunk/pjsip-apps/build/Samples.mak	(revision 5619)
+++ pjproject/trunk/pjsip-apps/build/Samples.mak	(revision 5620)
@@ -51,6 +51,8 @@
 PJSUA2_SAMPLES := pjsua2_demo
 
+ifeq ($(findstring android,$(TARGET_NAME)),)
 EXES := $(foreach file, $(SAMPLES), $(file)$(HOST_EXE))
 PJSUA2_EXES := $(foreach file, $(PJSUA2_SAMPLES), $(file)$(HOST_EXE))
+endif
 
 .PHONY: $(EXES)
