
OCAMLBUILDDIR = $(top_builddir)/src/gdome_caml
OCAMLINSTALLDIR = $(DESTDIR)$(OCAML_LIB_PREFIX)/gdome2
OCAMLFLAGS = -I $(OCAMLBUILDDIR) -I $(OCAMLBUILDDIR)/core \
             -I $(OCAMLBUILDDIR)/types
OCAMLC = @OCAMLC@ ${OCAMLFLAGS}
OCAMLOPT = @OCAMLOPT@ ${OCAMLFLAGS}
OCAMLDEP = @OCAMLDEP@
OCAML_CFLAGS  = @OCAML_CFLAGS@

CLEANFILES = \
  mlbasic.cma mlbasic.cmxa mlbasic.a \
  gdomeInit.cmi gdomeInit.cmo gdomeInit.cmx gdomeInit.o \
  tDOMTimeStamp.cmi \
  tDOMString.cmi \
  iDOMString.cmi iDOMString.cmo iDOMString.cmx iDOMString.o

EXTRA_DIST = \
  gdomeInit.ml \
  gdomeInit.mli \
  tDOMTimeStamp.mli \
  tDOMString.mli \
  iDOMString.ml \
  .depend

if HAVE_OCAMLOPT_COND
noinst_DATA = mlbasic.cma gdomeInit.cmo mlbasic.cmxa gdomeInit.cmx
else
noinst_DATA = mlbasic.cma gdomeInit.cmo
endif
noinst_LTLIBRARIES = libbasic.la

mlbasic.cma : iDOMString.cmo
	$(OCAMLC) -o $@ -a $^

mlbasic.cmxa mlbasic.a : iDOMString.cmx
	$(OCAMLOPT) -o $@ -a $^

iDOMString.cmo : tDOMString.cmi

libbasic_la_SOURCES = \
  ml_DOMString.c \
  ml_misc.c

all : tDOMTimeStamp.cmi

INCLUDES = \
  $(OCAML_CFLAGS) \
  $(GDOME_CFLAGS) \
  -I$(srcdir)/../include

if HAVE_OCAMLOPT_COND
install-data-local: mlbasic.cma mlbasic.cmxa mlbasic.a gdomeInit.cmo \
                    gdomeInit.cmx gdomeInit.o tDOMTimeStamp.cmi tDOMString.cmi \
                    gdomeInit.ml gdomeInit.mli tDOMTimeStamp.mli \
                    tDOMString.mli iDOMString.ml iDOMString.cmi gdomeInit.cmi
else
install-data-local: mlbasic.cma mlbasic.a gdomeInit.cmo \
                    gdomeInit.o tDOMTimeStamp.cmi tDOMString.cmi \
                    gdomeInit.ml gdomeInit.mli tDOMTimeStamp.mli \
                    tDOMString.mli iDOMString.ml iDOMString.cmi gdomeInit.cmi
endif
	$(mkinstalldirs) $(OCAMLINSTALLDIR)
	for i in $^; do \
		$(INSTALL_DATA) $$i $(OCAMLINSTALLDIR)/$$i; \
	done

#### OCaml only stuff from now on

DEPOBJS = \
  tDOMString.mli \
  tDOMTimeStamp.mli \
  gdomeInit.mli \
  gdomeInit.ml \
  iDOMString.ml

depend:
	$(OCAMLDEP) $(DEPOBJS) > .depend

%.cmi : $(srcdir)/%.mli
	if test ! -e $(@:%.cmi=%.mli) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi
	$(OCAMLC) -c $(@:%.cmi=%.mli)
		
%.cmo : %.ml
	if test ! -e $(@:%.cmo=%.ml) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi
	$(OCAMLC) -c $(@:%.cmo=%.ml)
				
%.cmx %.o : %.ml
	if test ! -e $(@:%.cmx=%.ml) -a "x$(srcdir)" != "x." ; then $(LN_S) $< . ; fi
	$(OCAMLOPT) -c $(@:%.cmx=%.ml)
						
include .depend

