# You may have to edit this file (In particular the CC, LABLTKDIR, and
# LABLGLDIR definitions) according to where OCAML's libraries are
# installed.
# After editing files, you may want to run "make depend" again before
# making the executables.

# Ocaml commands
CAMLC = ocamlc
CAMLOPT = ocamlopt -inline 20
COMPILER = $(CAMLC) -c -labels
OPTCOMP = $(CAMLOPT) -c -labels
CC = gcc -c -I $(HOME)/lib/ocaml -I/usr/X11R6/include
LINKER = $(CAMLC) -custom
OPTLINK = $(CAMLOPT)

# directories
LABLTKDIR = $(HOME)/lib/ocaml/labltk
LABLGLDIR = $(HOME)/lib/ocaml/lablGL
OCAMLINC = -I $(LABLTKDIR) -I $(LABLGLDIR)

# Files
LIB = unix.cma labltk.cma lablgl.cma togl.cmo
OPTLIB = unix.cmxa labltk.cmxa lablgl.cmxa togl.cmx

OBJS = texhelp.o tex.cmo collision.cmo fixedobj.cmo freeobj.cmo \
       badguy.cmo spiff.cmo wall.cmo level.cmo mousehelp.o mouse.cmo game.cmo \
       ui.cmo main.cmo
OPTOBJS = $(OBJS:.cmo=.cmx)

EDITOBJS = texhelp.o tex.cmo collision.cmo \
           fixedobj.cmo freeobj.cmo badguy.cmo \
           spiff.cmo wall.cmo level.cmo editor.cmo


# Default rules
.SUFFIXES: .ml .mli .cmo .cmi .cmx .c .o

.ml.cmo:
	$(COMPILER) $(OCAMLINC) $<

.ml.cmx:
	$(OPTCOMP) $(OCAMLINC) $<

.mli.cmi:
	$(COMPILER) $(OCAMLINC) $<

.c.o:
	$(CC) $<

install: spiff.opt editor
	(mv editor ../Dungeon; mv spiff.opt ..)

all:	spiff editor    # in bytecode

all.opt:	spiff.opt  # in native code

spiff: 	$(OBJS)
	$(LINKER) $(OCAMLINC) $(LIB) $(OBJS) -o spiff

spiff.opt: $(OPTOBJS)
	$(OPTLINK) -o spiff.opt $(OCAMLINC) $(OPTLIB) $(OPTOBJS)

editor:	$(EDITOBJS)
	$(LINKER) $(OCAMLINC) $(LIB) $(EDITOBJS) -o editor

clean:
	rm -f editor spiff spiff.opt *.cm* *.o

depend:
	ocamldep *.ml *.mli > .depend

#dependencies
include .depend
