[Caml-list] Re: Simple ocamlbuild example for C stubs?

2009-11-28 Thread Sylvain Le Gall
On 28-11-2009, Guillaume Yziquel guillaume.yziq...@citycable.ch wrote:
 Hello.

 I'm trying to build a .cma with C stubs with ocamlbuild. Linking and 
 includes are supposed to be set to non-standard directories.


You probably need to add some 'A-ccopt; Ayour-option' to the good
tag. 

Can you give more details/actual layout of your myocamlbuild.ml ?

Regards,
Sylvain Le Gall

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] Re: Simple ocamlbuild example for C stubs?

2009-11-28 Thread Guillaume Yziquel

Sylvain Le Gall a écrit :

On 28-11-2009, Guillaume Yziquel guillaume.yziq...@citycable.ch wrote:

Hello.

I'm trying to build a .cma with C stubs with ocamlbuild. Linking and 
includes are supposed to be set to non-standard directories.




You probably need to add some 'A-ccopt; Ayour-option' to the good
tag. 


Can you give more details/actual layout of your myocamlbuild.ml ?


OK. Yes, I could meddle with my myocamlbuild.ml file. My myocamlbuild.ml 
file is the same as the one on the wiki:


http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild

But I mean, if I'm supposed to write a myocamlbuild.ml for every project 
I make, I might as well use Makefiles, as below.


I was wondering if there was a myocamlbuild.ml that would solve the C 
stub problem and bottleneck. For instance, being able to _tag in the 
tags file for a given .c file the directories in which to look for 
headers (here /usr/share/R/include), and for .o files, all linking 
information (here, /usr/lib/R/lib/libR.so).


The ideal would be to have all that available only from _tags.

Because if you need to write a myocamlbuild.ml for each and every 
project, you might as well write Makefiles... That's the point of a 
generic plugin.


yziq...@seldon:~/git/ocaml-r$ cat Makefile 
RLIBDIR=/usr/lib/R/lib

RINCLUDES=-I . -I /usr/share/R/include
INCLUDES=   -I +ocamldoc -I `ocamlc -where`/caml $(RINCLUDES)

COMPFLAGS=$(INCLUDES)
LINKFLAGS=$(INCLUDES) -ccopt -L$(RLIBDIR) -cclib -lR
LINKFLAGS_BYTE=$(INCLUDES) -ccopt -L$(RLIBDIR)  -cclib -lR

all: build

#build: r.cma r.cmxa oCamlR.cma oCamlR.cmxa
build: r.cma r.cmxa

r.cma: dllr_stubs.so camlobjs
ocamlc -a -dllpath /usr/lib/R/lib -dllib dllr_stubs.so -dllib libR.so 
-o r.cma r.cmo

r.cmxa: dllr_stubs.so camlobjs
ocamlopt -a -ccopt -L/usr/lib/R/lib -cclib -lr_stubs -cclib -lR -o 
r.cmxa r.cmx

oCamlR.cma: camlobjs
ocamlc -a -o oCamlR.cma oCamlR.cmo

oCamlR.cmxa: camlobjs
ocamlopt -a -o oCamlR.cmxa oCamlR.cmx

camlobjs: standard.ml
#   ocamlbuild -classic-display r.cmo r.cmx oCamlR.cmo oCamlR.cmx
ocamlbuild -classic-display r.cmo r.cmx
cp _build/r.cmi .
cp _build/r.cmo .
cp _build/r.cmx .
cp _build/r.o .
#   cp _build/oCamlR.cmi .
#   cp _build/oCamlR.cmo .
#   cp _build/oCamlR.cmx .

standard.ml: r/standard.R
R --silent --vanilla --slave  r/standard.R  r/standard.ml

r_stubs.o: r_stubs.c
ocamlopt -ccopt -Wall $(COMPFLAGS) -ccopt -fPIC -c $

libr_stubs.a: r_stubs.o
ar rcs libr_stubs.a r_stubs.o

dllr_stubs.so: libr_stubs.a r_stubs.o
ocamlmklib -o r_stubs r_stubs.o

clean:
rm -f r/tandard.ml
rm -f *.o *.so *.a *.cmi *.cmo *.cmx *.cma *.cmxa
ocamlbuild -clean

test: build
ocaml -init ocamlinit

install:
cp META *.a *.cm[ai] *.cmxa /usr/lib/ocaml/R/
cp dllr_stubs.so /usr/lib/ocaml/stublibs/


All the best,

--
 Guillaume Yziquel
http://yziquel.homelinux.org/

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs