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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@i...>
Subject: Re: [Caml-list] Re: ocamlbuild and c libs
Excerpts from Alan Falloon's message of Tue Oct 09 16:11:01 +0200 2007:
> Nicolas Pouillard wrote:
> > Excerpts from Alan Falloon's message of Thu Oct 04 16:49:54 +0200 2007:
> >> Another useful addition would be to pass the include flags when 
> >> compiling c stubs. Right now, you need to write a plugin even if you 
> >> only want to include the other project directories.
> > 
> > You can also specify include directories using tags.
> > 
> > "libfoo": include
> 
> That works for compiling ocaml ".ml -> .cmo" code, but not for c code 
> ".c -> .o".
> 
> I had to add this to my After_rules section:
>     flag ["c"; "compile"] (
>       S( List.map
>           (fun p -> S[A"-ccopt"; A("-I../"^p)])
>           !Ocamlbuild_pack.Options.include_dirs)
>     );

Hum, that's make sense.

[...]

> It is a big hack because what I really want to do is scan the C file and 
> determine which header files is actually depends on and have them copied 
> into the _build directory before compiling (notice the include flag has 
> .. in it). However, I am having a really hard time figuring our how to 
> reproduce the dependency magic implemented for the ocaml stuff, and at 
> least this sort of works (as long as I don't expect the .o to rebuild 
> when I touch the headers).

Have  you  tried  to  use  `gcc -MM' it's some kind of ocamldep for C code. It
returns  dependencies  in  a  makefile  syntax. But you can do almost the same
thing as for OCaml.

> Maybe this would make another good example for the Wiki.

Indeed! A volunteer... :)
-- 
Nicolas Pouillard aka Ertai