Add Android.bp to build U-Boot's mkimage.

This tool is needed to build FIT images for the Beagleboard-X15
platform. As it is not a required host build dependency, we must build
it from sources.

This change introduces a build of the mkimage tool from 2018.07, however
the image signing feature is disabled because it depends on an openssl
API which was removed from boringssl. This would need further changes
upstream to resolve.

A directory containing a large number of symlinks to existing headers is
also provided, as the GNU Make build system was using the "-idirafter"
feature to stop copies of standard C headers like stdint.h, stdlib.h
from being selected from the U-Boot 'include' directory, which is an
unsupported feature in the Android build system.

Bug: 74437007
Change-Id: Idadda650232749d198320b4556a7ba5379a441d0
Signed-off-by: Alistair Strachan <astrachan@google.com>
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..cf80822
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,92 @@
+// Copyright 2018 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// NOTE: image-sig (RSA signature) support is broken because the U-Boot code
+// requires API features from openssl which are not provided by boringssl
+
+cc_binary_host {
+    name: "mkimage",
+
+    cflags: [
+        "-D__KERNEL_STRICT_NAMES",
+        "-D_GNU_SOURCE",
+        "-DMKIMAGE_DTC=\"dtc\"",
+        "-DUSE_HOSTCC",
+        "-Wno-missing-field-initializers",
+        "-Wno-pointer-arith",
+        "-Wno-unused-parameter",
+        "-Wno-visibility",
+        "-include linux/kconfig.h",
+        "-include compiler.h",
+    ],
+
+    srcs: [
+        "common/bootm.c",
+        "common/hash.c",
+        "common/image.c",
+        "common/image-fit.c",
+        "lib/crc32.c",
+        "lib/fdtdec.c",
+        "lib/fdtdec_common.c",
+        "lib/libfdt/fdt_region.c",
+        "lib/libfdt/fdt_ro.c",
+        "lib/md5.c",
+        "lib/rc4.c",
+        "lib/sha1.c",
+        "lib/sha256.c",
+        "tools/aisimage.c",
+        "tools/atmelimage.c",
+        "tools/default_image.c",
+        "tools/fit_common.c",
+        "tools/fit_image.c",
+        "tools/gpimage.c",
+        "tools/gpimage-common.c",
+        "tools/image-host.c",
+        "tools/imagetool.c",
+        "tools/imximage.c",
+        "tools/kwbimage.c",
+        "tools/libfdt/fdt.c",
+        "tools/libfdt/fdt_addresses.c",
+        "tools/libfdt/fdt_empty_tree.c",
+        "tools/libfdt/fdt_overlay.c",
+        "tools/libfdt/fdt_rw.c",
+        "tools/libfdt/fdt_strerror.c",
+        "tools/libfdt/fdt_sw.c",
+        "tools/libfdt/fdt_wip.c",
+        "tools/lpc32xximage.c",
+        "tools/mkimage.c",
+        "tools/mxsimage.c",
+        "tools/omapimage.c",
+        "tools/os_support.c",
+        "tools/pbl_crc32.c",
+        "tools/pblimage.c",
+        "tools/rkcommon.c",
+        "tools/rkimage.c",
+        "tools/rksd.c",
+        "tools/rkspi.c",
+        "tools/socfpgaimage.c",
+        "tools/stm32image.c",
+        "tools/ublimage.c",
+        "tools/vybridimage.c",
+        "tools/zynqimage.c",
+        "tools/zynqmpbif.c",
+        "tools/zynqmpimage.c",
+    ],
+
+    local_include_dirs: [
+        "prebuilt-intermediates",
+        "scripts/dtc/libfdt",
+        "tools",
+    ],
+}
diff --git a/prebuilt-intermediates/bootm.h b/prebuilt-intermediates/bootm.h
new file mode 120000
index 0000000..e045d8c
--- /dev/null
+++ b/prebuilt-intermediates/bootm.h
@@ -0,0 +1 @@
+../include/bootm.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/bootstage.h b/prebuilt-intermediates/bootstage.h
new file mode 120000
index 0000000..e10131e
--- /dev/null
+++ b/prebuilt-intermediates/bootstage.h
@@ -0,0 +1 @@
+../include/bootstage.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/command.h b/prebuilt-intermediates/command.h
new file mode 120000
index 0000000..3d918c0
--- /dev/null
+++ b/prebuilt-intermediates/command.h
@@ -0,0 +1 @@
+../include/command.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/compiler.h b/prebuilt-intermediates/compiler.h
new file mode 120000
index 0000000..715e568
--- /dev/null
+++ b/prebuilt-intermediates/compiler.h
@@ -0,0 +1 @@
+../include/compiler.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/config.h b/prebuilt-intermediates/config.h
new file mode 120000
index 0000000..31c4e5c
--- /dev/null
+++ b/prebuilt-intermediates/config.h
@@ -0,0 +1 @@
+../include/config.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/fdt_support.h b/prebuilt-intermediates/fdt_support.h
new file mode 120000
index 0000000..b515e50
--- /dev/null
+++ b/prebuilt-intermediates/fdt_support.h
@@ -0,0 +1 @@
+../include/fdt_support.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/generated/autoconf.h b/prebuilt-intermediates/generated/autoconf.h
new file mode 100644
index 0000000..710cecc
--- /dev/null
+++ b/prebuilt-intermediates/generated/autoconf.h
@@ -0,0 +1 @@
+/* Empty */
diff --git a/prebuilt-intermediates/generated/timestamp_autogenerated.h b/prebuilt-intermediates/generated/timestamp_autogenerated.h
new file mode 100644
index 0000000..9ce5c78
--- /dev/null
+++ b/prebuilt-intermediates/generated/timestamp_autogenerated.h
@@ -0,0 +1,3 @@
+#define U_BOOT_DATE "Jan 1 2000"
+#define U_BOOT_TIME "00:00:00"
+#define U_BOOT_TZ "0000"
diff --git a/prebuilt-intermediates/generated/version_autogenerated.h b/prebuilt-intermediates/generated/version_autogenerated.h
new file mode 100644
index 0000000..c3c8b18
--- /dev/null
+++ b/prebuilt-intermediates/generated/version_autogenerated.h
@@ -0,0 +1 @@
+#define PLAIN_VERSION "2018.07"
diff --git a/prebuilt-intermediates/hash.h b/prebuilt-intermediates/hash.h
new file mode 120000
index 0000000..3d1f761
--- /dev/null
+++ b/prebuilt-intermediates/hash.h
@@ -0,0 +1 @@
+../include/hash.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/image.h b/prebuilt-intermediates/image.h
new file mode 120000
index 0000000..ff803f7
--- /dev/null
+++ b/prebuilt-intermediates/image.h
@@ -0,0 +1 @@
+../include/image.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/imximage.h b/prebuilt-intermediates/imximage.h
new file mode 120000
index 0000000..85bcd1f
--- /dev/null
+++ b/prebuilt-intermediates/imximage.h
@@ -0,0 +1 @@
+../include/imximage.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/linker_lists.h b/prebuilt-intermediates/linker_lists.h
new file mode 120000
index 0000000..fadc1cf
--- /dev/null
+++ b/prebuilt-intermediates/linker_lists.h
@@ -0,0 +1 @@
+../include/linker_lists.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/linux/compiler-clang.h b/prebuilt-intermediates/linux/compiler-clang.h
new file mode 120000
index 0000000..c5b66b4
--- /dev/null
+++ b/prebuilt-intermediates/linux/compiler-clang.h
@@ -0,0 +1 @@
+../../include/linux/compiler-clang.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/linux/compiler.h b/prebuilt-intermediates/linux/compiler.h
new file mode 120000
index 0000000..e1089ac
--- /dev/null
+++ b/prebuilt-intermediates/linux/compiler.h
@@ -0,0 +1 @@
+../../include/linux/compiler.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/linux/kconfig.h b/prebuilt-intermediates/linux/kconfig.h
new file mode 120000
index 0000000..0acd2ec
--- /dev/null
+++ b/prebuilt-intermediates/linux/kconfig.h
@@ -0,0 +1 @@
+../../include/linux/kconfig.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/linux/libfdt.h b/prebuilt-intermediates/linux/libfdt.h
new file mode 120000
index 0000000..fb14cd34
--- /dev/null
+++ b/prebuilt-intermediates/linux/libfdt.h
@@ -0,0 +1 @@
+../../include/linux/libfdt.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/linux/libfdt_env.h b/prebuilt-intermediates/linux/libfdt_env.h
new file mode 120000
index 0000000..9070c9d
--- /dev/null
+++ b/prebuilt-intermediates/linux/libfdt_env.h
@@ -0,0 +1 @@
+../../include/linux/libfdt_env.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/rc4.h b/prebuilt-intermediates/rc4.h
new file mode 120000
index 0000000..976089d
--- /dev/null
+++ b/prebuilt-intermediates/rc4.h
@@ -0,0 +1 @@
+../include/rc4.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/tee b/prebuilt-intermediates/tee
new file mode 120000
index 0000000..7212bf0
--- /dev/null
+++ b/prebuilt-intermediates/tee
@@ -0,0 +1 @@
+../include/tee
\ No newline at end of file
diff --git a/prebuilt-intermediates/timestamp.h b/prebuilt-intermediates/timestamp.h
new file mode 120000
index 0000000..ea7a630
--- /dev/null
+++ b/prebuilt-intermediates/timestamp.h
@@ -0,0 +1 @@
+../include/timestamp.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/u-boot b/prebuilt-intermediates/u-boot
new file mode 120000
index 0000000..0d1a07f
--- /dev/null
+++ b/prebuilt-intermediates/u-boot
@@ -0,0 +1 @@
+../include/u-boot
\ No newline at end of file
diff --git a/prebuilt-intermediates/version.h b/prebuilt-intermediates/version.h
new file mode 120000
index 0000000..bb57607
--- /dev/null
+++ b/prebuilt-intermediates/version.h
@@ -0,0 +1 @@
+../include/version.h
\ No newline at end of file
diff --git a/prebuilt-intermediates/watchdog.h b/prebuilt-intermediates/watchdog.h
new file mode 120000
index 0000000..d214f99
--- /dev/null
+++ b/prebuilt-intermediates/watchdog.h
@@ -0,0 +1 @@
+../include/watchdog.h
\ No newline at end of file