lib/replace: Improve mkstemp test in autoconf and waf