summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/opkbuild10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/opkbuild b/src/opkbuild
index d41d5bd..d85a0ad 100644
--- a/src/opkbuild
+++ b/src/opkbuild
@@ -103,6 +103,15 @@ elif [ -z "${platform}" ]; then
# ... and there are config files and one installable platform, build for it.
fi
+# Attempt to detect the target architecture tuple.
+# NB: Currently cross-compiling is not supported.
+arch=$(opkg print-architecture | grep -E '^arch [^ -]+(-[^ -]+){3} [0-9]+$')
+if [ -z "${arch}" ]; then
+ printf 'opkbuild: Error: No installable architecture found\n' >&2
+elif [ $(echo "${arch}" | wc -l) -gt 1 ]; then
+ printf 'opkbuild: Error: Multiple installable architectures found\n' >&2
+fi
+
# Make work area.
printf 'opkbuild: Making work area...\n'
mkdir tmp
@@ -115,6 +124,7 @@ version=$(oh_get_field Version)
# Set environment variables for the build configuration.
export OH_PLATFORM="${platform}"
+export OH_ARCH="${arch}"
export OH_SRCPKG="${srcpkg}"
export OH_PKGVER="${version%'-'*}"
export OH_PKGREV="${version#*'-'}"