configure: error: cannot guess build type; you must specify one

I get

<b>configure: error: cannot guess build type; you must specify one</b>

error a lot of times when I try to install software using apt-get or sometimes when I try to configure and build install software. What are the best practices when I face this issue?

googling is a way to get some reference.