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: Alan Falloon <alan.falloon@m...>
Subject: Re: [Caml-list] Re: ocamlbuild and c libs
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)
	);

To get the stubs to have the project include dirs.

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).

Maybe this would make another good example for the Wiki.