Rooting is adding a file (su) to the system folder - the rest (busybox, a superuser app) is actually optional (although they're always added). That's it. It's done to the ROM that's currently in the phone.
What you're talking about is flashing a new ROM - even if it's the stock M* ROM) that's already been rooted.
Save yourself a lot of time, effore and possibly bricking the phone. Go to the
AT&T M8 section on XDA and see what's available to just root the version of Android you have in that phone. At worst, it's probably a 5 minute process.