R on Unix can be run from where it is built, and I frequently move where it is built/change symbolic links. You definitely do not want where it is going to be installed, as make check is run where it is built (not that that matters when the R(.sh) scripts sets R_HOME).
On Sun, 30 Nov 2003, Simon Urbanek wrote:
On Nov 29, 2003, at 9:33 PM, Prof Brian Ripley wrote:
On Sat, 29 Nov 2003, Simon Urbanek wrote:
BTW: This is not Mac specific - I was fighting this on Windows (and unix for that matter) as well - it is possible to run an .exe linked to R.dll from anywhere, if R.dll is in the PATH. But then, one has to determine R_HOME somehow (yes, there is the registry, but that's not really safe if more R versions are installed).
How do you do that? For R's own executables on Windows R_HOME is determined from where they are loaded from. You cannot AFAIK determine from within an executable where the R.dll was linked from. That's why the rproxy.dll uses the registry. I believe you have even less information on Windows.
On Mac OS X there is a very nice CoreFoundation function:
CFBundleGetBundleWithIdentifier. Each bundle can have an unique
identifier and the above function will return the bundle reference if
the bundle was loaded by the current application - and a framework is a
bundle. So for Mac OS X this piece of code will determine R_HOME of the
linked R.framework:
CFBundleRef bundle =
CFBundleGetBundleWithIdentifier(CFSTR("org.r-project.r-framework") );
CFURLRef rdir=CFBundleCopyBundleURL(bundle);
CFStringRef rhome=CFURLCopyFileSystemPath(rdir,kCFURLPOSIXPathStyle);
I doubt there is any standard way on unix platforms in general. I have
a vague feeling that I saw some relevant API on Windows - at least form
the DLL itself, but I'm stuck with my PowerBook for three more week
until I get home, so I can't check that easily.
I would suggest a fallback for cases where the location cannot be
determined: we could use a tiny source file like location.c.in (could
be config.h.in itself for that matter) which gets processed by
configure and contains the install path. Then any program linked to R
shlib could call a function like char* R_installPath(); Although that
is not optimal, it is in general unlikely that the user would move R
after doing make install (unless it's a network installation of course
- then we're in trouble) and it is even safer that the registry on
Windows. It would be an useful fallback for platforms where we simply
don't know.
Simon
PS: My script mentioned in the original post doesn't create proper
Info,plist if ran by /bin/sh - you can get the correct Info.plist for R
1.8.1 from http://stats.math.uni-augsburg.de/misc/Info.plist and copy
it to .../R.framework/Resources/
---
Simon Urbanek
Department of computer oriented statistics and data analysis
Universit?tsstr. 14
86135 Augsburg
Germany
Tel: +49-821-598-2236
Fax: +49-821-598-2280
Simon.Urbanek@Math.Uni-Augsburg.de
http://simon.urbanek.info
Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595