
OCAMLINCLUDES = ../idl/ocaml_backend ../xapi ../idl ../util ../autogen
OCAMLPACKS    = xml-light2 stdext stunnel http-svr log sexpr rpc-light
#OCAMLPPFLAGS  = -pp "camlp4o" 
#OCAMLDEPFLAGS = -pp "camlp4o"

UseCamlp4(rpc-light.syntax, db_rpc_common_v2 db_cache_types db_filter_types)

OCamlGeneratedFiles(db_filter_parse.ml db_filter_parse.mli db_filter_lex.ml)

OCamlProgram(unit_test_sql, unit_test_sql)

BLOCK_DEVICE_IO_FILES = \
	block_device_io_errors \
	block_device_io \
	../xapi/config_constants ../xapi/xapi_globs ../idl/ocaml_backend/ref \
	../xapi/helper_process ../xapi/helper_hostname ../idl/api_errors

OCamlProgram(block_device_io, $(BLOCK_DEVICE_IO_FILES))
OCamlDocProgram(block_device_io, $(BLOCK_DEVICE_IO_FILES))

DATABASE_SERVER_FILES = database_server_main test_schemas database_test ../autogen/db_actions 
DATABASE_TEST_FILES = database_test database_test_main test_schemas
section:
	#XXX there are lots of interdependencies which we should be aim to remove
	OCAML_LIBS += ../util/version ../idl/ocaml_backend/common ../idl/ocaml_backend/client ../util/stats ../idl/ocaml_backend/server
	OCamlProgram(database_server, $(DATABASE_SERVER_FILES))
	OCamlProgram(database_test, $(DATABASE_TEST_FILES))

section:
	OCAML_LIBS +=  ../idl/ocaml_backend/common ../idl/ocaml_backend/client ../idl/ocaml_backend/server
	OCamlProgram(unit_test_marshall, unit_test_marshall db_remote_cache_access_v1)

.PHONY: install
install:
	mkdir -p $(LIBEXEC)
	$(IPROG) block_device_io $(LIBEXEC)

.PHONY: sdk-install
sdk-install: install

.PHONY: clean
clean:
	rm -f *.cmo *.cmi *.cmx *.o *.cmx *.cma *.cmxa xenEnterpriseAPI* gen gen.opt *.omc *.annot db_filter_parse.ml db_filter_parse.mli db_filter_lex.ml
	rm -f block_device_io unit_test_marshall block_device_io.opt unit_test_marshall.opt

