The probe is what you want..
There is a sample g-code program showing how to set tool lengths.
http://cvs.linuxcnc.org/cvs/emc2/nc_...ngth-probe.ngc
I have used this for making circuit boards. Once the first tool length is known - the rest are referenced from that.
(I use a microswitch)
sam