.PHONY: simple monadic lib test all ocsigen install clean

# .SUBDIRS:

USE_OCAMLFIND = true

OCAMLPACKS[] =
	json-static
	json-wheel
	netclient
	lwt
	lwt.unix

if $(not $(OCAMLFIND_EXISTS))
    eprintln(This project requires ocamlfind, but is was not found.)
    eprintln(You need to install ocamlfind and run "omake --configure".)
    exit 1

# OCAMLINCLUDES +=

NATIVE_ENABLED = true
BYTE_ENABLED = true

OCAMLFLAGS    += -g -syntax camlp4o -for-pack Couch
OCAMLDEPFLAGS += -syntax camlp4o
# OCAMLCFLAGS   +=
# OCAMLOPTFLAGS +=
# OCAML_LINK_FLAGS +=
# OCAML_BYTE_LINK_FLAGS +=
# OCAML_NATIVE_LINK_FLAGS +=

################################
# Library
#
section
	FILES_LIB[] =
		common
		http
	simple : $(OCamlLibrary simple , $(FILES_LIB) simple)
	monadic: $(OCamlLibrary monadic, $(FILES_LIB) monadic)

section
	OCAMLFLAGS =
	OCamlPackage(couch, simple monadic)
	lib: $(OCamlLibrary couch, common http couch)

################################
# Test programs
#
section
	OCAML_LIBS += couch
	test: $(OCamlProgram test_simple, test_simple) $(OCamlProgram test_monadic, test_monadic)

section
	OCAML_LIBS += couch
	NATIVE_ENABLED = false
	BYTE_ENABLED = true
	OCAMLPACKS[] =
		json-static
		json-wheel
		ocsigen
	OCAMLFLAGS += -thread
	OCamlLibrary(ocsigen, ocsigen)
	ocsigen:
		 ocamlfind ocamlc -c -g -syntax camlp4o -thread -package json-static,json-wheel,ocsigen ocsigen.ml

################################
#
all: lib test
clean:
	rm $(filter-proper-targets $(ls R, .))

.DEFAULT: all

