Best way to do this is to compile a 'tiny build', which only lets you include the drivers you're interested in.

https://docs.mamedev.org/initialsetup/compilingmame.html