configure: use test in a portable way

(based on commit c13e73271b77ffc298815e7fee8b22d0750c689e)