Anytime I got the megadriv.c error recently, I found that running make without any -j flag allowed me to complete compile. Not sure why, though.