caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus@mail4.ai.univie.ac.at>
To: Jeremy Fincher <tweedgeezer@hotmail.com>
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] Building O'Caml projects properly.
Date: Sun, 30 Sep 2001 00:08:36 +0200	[thread overview]
Message-ID: <20010930000836.A21582@fichte.ai.univie.ac.at> (raw)
In-Reply-To: <F117nyxGxTWlEqLjd5j0000e00a@hotmail.com>; from tweedgeezer@hotmail.com on Sat, Sep 29, 2001 at 16:31:39 -0400

On Sat, 29 Sep 2001, Jeremy Fincher wrote:
> I'm not very experienced with make, so I've been using Markus Mottl's
> OcamlMakefile in my projects so far.  In one of my projects, I use
> source files from two other small libraries I've written; at present,
> I just have a whole lot of files in my SOURCES and a bunch of symlinks
> to the proper files in the proper directories.  However, I'd really
> like to be able to improve my build process, and I think a good way to
> do that is to isolate in directories the other libraries I've written.

"make" is notoriously bad at handling project dependencies across several
directories. This means that it imposes some work on the developers to
behave as they want it to.

If you want to do what I usually do, your project tree should look
somewhat like this:

  ./
    Makefile
    OcamlMakefile
    lib/
    libsrc/
      lib1/...
      lib2/...
      lib3/...
    src/
      Makefile
      src1.ml
      src2.ml
      ...

Your Makefile in the toplevel could contain something like this:

---------------------------------------------------------------------------
OCAML_LIB_INSTALL := $(shell echo `pwd`/lib)
LIBSRC := $(filter-out libsrc/CVS, $(wildcard libsrc/*))

all:    libsrc
	cd src; $(MAKE) all

.PHONY: libsrc
libsrc:
	for dir in $(LIBSRC); do (cd $$dir; yes | $(MAKE) install); done
---------------------------------------------------------------------------

If all your libraries follow the OcamlMakefile install conventions, they
will be installed in directory "lib". Then your Makefile in directory
"src" can refer to your libraries as usual:

---------------------------------------------------------------------------
OCAMLMAKEFILE = ../OcamlMakefile

SOURCES = src1.ml src2.ml ...
RESULT = myexe
LIBDIRS = ../lib
INCDIRS = ../lib

-include $(OCAMLMAKEFILE)
---------------------------------------------------------------------------

Enter "make" in the toplevel directory of your project, and everything
will be compiled. People usually do not edit their libraries all the
time so you only need to issue "make" in your "src"-directory in most
cases (very efficient).  When you change some library, issue a "make"
in the toplevel again and make sure that your "src"-tree will be rebuilt
correctly. If insure in the last case, a "make clean; make" in directory
"src" will do what you want.

I hope this will help you getting started with more complex projects!

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-09-29 22:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-29 20:31 Jeremy Fincher
2001-09-29 21:48 ` Julian Assange
2001-09-29 22:08 ` Markus Mottl [this message]
2001-10-01  7:04 Jeremy Fincher
2001-10-01  8:07 ` Markus Mottl
2001-10-01 11:46 Jeremy Fincher
2001-10-01 12:57 ` Markus Mottl
2001-10-01 13:08   ` Hideo Bannai
2001-10-01 13:47     ` Markus Mottl
2001-10-01 15:17       ` Julian Assange
2001-10-01 14:02 Jeremy Fincher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010930000836.A21582@fichte.ai.univie.ac.at \
    --to=markus@mail4.ai.univie.ac.at \
    --cc=caml-list@pauillac.inria.fr \
    --cc=tweedgeezer@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).