Ideally this should be done by appending to the CFLAGS and LDFLAGS environment variables rather than override all the flags Homebrew has already set. At the very least it should be done as separate string arguments rather than all this escaping.