The problem here is -DGLX_GLXEXT_LEGACY; this has been deprecated.
Please remove the line in your mesalib buildlink3.mk file that defines
this and you shouldn't have any problems.
If any other applications' builds are problematic, you can try
defining GLX_GLXEXT_PROTOTYPES instead.
Regards,
--Blair