I tried compiling mame from git but early on in the process I get this:
d:/dev/msys64/home/mforan/Emulators/mame/scripts/genie.lua:558: File definition for TARGET=mame SUBTARGET=mame does not exist
stack traceback:
        [C]: in function 'error'
        d:/dev/msys64/home/mfora/Emulators/mame/scripts/genie.lua:558: in main chunk
        [C]: in upvalue 'builtin_dofile'
        [string "premake = { }..."]:109: in function 'dofile'
        [string "_WORKING_DIR        = os.getcwd()..."]:46: in function '_premake_main'
make: *** [makefile:1105: build/projects/windows/mame/gmake-mingw64-gcc/Makefile] Error 1
make: *** Waiting for unfinished jobs....

I used the following commandline:
make -r -j7 NOWERROR=1 avx2=1 TOOLS=1 ARCHOPTS=-march=native

Any ideas?