Regarding "reset the CFLAGS", couldn't you just specify CFLAGS on the same line instead of using `export`? That wouldn't alter the shell environment permanently.