TOP_DIR=../..

include $(TOP_DIR)/Makefile.conf

PRE = 1
PKGNAME = netstring
GENERATE = netconst.ml netglob_lex.ml \
           netunichar.ml netmappings_asn1.ml META
CLEAN_LIST += $(GENERATE)

NETNUMBER_DEFS = -D WORDSIZE_$(WORD_SIZE) -D HOST_IS_$(ENDIANESS) \
                 -D USE_NETSYS_XDR

PP_OPTIONS = -pp "$(CPPO) $(NETNUMBER_DEFS) $(REGEXP_DEFS) $(PP_BYTES) $(PP_DEPRECATED)"

INSTALL_EXTRA = netstring_top.cmo netaccel_link.cmo netaccel.cma

netconst.ml: netconst.mlp
	sed -e 's/@VERSION@/$(VERSION)/' netconst.mlp >netconst.ml

unicode_charinfo.txt:
	ocaml ../../tools/unicode_extract.ml > unicode_charinfo.txt

netunichar.ml: unicode_charinfo.txt
	ocaml ../../tools/unicode_charinfo.ml unicode_charinfo.txt \
		> netunichar.ml

ASN1_MAPPINGS  = ../netunidata/mappings/asn1_*.unimap
unimap_to_ocaml = $(TOP_DIR)/tools/unimap_to_ocaml/unimap_to_ocaml

# The .pmap files are the distributed files. The .unimap files cannot be
# distributed because of license conditions.

netmappings_asn1.pmap:
	$(unimap_to_ocaml) \
	        -o netmappings_asn1.pmap -pmap $(ASN1_MAPPINGS)

netmappings_asn1.ml: netmappings_asn1.pmap
	$(unimap_to_ocaml) \
		-o netmappings_asn1.ml netmappings_asn1.pmap

# How I created netsaslprep_data.ml:
#netsaslprep_data.ml: tmp/CompositionExclusions-3.2.0.txt \
#                     tmp/UnicodeData-3.2.0.txt
#	ocaml str.cma ../../tools/saslprep-extract-from-unicode.ml \
#		> netsaslprep_data.ml
#
#tmp/CompositionExclusions-3.2.0.txt:
#	mkdir -p tmp
#	cd tmp && \
#		wget 'http://www.unicode.org/Public/3.2-Update/CompositionExclusions-3.2.0.txt'
#
#tmp/UnicodeData-3.2.0.txt:
#	mkdir -p tmp
#	cd tmp && \
#		wget 'http://www.unicode.org/Public/3.2-Update/UnicodeData-3.2.0.txt'

include $(TOP_DIR)/Makefile.rules
