configure.in uses 'unsigned long' (32-bit on 32-bit MIPS) for __sync_* feature test code and assumes 64-bit __sync_* builtins are present too thus breaking the build on pre-R6 32-bit MIPS (which lacks any means for 64-bit atomics implementation).
"sed -i 's/unsigned long/unsigned long long/' configure.in" works as a quick work-around for me however certainly not a proper solution as it apparently forces unnecessary mutex-based re-implementation of 32-bit atomics too. mips32 < r6 is probably not the only platform that suffers from this problem -- sh4, riscv32 should be in the same camp. (apr version is 1.7.0)