# Common parts of the Makefile, shared by everybody

# Ocaml commands
CAMLC=ocamlc
CAMLOPT=ocamlopt
CAMLP4O=camlp5o pr_o.cmo
OCAMLFIND=ocamlfind
COMPILER=$(CAMLC) -c -w s #-warn-error A
OPTCOMP=$(CAMLOPT) -c
LIBRARIAN=ocamlmklib
OPTLIB=$(CAMLOPT) -a
LINKER=$(CAMLC)
OPTLINK=$(CAMLOPT)
SRCDIR=$(TOPDIR)/src
VAR2DEF=ocamlrun $(SRCDIR)/var2def
VAR2SWITCH=ocamlrun $(SRCDIR)/var2switch

# Default settings
CONFIG = $(TOPDIR)/Makefile.config
LIBDIR = `$(CAMLC) -where`
LABLTKDIR = `$(OCAMLFIND) query -qe labltk || echo +labltk`
DLLDIR = $(LIBDIR)/stublibs
INSTALLDIR = $(LIBDIR)/lablGL
TOGLDIR = Togl
TOGL_WS = TOGL_X11
COPTS = -c -O

# Default toolchain (unix)
TOOLCHAIN = unix
XA = .a
XB =
XE =
XO = .o
XS = .so

# Windows specific
MKLIB=link /lib /nologo /debugtype:CV /out:
MKDLL=link /nologo /dll /out:
OCAMLDLL= "$(LIBDIR)/ocamlrun$(XA)"

include $(CONFIG)

# Default rules
.SUFFIXES: .ml .mli .cmo .cmi .cmx .c .var .h .opt $(XA) $(XO) $(XE) .d$(XO)
.SUFFIXES: .ml4

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

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

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

.c$(XO):
	$(COMPILER) -ccopt "$(COPTS) $(INCLUDES)" $<

.var.h:
	$(VAR2DEF) < $< > $@

ifneq ($(CAMLP4O),no)
.ml4.ml:
	$(CAMLP4O) -impl $< -o $@
endif
