nvidia: fix problems with -glsi and glx

..by generalizing the build script.
Obsoletes #3699, and it should finally fix problems around 816d971a.