Re: ocamlfind problem
On Thu, Mar 23, 2006 at 06:35:26PM +0800, Paul Wise wrote:
> On Thu, 2006-03-23 at 11:26 +0100, Sven Luther wrote:
>
> > Yes, That said, the install.ml is a very nice touch, maybe you could attach it
> > here, and we can help you modify it to do the right thing, and possibly even
> > reuse it for other projects ?
>
> Attached, and available at [1]. [2] is a similar thing for another
> program by the same people. It is GPL, so that should be fine. In this
> case, it would need to make a bytecode version where ocamlopt is not
> available, and emit stuff so debian/rules knows what to add to the
> dependencies.
Oh, nice.
> let bytecode = true
> let native = true
> let ocamlc file =
> if bytecode then command ("ocamlc -c " ^ file);
> if native then command ("ocamlopt -c " ^ file)
> command ("ocaml install.ml -nodoc -d .. " ^ (if bytecode then "-b " else "") ^ (if native then "-n" else ""));
> let options = "-cclib ../extc/extc_stubs" ^ obj_ext ^ " -cclib " ^ zlib ^ " extc.mli extc.ml" in
> if bytecode then command ("ocamlc -a -o extc.cma " ^ options);
> if native then command ("ocamlopt -a -o extc.cmxa " ^ options);
> Sys.chdir "../..";
...
Oh, well. It seems that there is already some nice touch here, and rather easy
to modify, altough others may probably help you more on this these days, me
being with my sick mother and all these weeks.
But basically, there are two variables (bytecode and native) which are set in
the file, but which should be made depednent on install.ml options, using the
Arg argument. I would say something like -n -> native and -b -> bytecode, and
have the thing iterate over both of them.
We would use the Arg module, as defined at :
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Arg.html
And do something like :
bytecode = ref false
native = ref false
Arg.parse [
"-b", Arg.Set bytecode, "build bytecode version";
"-n", Arg.Set natriuve, "native code version";
] (function () -> ()) "usage message"
and then replace all usages of bytecode and native by !bytecode and !native.
not sure if this would be enough, but it is already a first step.
That said, it builds .cma/.cmxa libraries, so are those used only by the tool,
or are there also usefull for the user ?
Friendly,
Sven Luther
Reply to: