Upgrade bc to 5.0.1

(This lets us remove the macOS fortify workaround and the
BC_ENABLE_LIBRARY workaround that were part of the 5.0.0 upgrade. I've
also removed a couple of obsolete -D lines that were pointed out by the
upstream maintainer when he helped with the 5.0.0 upgrade; he got 5.0.1
out quicker than I could clean those up separately!)

Test: make
Change-Id: I02ee4e41d62e9430386c1690e5200f356e5c21f1
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..7d7afe2
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,92 @@
+package {
+    default_applicable_licenses: ["external_bc_license"],
+}
+
+license {
+    name: "external_bc_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-MIT",
+    ],
+    license_text: [
+        "LICENSE.md",
+        "NOTICE.md",
+    ],
+}
+
+cc_defaults {
+  name: "bc-defaults",
+
+  cflags: [
+    "-include bc-version.h",
+    "-DBC_ENABLED=1",
+    "-DDC_ENABLED=0",
+    "-DBC_ENABLE_EXTRA_MATH=0",
+    "-DBC_ENABLE_HISTORY=0",
+    "-DBC_ENABLE_NLS=0",
+    "-Os",
+  ],
+  generated_headers: ["bc-version.h"],
+  local_include_dirs: ["include"],
+  srcs: [
+    "src/bc/*.c",
+    "src/*.c",
+    ":bc-bc_help.c",
+    ":bc-lib.c",
+  ],
+  stl: "none",
+}
+
+genrule {
+  name: "bc-lib.c",
+  srcs: ["gen/lib.bc"],
+  out: ["gen/lib.c"],
+  tool_files: ["gen/strgen.sh"],
+  cmd: "$(location gen/strgen.sh) $(in) $(out) bc_lib bc_lib_name BC_ENABLED",
+}
+
+genrule {
+  name: "bc-bc_help.c",
+  srcs: ["gen/bc_help.txt"],
+  out: ["gen/bc_help.c"],
+  tool_files: ["gen/strgen.sh"],
+  cmd: "$(location gen/strgen.sh) $(in) $(out) bc_help '' BC_ENABLED",
+}
+
+genrule {
+  name: "bc-version.h",
+  srcs: ["Makefile.in"],
+  out: ["bc-version.h"],
+  cmd: "sed -n 's/VERSION = /#define VERSION /p' $(in) > $(out)",
+}
+
+cc_binary {
+  name: "bc",
+  defaults: ["bc-defaults"],
+}
+
+cc_binary {
+  name: "bc_vendor",
+  defaults: ["bc-defaults"],
+  stem: "bc",
+  vendor: true,
+}
+
+cc_binary_host {
+  name: "gavinhoward-bc",
+  defaults: ["bc-defaults"],
+}
+
+sh_test {
+  name: "bc-tests",
+  src: "run-bc-tests-on-android.sh",
+  filename: "run-bc-tests-on-android.sh",
+  test_suites: ["general-tests"],
+  host_supported: true,
+  device_supported: false,
+  data: [
+    "scripts/functions.sh",
+    "tests/**/*",
+  ],
+}
diff --git a/LICENSE b/LICENSE
new file mode 120000
index 0000000..f0c4298
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1 @@
+LICENSE.md
\ No newline at end of file
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..8c23596
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,15 @@
+name: "gavinhoward/bc"
+description: "An implementation of the POSIX bc calculator with GNU extensions and dc."
+third_party {
+  url {
+    type: GIT
+    value: "https://github.com/gavinhoward/bc"
+  }
+  version: "5.0.1"
+  license_type: NOTICE
+  last_upgrade_date {
+    year: 2021
+    month: 8
+    day: 13
+  }
+}
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..7529cb9
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+include platform/system/core:/janitors/OWNERS
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..c05ac95
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+  "presubmit": [
+    {
+      "name": "bc-tests"
+    }
+  ]
+}
diff --git a/run-bc-tests-on-android.sh b/run-bc-tests-on-android.sh
new file mode 100755
index 0000000..10170bf
--- /dev/null
+++ b/run-bc-tests-on-android.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Copy the tests across.
+adb shell rm -rf /data/local/tmp/bc-tests/
+adb shell mkdir /data/local/tmp/bc-tests/
+adb shell mkdir /data/local/tmp/bc-tests/scripts/
+adb push tests/ /data/local/tmp/bc-tests/
+adb push scripts/functions.sh /data/local/tmp/bc-tests/scripts/
+
+if tty -s; then
+  dash_t="-t"
+else
+  dash_t=""
+fi
+
+exec adb shell $dash_t /data/local/tmp/bc-tests/tests/all.sh bc 0 1 0 0 bc