caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Romain Bardou <Romain.Bardou@lri.fr>
To: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
Cc: Nicolas Pouillard <nicolas.pouillard@gmail.com>,
	caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] ocamlbuild and installed modules and libraries
Date: Mon, 17 Nov 2008 10:54:03 +0100	[thread overview]
Message-ID: <49213F3B.5030805@lri.fr> (raw)
In-Reply-To: <8C3D2D08-575C-4746-B130-80C1F8417948@erratique.ch>

Daniel Bünzli a écrit :
> 
> Le 16 nov. 08 à 21:37, Nicolas Pouillard a écrit :
> 
>> I'm a bit uncomfortable with this kind of dynamic or special tags.
>>
>> However the simplest solution to your problem is probably one of those:
>>
>>  1/ ocamlbuild -cflags -I,+xmlm,xmlm.cmx test.native
> 
> You meant,
> 
>> ocamlbuild -cflags -I,+xmlm -lflags -I,+xmlm,xmlm.cmx test.native
> 
> 
> I still think using ocamlbuild with installed libraries/modules is a 
> little bit problematic. If we have to do it that way [1] we are 
> hard-coding the location of the library in the plugin which doesn't feel 
> right.
> 
> For me there should be (1) a way of defining the dependency on a 
> module/library (hopefully without needing a plugin) and (2) a way of 
> defining its location (-I). These two aspects should be decoupled. This 
> makes it easier to drive the installation process in build scripts by 
> using environment variables, i.e. I just need
> to specify the location of the module/library I depend on via a suitable 
> -I $DEPDIR to compile the sources.

Isn't it almost as simple to write, in a script:
   ocamlbuild -cflags -I,$DEPDIR -lflags -I,$DEPDIR
instead of:
   ocamlbuild -I $DEPDIR
Remember that $DEPDIR must be absolute, or relative to the _build directory.

Then you can use ocamlbuild with the -lib option as usual, in a 
"decoupled" way. For instance, if bla/bla.cma is in your current directory:

$ ocamlbuild -classic-display -lib bla -cflags -I,../bla -lflags 
-I,../bla test.byte
ocamldep.opt -modules test.ml > test.ml.depends
ocamlc.opt -c -I ../bla -o test.cmo test.ml
ocamlc.opt -I ../bla bla.cma test.cmo -o test.byte

And for modules, instead of -lib bla, you write -lflags bla.cmo or 
-lflags bla.cmx. You can have several -lflags if you want. Unfortunately 
you have to specify the extension, so it is true that a -mod option 
would actually add something.

I admit, though, that it is not really easy to understand how to include 
a library. One solution would be to have findlib in ocamlbuild, but even 
then, there would be problems if you want a Makefile which is supposed 
to work also when findlib is not installed.

I think there is a recent debate about the -I option of Ocamlbuild...

-- 
Romain Bardou


  reply	other threads:[~2008-11-17  9:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-16 18:22 Daniel Bünzli
2008-11-16 20:37 ` [Caml-list] " Nicolas Pouillard
2008-11-17  9:20   ` Daniel Bünzli
2008-11-17  9:54     ` Romain Bardou [this message]
2008-11-17 10:07       ` Daniel Bünzli

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=49213F3B.5030805@lri.fr \
    --to=romain.bardou@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    --cc=nicolas.pouillard@gmail.com \
    /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).