How to you determine the architecture (32 vs 64) in a build script for Android?

I’m adding in 64-bit android support to the script but it always chokes if I try to let toolchain figure it out. If I just specify both libs, the 32 builds fine, the 64 chokes with “wrong architecture”. Specifying just the 64 by itself builds fine in 64…