caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] make
@ 2004-10-19 12:49 Radu Grigore
  2004-10-19 13:02 ` Nicolas Cannasse
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Radu Grigore @ 2004-10-19 12:49 UTC (permalink / raw)
  To: caml-list

I have a problem with writing makefiles for OCaml and with compilation
order. Probably a FAQ.

Searching the caml-list archives I've found info about a tool by
Nicolas Cannesse (ocamake) that can be used to compile a set of ml
files into an executable or to generate a makefile such that a
subsequent make command will construct the executable. However this is
not quite what I want.

Using a makefile has the advantage that only necessary recompilations
are performed. So I want to use a makefile. If I add a source (ml)
file in the project directory then the generated makefile becomes
obsolete and needs to be regenerated. But... a regeneration might
overwrite any subsequent changes I've done.

What I'd love is an enhanced ocamldep that in addition to the
dependencies prints also a topologically sorted list of files, like
this:

---
$ocamldep main.ml parser.ml ast.ml lexer.ml
main.cmo: lexer.cmo parser.cmo
main.cmx: lexer.cmx parser.cmx
parser.cmo: ast.cmo
parser.cmx: ast.cmx
lexer.cmo: parser.cmo
lexer.cmx: parser.cmx
CMO_FILES=ast.cmo parser.cmo lexer.cmo main.cmo
CMX_FILES=ast.cmx parser.cmx lexer.cmx main.cmx
---

This way I would be able to write a kind of 'standard' makefile:

---
include .depend
all: $(CMO_FILES)
   ocamlc -o my_app $(CMO_FILES)

depend:
  ocamldep *.ml > .depend

%.cmo: %.ml
   ocamlc -c $<
---

Does such a tool exists? Does ocamldep already knows to do this and I
didn't found it in the docs? Thanks.

-- 
regards,
 radu
http://rgrig.idilis.ro/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] make
  2004-10-19 12:49 [Caml-list] make Radu Grigore
@ 2004-10-19 13:02 ` Nicolas Cannasse
  2004-10-20  0:28   ` skaller
  2004-10-19 13:16 ` Julien Signoles
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Nicolas Cannasse @ 2004-10-19 13:02 UTC (permalink / raw)
  To: Radu Grigore, caml-list

> I have a problem with writing makefiles for OCaml and with compilation
> order. Probably a FAQ.
>
> Searching the caml-list archives I've found info about a tool by
> Nicolas Cannesse (ocamake) that can be used to compile a set of ml
> files into an executable or to generate a makefile such that a
> subsequent make command will construct the executable. However this is
> not quite what I want.
[...]
> Does such a tool exists? Does ocamldep already knows to do this and I
> didn't found it in the docs? Thanks.

This is not a FAQ and still an open problem.
OCamldep is working at the syntax level but does not differenciate between
the usage of a module *type* (so a compilation dependency : the MLI of the
module need to be compiled first) and the usage of a module *value* ( so a
compilation + runtime dependency : the MLI needs to be compiled first AND
the module linked first). Thus unless you rewrite your ocamldep you cannot
get enough information to correctly sort the CMO into the good order.
However ocamake is applying some algorithms in order to "guess" which order
might be valid in cases of conflict . A case of conflict arise when we
reduce the ML+MLI ocamldep graph output into a CMO only graph, merging ML
and MLI nodes, and thus sometimes creating cycles while there *is* a valid
compilation order.
Instead of doing again the job you might try to use the Makefile generation
from ocamake, or simply tweak it in order to make it output the linkage
order it found.

Regards,
Nicolas Cannasse

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] make
  2004-10-19 12:49 [Caml-list] make Radu Grigore
  2004-10-19 13:02 ` Nicolas Cannasse
@ 2004-10-19 13:16 ` Julien Signoles
  2004-10-19 13:35   ` Radu Grigore
  2004-10-21 11:12   ` [Caml-list] ocamldsort and directories Richard Jones
  2004-10-19 14:48 ` [Caml-list] make Eric C. Cooper
  2004-10-21  2:41 ` Aleksey Nogin
  3 siblings, 2 replies; 12+ messages in thread
