From the pl/R website instructions:
As of PostgreSQL 8.0.0, PL/R can also be built without the PostgreSQL source tree. Untar PL/R whereever you prefer. The shared object for the R call handler is built and installed in the PostgreSQL library directory via the following commands (starting from/path/to/plr):
cd plr USE_PGXS=1 make USE_PGXS=1 make install
I wanted to keep the same version I had worked with on PostgreSQL 9.0 so I tried to follow those instructions after deactivating postgresql 9.0 port and activating 9.1, as well as doing postgresql-select so all the default commands (unversioned psql etc) would target 9.1.
Seems with or without R_HOME env variable the build would fail to find the include headers.
In file included from pg_backend_support.c:33:
plr.h:89:15: error: R.h: No such file or directory
plr.h:90:22: error: Rversion.h: No such file or directory
So I downloaded the latest version (had 8.3.0.13 but downloaded 8.3.0.14 hoping the following recent change would solve my build problems given this in the change log:
- The MacPorts installation has the header filed distributed across two different directories, so there is no single "rincludedir" to query from pkg-config. Instead, do it the proper way and ask pkg-config for the cflags, which should work for all installation variants. (Peter Eisentraut)
Well that did not fix it either.
Desperate and aware my Mac Ports were outdated I figured I'd do an update anyway and retry.
The update brought R 3.0.0 instead of my 2.15 so I'm not sure if this is helping or hurting (my production environment uses 2.15)
Even after the upgrade PL/R build code would complain about the headers. So I checked to see where they were:
port contents R
And specifying that location directly did the trick:
USE_PGXS=1 R_HOME="/Library/Frameworks/R.framework/Resources/" make
sudo USE_PGXS=1 R_HOME="/Library/Frameworks/R.framework/Resources/" make install