From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A58F0BC69 for ; Wed, 28 Mar 2007 10:53:52 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2S8rqnm011268 for ; Wed, 28 Mar 2007 10:53:52 +0200 Received: by ug-out-1314.google.com with SMTP id k3so166405ugf for ; Wed, 28 Mar 2007 01:53:52 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Og0VOu2ygMv70wHXhKCO/q34MTlzgygWW2K6Ymjs69Nn6P5PQFVEvvZtK4PKUZ/kf2QCzgf0EAU8WbDumeeQYQPVEJvM1fJ52mk+rUc6uCiVLN89S3mBpFrkVBI4zEsUTn0gd3OL0tjiItXAA+eHX4ZZ3VxbHMv1RCdINBMfQCE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=VzDPre3Z3Um85ktBUprWa5hzlZBw/IJQJelXLnZ4VCLk9XtSU2FFORimTTmERBwp5NY9mfQxNA5iD4KDZgF2jemPhon6bozcXVDdYJKgsLKSRcSZ3xbFRLJitM13ZWrWqz7+VdyOJ2rxV9/uLn8p+zNc2pJiU/Kt637BnD5d2Tk= Received: by 10.114.89.1 with SMTP id m1mr3595271wab.1175072030728; Wed, 28 Mar 2007 01:53:50 -0700 (PDT) Received: by 10.114.183.4 with HTTP; Wed, 28 Mar 2007 01:53:50 -0700 (PDT) Message-ID: Date: Wed, 28 Mar 2007 10:53:50 +0200 From: "Nicolas Pouillard" To: "Joel Reymont" Subject: Re: [Caml-list] Producing a C wrapper with ocamlbuild or OMake Cc: "Caml List" In-Reply-To: <026CA3D4-5A8B-4083-B429-DE5AEC418C0A@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <026CA3D4-5A8B-4083-B429-DE5AEC418C0A@gmail.com> X-j-chkmail-Score: MSGID : 460A2D20.000 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 460A2D20.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocamlopt:01 -output-obj:01 ocamlopt:01 usr:01 lib:01 ocaml:01 libasmrun:01 libasmrun:01 utils:01 stdlib:01 -output-obj:01 lib:01 deps:01 seq:01 On 3/28/07, Joel Reymont wrote: > Folks, > > I'm trying to produce a C library from my OCaml code. I found these > instructions on the net: > > ocamlopt -output-obj -o fibcaml.o fib.ml > ocamlopt -c fibwrap.c > cp /usr/local/lib/ocaml/libasmrun.a libfib.a > ar r libfib.a fibcaml.o fibwrap.o > > How would I accomplish the same with ocamlbuild, which I'm using now, > or with OMake? > Just add some rules... Here is a plugin example that I will add to the example directory. open Ocamlbuild_plugin;; open Command;; let cc = A"cc";; let ar = A"ar";; let libasmrun = !*Ocamlbuild_pack.Ocaml_utils.stdlib_dir/"libasmrun.a";; dispatch begin function | After_rules -> rule "output C obj" ~dep:"%.ml" ~prod:"%caml.o" begin fun env _ -> let caml_o = env "%caml.o" and ml = env "%.ml" in Cmd(S[!Options.ocamlopt; A"-output-obj"; P ml; A"-o"; Px caml_o]) end; rule "build C lib" ~deps:["%wrap.o"; "%caml.o"] ~prod:"lib%.a" begin fun env _ -> let wrap_o = env "%wrap.o" and caml_o = env "%caml.o" and lib_a = env "lib%.a" in Seq[cp libasmrun lib_a; Cmd(S[ar; A"r"; Px lib_a; P caml_o; P wrap_o])] end; rule "build main" ~deps:["libfib.a"; "main.o"] ~prod:"main" begin fun _ _ -> Cmd(S[cc; P"main.o"; P"libfib.a"; A"-o"; Px"main"]) end; | _ -> () end -- Nicolas Pouillard