I should have done this a long time ago, but I finally got smart and uploaded my CNC firmware to github so you can download it directly rather than having to recreate my modifications on your own. For every file that I have modified, I included the original file next to it. That way you can see just what I have changed easily without needing to pull the original version of the files.
There are two different repositories. One is my last version of my grbl build for the uno and cnc shield. This assumes you have a new protoneer shield or have modified the chinese shields to be compatible with the latest release. There is not much changed in this version, it is probably best to look at the changes and then work out for yourself if they fit your setup.
The other setup is my new grbl-mega-5x port for the mks gen l v2.1 board. This is a more extensive modification. I had to reroute several pins so I could use the thermistor inputs for buttons, as well as turning the negative y limit switch to an 'a' axis limit switch and moving the probe pin to the negative z limit switch. Finally I have modified it to support auto homing and a 4th axis rotary attachment and of course configured it all to work with my machine.
Again these changes are very machine specific, so I recommend looking at them closely to make sure it matches your machine. However it is complicated enough that I don't feel a line by line writeup would be enough to get you going, hence the repository.