Here's a neat little bash function that might help, pinched it from a Gentoo ebuild I was reading over the other day so I'm not 100% sure if uname -m returns the real machine arch or the arch the kernel was built for but it's gotta be a start.
Code:
guess_arch() {
local x
local host=$(echo "${CTARGET%%-*}" | sed -e 's/i.86/i386/' \
-e 's/sun4u/sparc64/' \
-e 's/arm.*/arm/' \
-e 's/sa110/arm/' \
-e 's/powerpc/ppc/')
# Sort reverse so that we will get ppc64 before ppc, etc
for x in $(ls -1 "${S}/include/arch/" | sort -r) ; do
if [[ ${host} == "${x}" ]] ; then
echo "${x}"
return 0
fi
done
return 1
}