# make all: 		make bytecode archive
# make opt: 		make native archive
# make install: 	install bytecode archive, and if present, native archive
# make uninstall: 	uninstall package
# make clean: 		remove intermediate files
# make distclean: 	remove any superflous files
# make release: 	cleanup, create archive, tag CVS module 
#			(for developers)

#----------------------------------------------------------------------
# specific rules for this package:

OBJECTS  = \
  mergepop.cmo

XOBJECTS = $(OBJECTS:.cmo=.cmx)
EXEC     = mergepop
XEXEC	 = mergepop.opt
NAME     = mergepop
REQUIRES = util

BYTE_THREAD = -thread
NAT_THREAD = -thread

.PHONY: all opt byte

all: opt byte

opt: $(XEXEC)

byte: $(EXEC)

$(EXEC): $(OBJECTS) 
	$(OCAMLC) -o $(EXEC) -linkpkg $(OBJECTS)

$(XEXEC): $(XOBJECTS)
	$(OCAMLOPT) -o $(XEXEC) -linkpkg $(XOBJECTS)

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

OPTIONS   =
OCAMLC    = ocamlfind ocamlc -dtypes -thread -g $(OPTIONS) -w y -package "$(REQUIRES)"
OCAMLOPT  = ocamlfind ocamlopt -dtypes -thread $(OPTIONS) -w y -package "$(REQUIRES)"
OCAMLDEP  = ocamldep $(OPTIONS)
OCAMLFIND = ocamlfind
OCAMLDOC  = ocamlfind doc -package "$(REQUIRES)"

.PHONY: depend
depend: *.ml *.mli
	$(OCAMLDEP) *.ml *.mli >.depend

.PHONY: install
install: all
	{ test ! -f $(XARCHIVE) || extra1="*.cmxa *.a"; }; \
	{ test ! -f http_client_mt.cmx || extra2="http_client_mt.cmx http_client_mt.o"; }; \
	$(OCAMLFIND) install $(NAME) *.mli *.cmi *.cma http_client_mt.cmo META $$extra1 $$extra2

.PHONY: uninstall
uninstall:
	$(OCAMLFIND) remove $(NAME)

.PHONY: very-clean
very-clean: clean
	rm -f .depend

.PHONY: clean
clean:
	rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa
	rm -f $(EXEC) $(XEXEC)
	rm -f *.annot
	rm -f doc/*

.PHONY: doc
doc: 
	rm -rf doc
	mkdir -p doc
	$(OCAMLDOC) -stars -html -d doc -t "The libhttpd Manual" *.mli

.ml.cmx:
	$(OCAMLOPT) -c $<

.ml.cmo:
	$(OCAMLC) -c $<

.mli.cmi:
	$(OCAMLC) -c $<

.SUFFIXES: .cmo .cmi .cmx .ml .mli

-include .depend
