* Simple ocamlbuild example for C stubs?
@ 2009-11-28 16:15 Guillaume Yziquel
2009-11-28 17:36 ` Sylvain Le Gall
0 siblings, 1 reply; 3+ messages in thread
From: Guillaume Yziquel @ 2009-11-28 16:15 UTC (permalink / raw)
To: caml-list
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.
Is there a state-of-the-art, and *simple* example lying around? Is there
an ocamlbuild plugin that is more generic than the one on the Wiki
http://brion.inria.fr/gallium/index.php/Ocamlbuild_example_with_C_stubs
which I unfortunately find quite obscure.
All the best,
--
Guillaume Yziquel
http://yziquel.homelinux.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Simple ocamlbuild example for C stubs?
2009-11-28 16:15 Simple ocamlbuild example for C stubs? Guillaume Yziquel
@ 2009-11-28 17:36 ` Sylvain Le Gall
2009-11-28 18:59 ` [Caml-list] " Guillaume Yziquel
0 siblings, 1 reply; 3+ messages in thread
From: Sylvain Le Gall @ 2009-11-28 17:36 UTC (permalink / raw)
To: caml-list
On 28-11-2009, Guillaume Yziquel <guillaume.yziquel@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"; A"your-option"' to the good
tag.
Can you give more details/actual layout of your myocamlbuild.ml ?
Regards,
Sylvain Le Gall
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Re: Simple ocamlbuild example for C stubs?
2009-11-28 17:36 ` Sylvain Le Gall
@ 2009-11-28 18:59 ` Guillaume Yziquel
0 siblings, 0 replies; 3+ messages in thread
From: Guillaume Yziquel @ 2009-11-28 18:59 UTC (permalink / raw)
To: Sylvain Le Gall; +Cc: caml-list
Sylvain Le Gall a écrit :
> On 28-11-2009, Guillaume Yziquel <guillaume.yziquel@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"; A"your-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.
> yziquel@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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-28 18:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-28 16:15 Simple ocamlbuild example for C stubs? Guillaume Yziquel
2009-11-28 17:36 ` Sylvain Le Gall
2009-11-28 18:59 ` [Caml-list] " Guillaume Yziquel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox