There were plans in a recent copy of make (which is worth getting if you like things of this sort ). This is a slightly more complicated than I think the one in the link Dan posted is, but you could certainly adjust the complication level as desired.