From Martin Maechler <maechler@stat.math.ethz.ch>  Mon Jun 14 09:01:00 1999
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Mon, 14 Jun 1999 10:01:00 +0200
Subject: dynload for R on AIX (>= 4.2)
In-Reply-To: <199906111915.PAA14180@infiniti.ece.cmu.edu> (message from Thomas
 Vogels on Fri, 11 Jun 1999 15:15:33 -0400)
References: <199906111915.PAA14180@infiniti.ece.cmu.edu>
Message-ID: <199906140801.KAA00561@sophie.ethz.ch>

>>>>> On Fri, 11 Jun 1999 15:15:33 -0400, Thomas Vogels <tov@infiniti.ece.cmu.edu> said:


    Thomas>   since I've never used dlsym and friends before, I coded a
    Thomas> test case last night to understand what's going on.  I've put
    Thomas> it at: http://www.ece.cmu.edu/~tov/public/dltest.tar.gz

got it

    Thomas> It should work out of the box for AIX 4.2 and Linux.  It's a
    Thomas> simple program that loads a shared object, uses it (with
    Thomas> references back to the main program), and then discards it.
    Thomas> Main point of the exercise is to find out how to compile this
    Thomas> stuff with AIX.

    Thomas> The "ugliness" that I encounter is that I need a file of the
    Thomas> exported symbols in R and the libraries (libappl.a, libmath.a,
    Thomas> etc.).  Otherwise I get core dumps.  Any suggestions for when
    Thomas> to build it or where to patch the Makefiles?

Couldn't you just 'nm' the  R.binary file?
That should be available *before* you start building  *.so's ?
Then it could happen in src/main/Makefile[.in].

The "tricky/tedious" part is to have "configure" produce that different
Makefile for the case of AIX only.
It seems, the FLAGS and the Makefile entry for the *.exp file (see below)
would also have to present in one of the two Makeconf  files or in every
Makefile that builds a *.so.

    Thomas> If you have a machine with AIX, would you mind downloading the
    Thomas> dltest tarfile?  Just unzip it, untar it.  Then in the dltest
    Thomas> directory, start "make test".  Should print "OK" eventually...

It did print "OK".  
I see in the "Makefile" that you're creating the list of exported objects
simply using  nm & awk :
(cited for those who haven't got your code ready):

    NM = nm
    NM_FLAGS = -g -h
    AWK = awk
    LD_FLAGS = -bdynamic -bE:main.exp
    LIBS = -ldl
    SHLIB_CFLAGS = 
    SHLIB_LD = /bin/ld
    SHLIB_LD_FLAGS = -bso -bM:SRE -H512 -T512 -bnoentry -bexpall -bI:main.exp

    <....>

    main.exp : main.o
	    $(NM) $(NM_FLAGS) main.o | $(AWK) ' \
	    BEGIN { print "#! ."; } \
	    $$2 == "T" && $$1 != ".main" { print substr ($$1, 2) } \
	    ' > $@

which looks very reasonable.
Now we just need configure build the proper Makeconf(s) and Makefile(s)
and things would hopefully work..

Could we short-cut E-mail ( R-core, Arne, TomV ) to get this going?
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


dynload for R on AIX (>= 4.2)
Martin Maechler