## Import the default build enviornment
Import qw( env );

## Clone the default environment and add the lib/naml/stdlib directory to the
## include path, since some of the modules here depend on the modules therein.
$env = $env->clone(
	OCAMLCFLAGS => "$env->{OCAMLCFLAGS} -pp '%CAMLP4MACRO'",
	PPFLAGS => "$env->{MP}/util/macro.cmo",

	# Because of PPFLAGS, all these files must be built with macro.cmo
	HIDDEPS => "$env->{MP_HASH}/util/macro.cmo",
);

## Declare the module sources in this directory that will be built
OCamlSources $env
	'set_sig.mlz',
	'file_base_type.mlz',
	'dag.mlz',
	'array_sig.mlz',
	'marshal_sig.mlz',
	'remote_queue_sig.mlz',
	'remote_lazy_queue_sig.mlz',
	'simplehash_sig.mlz',
	'hash_with_gc_sig.mlz',
	'memo_sig.mlz',
	'weak_memo_sig.mlz',
	'linear_set.mlz',
	'readline.ml',
	'mp_debug.ml',
	'mp_pervasives.ml',
	'mmap.ml',
	'mmap_pipe.ml',
	'string_util.ml',
	'env_arg.ml',
	'punix.ml',
	'getrusage.ml',
	'int_util.ml',
	'array_util.ml',
	'list_util.ml',
	'ref_util.ml',
	'file_util.ml',
	'filename_util.ml',
	'hashtbl_util.ml',
	'list_neq_append.ml',
	'mp_id.ml',
	'large_array.ml',
	'large_weak_array.ml',
	'marshal_buf.ml',
	'marshal_shared.ml',
	'mp_big_int.ml',
	'mp_num.ml',
	'bitset.ml',
	'imp_dag.ml',
	'precedence.ml',
	'file_base.ml',
	'file_type_base.ml',
	'table_util.ml',
	'splay_table.ml',
	'fun_splay_set.ml',
	'red_black_set.ml',
	'red_black_test.ml',
	'red_black_table.ml',
	'hash_set.ml',
	'small_set.ml',
	'debug_string_sets.ml',
	'debug_tables.ml',
	'string_set.ml',
	'flist.ml',
	'cycle_dag.ml',
	'thread_util.ml',
	'thread_event.ml',
	'remote_queue_null.ml',
	'remote_lazy_queue.ml',
	'memo.ml',
	'splay_linear_set.ml',
	'array_linear_set.ml',
	'simplehashtbl.ml',
	'hash_with_gc.ml',
	'weak_memo.ml',
	'permutations.ml',
	'mp_inet.ml',
	'http_server.ml',
	'comment_parse.mll',
	'mp_term.ml';

# These files use external symbols in $env->{MP}/clib/clib.a
for my $mod ('getrusage', 'marshal_shared', 'mmap', 'mp_debug', 'mp_term',
             'punix', 'readline', 'string_util') {
    Depends $env "$mod$env->{SUFOBJ}", "$env->{MP_HASH}/clib/clib.a";
}

OCamlLibrary $env 'mllib',
	'set_sig',
	'file_base_type',
	'dag',
	'array_sig',
	'marshal_sig',
	'remote_queue_sig',
	'remote_lazy_queue_sig',
	'simplehash_sig',
	'hash_with_gc_sig',
	'memo_sig',
	'weak_memo_sig',
	'linear_set',
	'readline',
	'mp_debug',
	'mp_pervasives',
	'mmap',
	'mmap_pipe',
	'string_util',
	'env_arg',
	'punix',
	'getrusage',
	'int_util',
	'array_util',
	'list_util',
	'ref_util',
	'file_util',
	'filename_util',
	'hashtbl_util',
	'list_neq_append',
	'mp_id',
	'large_array',
	'large_weak_array',
	'marshal_buf',
	'marshal_shared',
	'mp_big_int',
	'mp_num',
	'bitset',
	'imp_dag',
	'precedence',
	'file_base',
	'file_type_base',
	'table_util',
	'splay_table',
	'fun_splay_set',
	'red_black_set',
	'red_black_test',
	'red_black_table',
	'hash_set',
	'small_set',
	'debug_string_sets',
	'debug_tables',
	'string_set',
	'flist',
	'cycle_dag',
	'thread_util',
	'thread_event',
	'remote_queue_null',
	'remote_lazy_queue',
	'memo',
	'splay_linear_set',
	'array_linear_set',
	'simplehashtbl',
	'hash_with_gc',
	'weak_memo',
	'permutations',
	'mp_inet',
	'http_server',
	'comment_parse',
	'mp_term';

#Default "mllib$env->{SUFLIB}";
