Refactor and fix fdm build. Moved makeFlags definition because non-builderDefs packages cannot use $out in direct variable definitions like makeFlags.