Add build matrix generation target

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

Fixes #346.

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