TOP_DIR=..

OBJECTS  = netstring_pcre.cmo netstring_str.cmo netbuffer.cmo \
	   netaux.cmo netchannels.cmo netdate.cmo \
	   netmappings.cmo netconversion.cmo \
           netencoding.cmo netstream.cmo \
	   mimestring.cmo cgi.cmo \
           nethtml_scanner.cmo nethtml.cmo \
	   neturl.cmo \
	   netaddress.cmo \
	   netmime.cmo netsendmail.cmo \

PKGNAME  = netstring

ISO_MAPPINGS   = mappings/iso*.unimap
OTHER_MAPPINGS = mappings/cp*.unimap \
                 mappings/adobe*.unimap \
	         mappings/jis*.unimap \
                 mappings/koi*.unimap \
                 mappings/mac*.unimap \
                 mappings/windows*.unimap

INSTALL_EXTRA = netstring_mt.cmo      netstring_mt.cmx      netstring_mt.o     \
	        netmappings_iso.cmo   netmappings_iso.cmx   netmappings_iso.o  \
	        netmappings_other.cmo netmappings_other.cmx netmappings_other.o\
		netstring_top.cmo

all: $(ARCHIVE) \
     netstring_top.cmo netstring_mt.cmo \
     netmappings_iso.cmo netmappings_other.cmo

opt: $(XARCHIVE) \
     netstring_mt.cmx \
     netmappings_iso.cmx netmappings_other.cmx


include $(TOP_DIR)/Makefile.rules


netmappings_iso.pmap: tools_done
	test ! -d mappings || tools/unimap_to_ocaml/unimap_to_ocaml \
		-o netmappings_iso.pmap -pmap $(ISO_MAPPINGS)

netmappings_iso.ml: netmappings_iso.pmap
	tools/unimap_to_ocaml/unimap_to_ocaml \
		-o netmappings_iso.ml netmappings_iso.pmap

netmappings_other.pmap: tools_done
	test ! -d mappings || tools/unimap_to_ocaml/unimap_to_ocaml \
		-o netmappings_other.pmap -pmap $(OTHER_MAPPINGS)

netmappings_other.ml: netmappings_other.pmap
	tools/unimap_to_ocaml/unimap_to_ocaml \
		-o netmappings_other.ml netmappings_other.pmap

tools_done:
	$(MAKE) -C tools
	touch tools_done

netdate.ml: netdate.mlp
	$(CAMLP4) pa_o.cmo pa_op.cmo pr_o.cmo -impl $< > $@

depend:: netdate.ml

#----------------------------------------------------------------------
# general rules:

clean::
	test ! -d mappings || rm -f netmappings_iso.ml netmappings_other.ml
	rm -f tools_done

distclean::
	$(MAKE) -C tests distclean
	$(MAKE) -C doc distclean
	$(MAKE) -C tools distclean

include depend
