Uh.....which M5 engine? Any S38 other than a B38 isn't worth putting into the car unless it's free, the S62 is a piece, and the S85....well, that'd be a first.
Either way, it requires replacement of practically everything in the driveline, brake work, and other such things. Much smarter to just by an M5.
best, whit