Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Pierre Weis <weis@pauillac.inria.fr>
To: guttman@mitre.org
Cc: Xavier.Leroy@inria.fr, guttman@linus.mitre.org,
	caml-list@inria.fr, weis@pauillac.inria.fr (Pierre Weis)
Subject: Re: OCaml: problems compiling
Date: Tue, 22 Jul 1997 18:25:11 +0200 (MET DST)	[thread overview]
Message-ID: <199707221625.SAA19307@pauillac.inria.fr> (raw)
In-Reply-To: <199707221550.LAA21532@apollonius.mitre.org> from "Joshua D. Guttman" at "Jul 22, 97 11:50:29 am"

> Is there some convenient way to set up a makefile so that it will
> ensure that foo.cmi is generated (or re-generated) before foo.cmo or
> foo.cmx?  
> 
> Not being a magician of `make', I didn't see an easy way to express
> the conditional on there existing a foo.mli file.  Of course, in the
> ideal case one would actually see whether it was possible to make
> foo.mli, e.g. from foo.mly.
> 
> Thanks.
> 
> 	Josh

Well, I'm not a magician of ``make'', but I use the following
(oversimplified) Makefile template for O'Caml. I hope it could be
useful, as a first attempt to automatize your recompilations.

As an example, the template is ready to use, if we suppose that you
want to produce executable file ``exc'', from (Caml lex) lexer source
definition ``lexer.mll'', parser source definition ``parser.mly'', and
O'Caml source files ``types.ml'' and ``main.ml''. It should not be too
difficult to modify it to fit your needs.

If Makefiles are new to you, note that the lines of rule
bodies must start with a tab character (not 8 blank spaces!).

Note also that this Makefile will handle dependancies between O'Caml
files, provided that you create a dummy file ``.depend'' the first
time you use it.

Usage:
-- just type make to recompile what have to be recompiled
-- type make clean, then make to rebuild the application from scratch.

============================================================
# The Caml compilers. You may have to add various -I options.

CAMLC = ocamlc
CAMLDEP = ocamldep
CAMLLEX = ocamllex
CAMLYACC = ocamlyacc

# Lex stuff
LEXSOURCES = lexer.mll
LEXGENERATED = lexer.mli lexer.ml

# Yacc stuff
YACCSOURCES = parser.mly
YACCGENERATED = parser.mli parser.ml

GENERATED = $(LEXGENERATED) $(YACCGENERATED)

# Caml sources
SOURCES = types.ml main.ml $(GENERATED)
# Caml object files to link
OBJS = types.cmo lexer.cmo parser.cmo main.cmo

# Name of executable file to generate
EXEC = exc

# This part should be generic
# Don't forget to create (touch) the file ./.depend at first use.

# Building the world
all: depend $(EXEC)

$(EXEC): $(GENERATED) $(OBJS)
	$(CAMLC) $(OBJS) -o $(EXEC) 

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

.ml.cmo:
	$(CAMLC) -c $<

.mli.cmi:
	$(CAMLC) -c $<

.mll.ml:
	$(CAMLLEX) $<

.mly.ml:
	$(CAMLYACC) $<

# Clean up
clean:
	rm -f *.cm[io] *.cmx *~ .*~ #*#
	rm -f $(GENERATED)
	rm -f $(EXEC)

# Dependencies
depend: $(SOURCES) $(GENERATED) $(LEXSOURCES) $(YACCSOURCES)
	$(CAMLDEP) *.mli *.ml > .depend

include .depend

=============================================================

Hope this help,

Pierre Weis

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







      reply	other threads:[~1997-07-22 16:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-18  0:21 Paul A. Steckler
1997-07-21 16:02 ` Xavier Leroy
1997-07-22 15:50   ` Joshua D. Guttman
1997-07-22 16:25     ` Pierre Weis [this message]

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=199707221625.SAA19307@pauillac.inria.fr \
    --to=weis@pauillac.inria.fr \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=guttman@linus.mitre.org \
    --cc=guttman@mitre.org \
    /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