Say you're using pgvm
to manage several versions of Postgres and you need to install the PostGIS extension.
$ brew uninstall postgis
$ pgvm install 9.3.12
$ pgvm use 9.3.12
$ pgvm cluster create my_cluster
$ pgvm cluster start my_cluster
$ pgvm cluster list
$ brew install geos proj gdal libxml2 json-c
$ wget http://download.osgeo.org/postgis/source/postgis-2.2.2.tar.gz
$ tar xvfz postgis-2.2.2.tar.gz
$ cd postgis-2.2.2
proj
and json-c
(adapt version numbers to your taste):$ ./configure --with-projdir=/usr/local/Cellar/proj/4.9.3 --with-jsondir=/usr/local/Cellar/json-c/0.12
$ make
$ sudo make install
$ pgvm console my_cluster
postgres=# CREATE EXTENSION IF NOT EXISTS postgis;
<3 to @tessi for finding out.