Prolate-spheroidal orbitals for homonuclear and heteronuclear diatomic molecules. I. Basic procedure