Nowadays building a port is like using a CPU without protected mode. Poor auto-configuration scripts can wreak havoc on your system, not to mention producing unusable executables and a host of other problems. There are ways to tame builds, this page discusses some of them.
Ideally, a package should specify its exact dependencies in a portable way. No matter if something is considered ubiquitous or present in the base of initially targeted operating system, it should be clear that it's needed at build-time or compile-time (or finer-grained stages). The problem is many packages attempt to autodetect what's present in the system they are built on and adjust themselves to the environment. The bottom line is, it's not clear if the same thing will be built on two different systems, even if they only differ in one installed library.
There are solutions to this problem. A package can be built in a specially prepared environment, in a chroot jail, where the only things present are the ones explicitly specified in its dependency list.