BUG: Fix support for builds with directories that contain whitespace

Fixes #4382. @MichaelAdello reported a build failing for a directory that contained whitespace, and narrowed the problem down to ``parse_flags(line)`` not supporting whitespace in directory names. 

This PR enables POSIX mode in the lexer, which adds support for quotes and backslash escaping. It also calls quote() on file names where necessary.