Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamlbuild and installed modules and libraries
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Romain Bardou <Romain.Bardou@l...>
Subject: Re: [Caml-list] ocamlbuild and installed modules and libraries
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