Loading ...
Sorry, an error occurred while loading the content.

Re: "ocaml_beginners"::[] Output directory ?

Expand Messages
  • Richard Jones
    ... As far as I can see, that s right. However, you probably ought to be using a Makefile and some standard rules, meaning that you will be compiling each file
    Message 1 of 3 , Sep 2, 2004
    • 0 Attachment
      On Mon, Aug 30, 2004 at 11:29:36AM -0300, Andrei Formiga wrote:
      >
      > Hi,
      >
      > Is there any way to instruct ocamlc to output all files to a given
      > directory ? For instance, if I need to compile A.ml and B.ml, in that
      > order (because B depends on A), to produce B.cmo, I can do
      >
      > ocamlc -c -o outdir/B.cmo A.ml B.ml
      >
      > and B.cmo will be in outdir, but A.cmo will be built in the current
      > dir. I looked for relevant compiler flags but found nothing. Seems
      > that the only way to get what I want is compiling A.ml separately,
      > before B.ml. Is that right ?

      As far as I can see, that's right.

      However, you probably ought to be using a Makefile and some standard
      rules, meaning that you will be compiling each file separately anyway.
      For reference here are the standard rules I always use:

      %.cmi: %.mli
      $(OCAMLC) $(OCAMLCFLAGS) -c $<

      %.cmo: %.ml
      $(OCAMLC) $(OCAMLCFLAGS) -c $<

      %.cmx: %.ml
      $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<

      .SUFFIXES: .ml .mli .cmi .cmo .cmx

      A simple modification of these will allow you to compile into a
      subdirectory. (You will probably need to "fix" the output of ocamldep
      to understand the subdirectory ...)

      Rich.

      --
      Richard Jones. http://www.annexia.org/ http://www.j-london.com/
      Merjis Ltd. http://www.merjis.com/ - improving website return on investment
      NET::FTPSERVER is a full-featured, secure, configurable, database-backed
      FTP server written in Perl: http://www.annexia.org/freeware/netftpserver/


      [Non-text portions of this message have been removed]
    • Andrei Formiga
      ... Yes, I would use a makefile, but that s for a tool and it shouldn t depend on GNU make. I m thinking about the alternatives, I ll probably end up compiling
      Message 2 of 3 , Sep 2, 2004
      • 0 Attachment
        On Thu, 2 Sep 2004 12:43:54 +0100, Richard Jones <rich@...> wrote:
        >
        > However, you probably ought to be using a Makefile and some standard
        > rules, meaning that you will be compiling each file separately anyway.
        > For reference here are the standard rules I always use:
        >
        > %.cmi: %.mli
        > $(OCAMLC) $(OCAMLCFLAGS) -c $<
        >
        > %.cmo: %.ml
        > $(OCAMLC) $(OCAMLCFLAGS) -c $<
        >
        > %.cmx: %.ml
        > $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
        >
        > .SUFFIXES: .ml .mli .cmi .cmo .cmx
        >

        Yes, I would use a makefile, but that's for a tool and it shouldn't
        depend on GNU make. I'm thinking about the alternatives, I'll probably
        end up compiling each file separately anyway, although it's slower.

        --
        []s, Andrei de A. Formiga
      Your message has been successfully submitted and would be delivered to recipients shortly.