I did this just days ago so I’ll try to scribble it down, I’m going from memory alone here so check the spelling on the paths if it won’t work, and it’s not the cleanest install with all the figures in the path, but here you go anyway
First I downloaded the mame4all_pi.zip from the official website
http://mame4all-pi.googlecode.com/git/mame4all_pi.zip
Then I uploaded it to /home/pi/RetroPie/emulators and unzipped it from cli
unzip mame4all_pi.zip
And unzipped the new file
cd mame4all-pi-ea85746014e2
unzip mame4all-pi.zip
Ran the install file to get the folder and cfg files
./install.sh
Uploaded some roms to the roms folder and tried them
./mame (filename without .zip)
Exit with ESC
I edited es_systems.cfg
cd /home/pi/.emulationstation
Sudo nano es_systems.cfg
Where the mame info is, just put # infront of the existing lines to make it easier to switch back, and add the new ones
PATH=/home/pi/RetroPie/emulators/mame4all-pi-ea85746014e2/roms
COMMAND=/home/pi/RetroPie/emulators/mame4all-pi-ea85746014e2/mame %BASENAME%
Started emulationstation
Started a game
Edited the config for the 360 joypad with TAB and selected input general
Added Exit on start+select
Menu on guide button
Exit
And finally lots of gamelist.xml editing to get the cover and description
Done :)