Use configure file

Just like #1990 but more tidy