summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/opkbuild.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/opkbuild.sh b/src/opkbuild.sh
index efec272..4915787 100644
--- a/src/opkbuild.sh
+++ b/src/opkbuild.sh
@@ -185,6 +185,35 @@ ${OH_HOST_ARCH_DIST}
EOF
export OH_HOST_ARCH_CPU OH_HOST_ARCH_KERNEL OH_HOST_ARCH_LIBS
+# Look up GNU architecture name and set toolchain environment variables.
+if [ ! -f "@@DATADIR@@/opkhelper/archtab" ]; then
+ printf 'opkbuild: Error: architecture table not found.\n' >&2
+ exit 1
+fi
+export OH_HOST_ARCH_GNU="$(sed -n \
+ "s/^${OH_HOST_ARCH_DIST}[ \\t][ \\t]*\\(.*\\)$/\\1/p" \
+ "@@DATADIR@@/opkhelper/archtab")"
+if [ -z "${OH_HOST_ARCH_GNU}" ]; then
+ printf 'opkbuild: Error: "%s" not found in architecture table.\n' \
+ "${OH_HOST_ARCH_DIST}" >&2
+ exit 1
+fi
+# NB: This is written for GNU Binutils and GCC and won't work for, e.g., LLVM.
+export AR="${OH_HOST_ARCH_GNU}-ar"
+export AS="${OH_HOST_ARCH_GNU}-as"
+export CC="${OH_HOST_ARCH_GNU}-gcc"
+export CPP="${OH_HOST_ARCH_GNU}-cpp"
+export CXX="${OH_HOST_ARCH_GNU}-g++"
+export LD="${OH_HOST_ARCH_GNU}-ld"
+export NM="${OH_HOST_ARCH_GNU}-nm"
+export OBJCOPY="${OH_HOST_ARCH_GNU}-objcopy"
+export OBJDUMP="${OH_HOST_ARCH_GNU}-objdump"
+export RANLIB="${OH_HOST_ARCH_GNU}-ranlib"
+export READELF="${OH_HOST_ARCH_GNU}-readelf"
+export SIZE="${OH_HOST_ARCH_GNU}-size"
+export STRINGS="${OH_HOST_ARCH_GNU}-strings"
+export STRIP="${OH_HOST_ARCH_GNU}-strip"
+
# Set build flags.
if [ -f "@@DATADIR@@/opkhelper/buildflags/${OH_HOST_ARCH_CPU}" ]; then
. @@DATADIR@@/opkhelper/buildflags/${OH_HOST_ARCH_CPU}