Fix Makefile rules, add macros and mkdir gen

 /bin/sh: 1: cannot create gen/nqpmojs.pm: Directory nonexistent