From: Julien Signoles @ 2004-10-19 13:16 UTC (permalink / raw)
  To: Radu Grigore; +Cc: caml-list


> What I'd love is an enhanced ocamldep that in addition to the
> dependencies prints also a topologically sorted list of files, like
> this:

I think Ara's ocamldsort (mixed with ocamldep) is your friend. I quote the
beginning of the README file:

"The ocamldsort command scans a set of Objective Caml source files (.ml
and .mli files), sorts them according to their dependencies and prints the
sorted files in order to link their corresponding .cmo and .cmi files."

	http://www.eleves.ens.fr/home/ara/ocaml.html

Hope this helps,
Julien Signoles
-- 
mailto:Julien.Signoles@lri.fr ; http://www.lri.fr/~signoles
"In theory, practice and theory are the same,
but in practice they are different" (Larry McVoy)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] make
  2004-10-19 13:16 ` Julien Signoles
@ 2004-10-19 13:35   ` Radu Grigore
  2004-10-19 19:12     ` noweb/nuweb (was: Re: [Caml-list] make) David MENTRE
  2004-10-21 11:12   ` [Caml-list] ocamldsort and directories Richard Jones
  1 sibling, 1 reply; 12+ messages in thread
From: Radu Grigore @ 2004-10-19 13:35 UTC (permalink / raw)
  To: caml-list

Julien & Nicolas, thanks for the answers. I'll try ocamldsort first.
So far I don't have cyclic type dependencies so the effort to modify
ocamake is not yet warranted.

A related question. Is there a good reason for ocaml to support only
"# <num> <file>" directives, and not "#line <num> <file>"? I try to
use nuweb and had to change it's sources to generate something that is
understood by ocaml and ocamldep...

-- 
regards,
 radu
http://rgrig.idilis.ro/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] make
  2004-10-19 12:49 [Caml-list] make Radu Grigore
  2004-10-19 13:02 ` Nicolas Cannasse
  2004-10-19 13:16 ` Julien Signoles
@ 2004-10-19 14:48 ` Eric C. Cooper
  2004-10-19 23:23   ` skaller
  2004-10-21  2:41 ` Aleksey Nogin
  3 siblings, 1 reply; 12+ messages in thread
From: Eric C. Cooper @ 2004-10-19 14:48 UTC (permalink / raw)
  To: caml-list

On Tue, Oct 19, 2004 at 03:49:51PM +0300, Radu Grigore wrote:
> What I'd love is an enhanced ocamldep that in addition to the
> dependencies prints also a topologically sorted list of files, like
> this:
> [...] 
> This way I would be able to write a kind of 'standard' makefile:
> 
> ---
> include .depend
> all: $(CMO_FILES)
>    ocamlc -o my_app $(CMO_FILES)
> 
> depend:
>   ocamldep *.ml > .depend
> 
> %.cmo: %.ml
>    ocamlc -c $<
> ---

This doesn't fully solve your problem, but you can build a library
(.cma or .cmxa) of all the object files, and thereby avoid having to
do the topological sort, since the linking phase does it for you.

-- 
Eric C. Cooper          e c c @ c m u . e d u

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* noweb/nuweb (was: Re: [Caml-list] make)
  2004-10-19 13:35   ` Radu Grigore
@ 2004-10-19 19:12     ` David MENTRE
  2004-10-20  5:08       ` Radu Grigore
  0 siblings, 1 reply; 12+ messages in thread
From: David MENTRE @ 2004-10-19 19:12 UTC (permalink / raw)
  To: Radu Grigore; +Cc: caml-list

Radu Grigore <radugrigore@gmail.com> writes:

> A related question. Is there a good reason for ocaml to support only
> "# <num> <file>" directives, and not "#line <num> <file>"? I try to
> use nuweb and had to change it's sources to generate something that is
> understood by ocaml and ocamldep...

