Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Building O'Caml projects properly.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus@m...>
Subject: Re: [Caml-list] Building O'Caml projects properly.
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:


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

RESULT = myexe
LIBDIRS = ../lib
INCDIRS = ../lib


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!

Markus Mottl

Markus Mottl                                   
Austrian Research Institute
for Artificial Intelligence        
Bug reports:  FAQ:
To unsubscribe, mail  Archives: