###
###	examples/Makefile.  Generated from Makefile.in by configure.
###

.PHONY: clean
.PRECIOUS: %.cmx %.cmo %.cmi
.SUFFIXES: .ml .mli .cmx .cmi .cmo

OCBYTE		= ocamlc.opt -thread
OCOPT		= ocamlopt.opt -thread
FINDLIB = ocamlfind

FLAGS		= -g -I ..
LFLAGS		= -g -I .. -ccopt -L..

OCURLLIB	= curl.cma unix.cma threads.cma
OCURLOPTLIB	= curl.cmxa unix.cmxa threads.cmxa

LWT_UNIX=no
LWT_PPX=no

TARGETS = ocurl ominimal ossl ocurl_test_threads opar test_cb_exn test_memory_leaks test_enum
ifneq (bytes,no)
TARGETS += oput
endif
ifneq ($(LWT_UNIX),no)
TARGETS += test_lwt_unit
ifneq ($(LWT_PPX),no)
TARGETS += test_lwt
endif
endif

ifeq (opt,opt)
TARGETS	+= ocurl.opt ominimal.opt ossl.opt ocurl_test_threads.opt opar.opt test_cb_exn.opt test_memory_leaks.opt test_enum.opt
ifneq (bytes,no)
TARGETS += oput.opt
endif
ifneq ($(LWT_UNIX),no)
TARGETS += test_lwt_unit.opt
ifneq ($(LWT_PPX),no)
TARGETS += test_lwt.opt
endif
endif
endif

all:	$(TARGETS)

test_lwt: ../curl.cma ../curl_lwt.cmo test_lwt.ml
	$(FINDLIB) c -thread -custom -linkpkg -package $(LWT_UNIX),$(LWT_PPX) $(LFLAGS) $^ -o $@

test_lwt.opt: ../curl.cmxa ../curl_lwt.cmx test_lwt.ml
	$(FINDLIB) opt -thread -linkpkg -package $(LWT_UNIX),$(LWT_PPX) $(LFLAGS) $^ -o $@

test_lwt_unit: ../curl.cma ../curl_lwt.cmo test_lwt_unit.ml
	$(FINDLIB) c -thread -custom -linkpkg -package $(LWT_UNIX) $(LFLAGS) $^ -o $@

test_lwt_unit.opt: ../curl.cmxa ../curl_lwt.cmx test_lwt_unit.ml
	$(FINDLIB) opt -thread -linkpkg -package $(LWT_UNIX) $(LFLAGS) $^ -o $@

oput: ../curl.cma oput.ml
	$(FINDLIB) c -custom -package bytes,unix -linkpkg $(LFLAGS) $^ -o $@

oput.opt: ../curl.cmxa oput.ml
	$(FINDLIB) opt -package bytes,unix -linkpkg $(LFLAGS) $^ -o $@

%: %.cmo ../curl.cma
		$(OCBYTE) -custom $(LFLAGS) $(OCURLLIB) $< -o $@

%.opt: %.cmx ../curl.cmxa
		$(OCOPT) $(LFLAGS) $(OCURLOPTLIB) $< -o $@

.ml.cmx:
		$(OCOPT) -c $(FLAGS) $< -o $@

.mli.cmi:
		$(OCBYTE) -c $(FLAGS) $< -o $@

.ml.cmo:
		$(OCBYTE) -c $(FLAGS) $< -o $@

clean:
		@rm -f $(TARGETS) *.cm* *.o *.a