On noweb you have the -L option. I use in my Makefile:
   -L'#%L "%F"%N'

Maybe a similar option exists in nuweb?

Yours,
d.
-- 
pub  1024D/A3AD7A2A 2004-10-03 David MENTRE <dmentre@linux-france.org>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] make
  2004-10-19 14:48 ` [Caml-list] make Eric C. Cooper
@ 2004-10-19 23:23   ` skaller
  0 siblings, 0 replies; 12+ messages in thread
From: skaller @ 2004-10-19 23:23 UTC (permalink / raw)
  To: Eric C. Cooper; +Cc: caml-list

On Wed, 2004-10-20 at 00:48, Eric C. Cooper wrote:

> This doesn't fully solve your problem, but you can build a library
> (.cma or .cmxa) of all the object files, and thereby avoid having to
> do the topological sort, since the linking phase does it for you.

It doesn't. The objects must be put into the library
in the required order. They're always linked in that order.
All the linkage phase does is omit uneeded objects.

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] make
  2004-10-19 13:02 ` Nicolas Cannasse
@ 2004-10-20  0:28   ` skaller
  0 siblings, 0 replies; 12+ messages in thread
From: skaller @ 2004-10-20  0:28 UTC (permalink / raw)
  To: Nicolas Cannasse; +Cc: Radu Grigore, caml-list

On Tue, 2004-10-19 at 23:02, Nicolas Cannasse wrote:
> > I have a problem with writing makefiles for OCaml and with compilation
> > order. Probably a FAQ.
> >
> > Searching the caml-list archives I've found info about a tool by
> > Nicolas Cannesse (ocamake) that can be used to compile a set of ml
> > files into an executable or to generate a makefile such that a
> > subsequent make command will construct the executable. However this is
> > not quite what I want.
> [...]
> > Does such a tool exists? Does ocamldep already knows to do this and I
> > didn't found it in the docs? Thanks.
> 
> This is not a FAQ and still an open problem.
[..]

However the problem you are refering to is not the problem that
Radu is refering to.

Radu needs to make changes to the makefile, and even if ocamake,
or some other makefile generator, gets the order right, his
changes are clobbered when he reruns it.

This is a problem for most generators. Some provide a template,
but that is a weak solution.

In addition, Radu mentions patching nuweb to allow for the fact
Ocaml can't accept #line spelled as such. The reason it doesn't
is that # is the symbol used in object # method syntax, and so
that usage is ambiguous. # digits is not.

