See also https://git.savannah.gnu.org/cgit/automake.git/commit/?id=4a12201292d9f114549911cf5aaad15e1e5dce3c and https://bugs.gnu.org/46744 linked therein.
On the autoconf side, see http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commit;h=c2ab755698db245898a4cc89149eb5df256e4bd0. Might be done here?