Version française
Home     About     Download     Resources     Contact us    
Browse thread
Why does the order in the Makefile matter?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <Pierre.Weis@i...>
Subject: Re: Why does the order in the Makefile matter?
> Two runs 'make all', the only difference in the order in the OBJS-line in
> the Makefile.
> 
> What is the needed order? Should I use the order of .depend?

A Caml implementation file (a .ml file) is a list of definitions and
expression evaluations.

-- definitions can only refer to preceding definitions (due to the
so-called ``static'' binding rule) and cannot refer to following
definitions.

-- top-level expressions may appear anywhere in implementation files and those
expressions define the runtime computation. They must be evaluated in
the exact order specified by the user in his source file (otherwise
strange things may happen if ``exit 0;;'' is evaluated before ``main
();;''!).

Hence, when the entire program is made of multiple implementation
files, those files must be linked in any order that is compatible with
the static binding rule: no definition can be linked if it refers to
an identifier that is defined after the definition at hand.  In
addition, expressions to be computed must evidently appear in any
order compatible with the desired runtime behaviour.

Hope this helps,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/