You could try interscript. It already knows Ocaml.
The makefile clobbering problem also just goes away,
since you can use any Python script you like from
within your literate programmed documents to generate
anything you want. The main problem is that it's a bit slow,
compared to some other LP tools (it's written in Python).

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: noweb/nuweb (was: Re: [Caml-list] make)
  2004-10-19 19:12     ` noweb/nuweb (was: Re: [Caml-list] make) David MENTRE
@ 2004-10-20  5:08       ` Radu Grigore
  0 siblings, 0 replies; 12+ messages in thread
From: Radu Grigore @ 2004-10-20  5:08 UTC (permalink / raw)
  To: David MENTRE; +Cc: caml-list

On Tue, 19 Oct 2004 21:12:09 +0200, David MENTRE
<dmentre@linux-france.org> wrote:
> On noweb you have the -L option. I use in my Makefile:
>   -L'#%L "%F"%N'
> 
> Maybe a similar option exists in nuweb?

Unfortunately "#line" is hardcoded in nuweb.

-- 
regards,
 radu
http://rgrig.idilis.ro/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] make
  2004-10-19 12:49 [Caml-list] make Radu Grigore
                   ` (2 preceding siblings ...)
  2004-10-19 14:48 ` [Caml-list] make Eric C. Cooper
@ 2004-10-21  2:41 ` Aleksey Nogin
  3 siblings, 0 replies; 12+ messages in thread
From: Aleksey Nogin @ 2004-10-21  2:41 UTC (permalink / raw)
  To: Radu Grigore, Caml List

On 19.10.2004 05:49, Radu Grigore wrote:

> What I'd love is an enhanced ocamldep that in addition to the
> dependencies prints also a topologically sorted list of files, like
> this:

I do not know if there are any stand-alone tools providing this 
functionality, but our OMake build system (http://omake.metaprl.org/) 
does have an option to sort build targets according to their dependencies.

-- 
Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal)
Office: Jorgensen 70, tel: (626) 395-2907

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Caml-list] ocamldsort and directories
  2004-10-19 13:16 ` Julien Signoles
  2004-10-19 13:35   ` Radu Grigore
@ 2004-10-21 11:12   ` Richard Jones
  2004-10-22 18:04     ` Dimitri Ara
  1 sibling, 1 reply; 12+ messages in thread
From: Richard Jones @ 2004-10-21 11:12 UTC (permalink / raw)
  Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1400 bytes --]

On Tue, Oct 19, 2004 at 03:16:33PM +0200, Julien Signoles wrote:
> 
> > What I'd love is an enhanced ocamldep that in addition to the
> > dependencies prints also a topologically sorted list of files, like
> > this:
> 
> I think Ara's ocamldsort (mixed with ocamldep) is your friend. I quote the
> beginning of the README file:
> 
> "The ocamldsort command scans a set of Objective Caml source files (.ml
> and .mli files), sorts them according to their dependencies and prints the
> sorted files in order to link their corresponding .cmo and .cmi files."
> 
> 	http://www.eleves.ens.fr/home/ara/ocaml.html

I tried out ocamldsort, and it seems to work well, *except* that
there seems to be a strange bug involving directories:

~/d/merjis/tools/wiki/scripts/lib$ ocamldsort -byte *.ml *.mli
cocanwiki_date.cmo cocanwiki_emailnotify.cmo cocanwiki_files.cmo [...]

~/d/merjis/tools/wiki/scripts/lib$ cd ..

~/d/merjis/tools/wiki/scripts$ ocamldsort -I lib -byte lib/*.ml lib/*.mli
lib/cocanwiki.cmo lib/cocanwiki_date.cmo lib/cocanwiki_diff.cmo [...]

The second ordering is completely wrong.  (In fact, I think the second
ordering is just alphabetic ordering).

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
http://www.YouUnlimited.co.uk/ - management courses

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] ocamldsort and directories
  2004-10-21 11:12   ` [Caml-list] ocamldsort and directories Richard Jones
@ 2004-10-22 18:04     ` Dimitri Ara
  0 siblings, 0 replies; 12+ messages in thread
From: Dimitri Ara @ 2004-10-22 18:04 UTC (permalink / raw)
  To: Richard Jones; +Cc: caml-list

Richard Jones <rich@annexia.org> a écrit :

> I tried out ocamldsort, and it seems to work well, *except* that
> there seems to be a strange bug involving directories

Thank you for your bug report. It is fixed in the 0.14.3 that I have
just released.
(<URL: ftp://quatramaran.ens.fr/pub/ara/ocamldsort/ocamldsort-0.14.3.tar.gz>)

-- 
Dimitri

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2004-10-22 18:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-19 12:49 [Caml-list] make Radu Grigore
2004-10-19 13:02 ` Nicolas Cannasse
2004-10-20  0:28   ` skaller
2004-10-19 13:16 ` Julien Signoles
2004-10-19 13:35   ` Radu Grigore
2004-10-19 19:12     ` noweb/nuweb (was: Re: [Caml-list] make) David MENTRE
2004-10-20  5:08       ` Radu Grigore
2004-10-21 11:12   ` [Caml-list] ocamldsort and directories Richard Jones
2004-10-22 18:04     ` Dimitri Ara
2004-10-19 14:48 ` [Caml-list] make Eric C. Cooper
2004-10-19 23:23   ` skaller
2004-10-21  2:41 ` Aleksey Nogin

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