General determination of phases in quark mass matrices