caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Guillaume Yziquel <guillaume.yziquel@citycable.ch>
To: Sylvain Le Gall <sylvain@le-gall.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: Simple ocamlbuild example for C stubs?
Date: Sat, 28 Nov 2009 19:59:21 +0100	[thread overview]
Message-ID: <4B117309.5090703@citycable.ch> (raw)
In-Reply-To: <slrnhh2nt3.uh9.sylvain@gallu.homelinux.org>

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/


      reply	other threads:[~2009-11-28 18:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-28 16:15 Guillaume Yziquel
2009-11-28 17:36 ` Sylvain Le Gall
2009-11-28 18:59   ` Guillaume Yziquel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B117309.5090703@citycable.ch \
    --to=guillaume.yziquel@citycable.ch \
    --cc=caml-list@inria.fr \
    --cc=sylvain@le-gall.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).