First of all, remove your previous version of gdal (if any):
brew uninstall gdal --force
Next, you need to remove any references to sqlite and spatialite from brew's gdal formula:
brew edit gdal
Then, re-install gdal with postgresql support:
brew install --env=std --complete --with-postgres gdal
You'll have to re-install mapnik if you have a previous version:
cd cartodb-windshaft
rm -rf node_modules/windshaft
brew uninstall mapnik
brew install mapnik
npm install