This patch applies several changes that enable OpenSSL 1.1.0g to be built
for Android using either Clang or GCC toolchains.

diff -Naur org/Configurations/10-main.conf mod/Configurations/10-main.conf
--- org/Configurations/10-main.conf	2017-11-02 07:29:01.000000000 -0700
+++ mod/Configurations/10-main.conf	2018-01-18 10:59:41.675138500 -0800
@@ -910,15 +910,27 @@
         # systems are perfectly capable of executing binaries targeting
         # Froyo. Keep in mind that in the nutshell Android builds are
         # about JNI, i.e. shared libraries, not applications.
-        cflags           => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
+        cflags           => add(picker(default => "-mandroid -fPIC --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wa,--noexecstack")),
         bin_cflags       => "-pie",
     },
+    "android-clang" => {
+        inherit_from     => [ "linux-generic32" ],
+        cc               => "clang",
+        cflags           => add(picker(default => "-fPIC --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Qunused-arguments -Wa,--noexecstack")),
+},
     "android-x86" => {
         inherit_from     => [ "android", asm("x86_asm") ],
         cflags           => add(picker(release => "-fomit-frame-pointer")),
         bn_ops           => "BN_LLONG",
         perlasm_scheme   => "android",
     },
+    "android-x86-clang" => {
+        inherit_from     => [ "android-clang", asm("x86_asm") ],
+        cflags           => add(picker(default => "-target i686-none-linux-android",
+                                       release => "-fomit-frame-pointer")),
+        bn_ops           => "BN_LLONG",
+        perlasm_scheme   => "android",
+    },
     ################################################################
     # Contemporary Android applications can provide multiple JNI
     # providers in .apk, targeting multiple architectures. Among
@@ -943,20 +955,38 @@
     "android-armeabi" => {
         inherit_from     => [ "android", asm("armv4_asm") ],
     },
+    "android-armeabi-clang" => {
+        inherit_from     => [ "android-clang", asm("armv4_asm") ],
+        cflags           => add("-target armv7-none-linux-androideabi"),
+    },
     "android-mips" => {
         inherit_from     => [ "android", asm("mips32_asm") ],
         perlasm_scheme   => "o32",
     },
-
+    "android-mips-clang" => {
+        inherit_from     => [ "android-clang", asm("mips32_asm") ],
+        cflags           => add("-target mipsel-none-linux-android"),
+        perlasm_scheme   => "o32",
+    },
     "android64" => {
         inherit_from     => [ "linux-generic64" ],
-        cflags           => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
+        cflags           => add(picker(default => "-mandroid -fPIC --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wa,--noexecstack")),
         bin_cflags       => "-pie",
     },
+    "android64-clang" => {
+        inherit_from     => [ "linux-generic64" ],
+        cc               => "clang",
+        cflags           => add(picker(default => "-fPIC --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Qunused-arguments -Wa,--noexecstack")),
+    },
     "android64-aarch64" => {
         inherit_from     => [ "android64", asm("aarch64_asm") ],
         perlasm_scheme   => "linux64",
     },
+    "android64-aarch64-clang" => {
+        inherit_from     => [ "android64-clang", asm("aarch64_asm") ],
+        cflags           => add("-target aarch64-none-linux-android"),
+        perlasm_scheme   => "linux64",
+    },
 
 #### *BSD
     "BSD-generic32" => {
