Can't this be done by eautoreconf from autotools.eclass?