Add build matrix generation target

Based on a patch by Tobias Gruetzmacher <tobias-git@23.gs> (@TobiX).

Signed-off-by: Timothy Gu <timothygu99@gmail.com>