From Simon.Urbanek at math.uni-augsburg.de  Mon Dec 22 19:53:21 2003
From: Simon.Urbanek at math.uni-augsburg.de (Simon Urbanek)
Date: Mon Dec 22 19:52:08 2003
Subject: [Rd] R-devel with Darwin: some issues (mostly due to latest
	R.framework changes)
Message-ID: <1D19D440-34B0-11D8-910D-000A957CEFBA@math.uni-augsburg.de>

Some issues with the recent R-devel (rsync today) on Darwin:

1) Recent R-devel is a bit misleading concerning the R-framework  
installation:
A new option --enable-R-framework was introduced, but  
install-Rframework ignores its absence (or --disable-R-framework for  
that matter) and tries to install the framework anyway in / which fails  
just after the R itself was copied into /Versions/.... I know, the user  
is to blame, but still, a simple check and stop (perhaps with a hint to  
use --enable-R-framework) would be nice.

2) Wrong -install_name:
configure.ac@1094:  LIBR_LDFLAGS="-dynamiclib -install_name  
${R_FRAMEWORK_DIR}/R.framework/Versions/${PACKAGE_VERSION}/Resources/ 
bin/libR.dylib -compatibility_version ${PACKAGE_VERSION}   
-current_version ${PACKAGE_VERSION}"

R_FRAMEWORK_DIR specifies the full path including the framework name,  
at least according to the previous definition:

configure.ac@154:
      if test "${want_R_framework}" = yes; then
	R_FRAMEWORK_DIR="/Library/Frameworks/R.framework"
       else
	R_FRAMEWORK_DIR="${want_R_framework}/R.framework"
	want_R_framework=yes
       fi

therefore R.framework should be removed from the path at line 1094

3) Chicken-and-egg problem:
There is a chicken-and-egg  problem if --enable-R-framework is used:
gcc -bundle -flat_namespace -undefined suppress -L/usr/local/lib -o  
R_X11.so  dataentry.lo devX11.lo rotated.lo rbitmap.lo  -lSM -lICE  
-L/usr/X11R6/lib -lX11   -framework R -lz -lreadline -lcc_dynamic  
-lncurses -lm
ld: can't locate framework for: -framework R
make[4]: *** [R_X11.so] Error 1

--enable-framework adds: LIBR="-framework R" [configure.ac@173] which  
is then used:
src/modules/X11/Makefile.in@36: R_X11_la_LIBADD = $(ALL_X_LIBS)  
$(BITMAP_LIBS) $(LIBR)

  If you installed R.framework previously, you're fine (well, fine in a  
sense that R is not compiled against its own version of the shared  
library as one would expect, but the currently installed R framework  
instead). If you have a clean system, it won't even build.

It is a touchy subject: during the compilation of R we cannot use the  
framework as-is, since there is none. On the other hand once installed,  
we want all packages to use -framework R.

A partial solution is to "fake" a non-installed framework:

Add following to the Makefile.in conditional for Darwin (probably  
somewhere around src/main/Makefile.in@160):
mkdir $(top_builddir)/bin/R.framework
ln -s ../libR.dylib $(top_builddir)/bin/R.framework/R

and add "-F$(top_builddir)/bin" to the LIBS
The addition of -F.. to LIBS should be temporary during the build of R  
only - I'm not sure if there is such a mechanism in the current R  
building process though ... if there isn't we could just add something  
like $(LIBS_BUILD) or similar to all modules that are built before  
install ...

A side note: unfortunately gcc doesn't honor DYLD_FRAMEWORK_PATH, so we  
cannot use that elegant solution :(

4) warnings - aqua module under construction?
I guess the aqua code is currently under construction, because it's  
probably compiled-in twice (in the libR and in aqua.so):
[...]
ld: warning multiple definitions of symbol _InitAquaIO
aquaconsole.lo definition of _InitAquaIO in section (__TEXT,__text)
/Work/R-builds/osx/r-devel/bin/R.framework/R(aqua.lo) definition of  
_InitAquaIO
[...many warnings of the same kind follow...]

I didn't invesitgate this further - if this is not intentional then I  
could have a look ... I suspect that this has something to do with  
Stefano's attempt to separate Carbon code (aqua+quartz) from the core R  
so it can be used from an external terminal w/o root privileges.

5) --enable vs. --with:
I have a rather general question about configure options: why use the  
name --"with"-aqua but --"enable"-R-framework ? I'm just curious: after  
--with-zlib --with-aqua I somehow expected --with-R-framework, but  
configure neither warns about an unrecognized option, nor does it take  
it as --enable-R-framework. Remember that R.framework isn't just a  
different way to install R/dylib, but in future it will also unlock the  
Obj-C code contained in the R.framework (hopefully) [i.e. to justify  
--with in case it is meant for additional stuff whereas --enable just  
pulls a lever somewhere ...].

Merry Xmas!
Simon

platform powerpc-apple-darwin7.2.0
arch     powerpc
os       darwin7.2.0
system   powerpc, darwin7.2.0
status   Under development (unstable)
major    1
minor    9.0
year     2003
month    12
day      22
language R

---
Simon Urbanek
Department of computer oriented statistics and data analysis
University of Augsburg
Universit?tsstr. 14
86135 Augsburg
Germany

Tel: +49-821-598-2236
Fax: +49-821-598-2200

Simon.Urbanek@Math.Uni-Augsburg.de
http://simon.urbanek.info


[Rd] R-devel with Darwin: some issues (mostly due to latest R.framework changes)
Simon Urbanek