# Compile all .ml files against some base libraries
# (defined in the plugin as unix,str,nums and bigarray)
<**/*.ml>: use_base

#
# Cocci sources and directories
#

<commons>: include
<commons/ocamlextra>: include
<commons/ocollection>: include

<globals>: include
<globals/regexp_pcre.ml>: use_pcre

<parsing_cocci>: include
<parsing_cocci/parser_cocci_menhir.ml>: use_menhirLib, nowarn20

<parsing_c>: include
<ctl>: include
<engine>: include
<popl09>: include
<extra>: include

<ocaml>: include
<ocaml/coccilib.ml{,i}>: use_pcre

<python>: include
<python/yes_pycocci.ml>: thread, use_pycaml

# some users have a symlink 'result' pointing to the outcome
# of the build, which causes troubles with the hygiene check.
<result>: -traverse


#
# Subdirectories
#

<engine/engine.{cma,cmxa}>:   use_pcre
<globals/globals.{cma,cmxa}>: use_pcre
<ocaml/ocaml.{cma,cmxa}>:     use_pcre
<parsing_c/parsing_c.{cma,cmxa}>:         use_pcre
<parsing_cocci/parsing_cocci.{cma,cmxa}>: use_pcre, use_menhirLib
<popl09/popl09.{cma,cmxa}>:   use_pcre
<python/python.{cma,cmxa}>:   use_pcre, use_pycaml


#
# Bundled packages
#

# apriori remove the traverse tag from the bundle
# directories to prevent them from being included.
# The traverse tag will be added by the plugin for
# the bundles that are included.
<bundles/*>: -traverse

<bundles/pcre/pcre.{cma,cmxa}>: use_pcre
<bundles/pycaml/pycaml.{cma,cmxa}>: thread, use_pycaml

# Interaction between the bundles and the plugin.
<bundles/pcre/libpcre_stubs.a>:     use_pcre
<bundles/pcre/*/lib/pcre_stubs.c>:  use_pcre
<bundles/pycaml/libpycaml_stubs.a>: use_pycaml
<bundles/pycaml/*/pycaml_stubs.c>:  pp_pycaml, use_pycaml
<bundles/pycaml/*/pycaml.ml>:       pp_pycaml
<bundles/menhirLib/*/src/*.cmx>:    for-pack(MenhirLib)


#
# Hygiene
#

# Some lexers and parsers are precompiled in the
# source distribution to make some preprocessors
# optional

<parsing_c/parser_c.mly>:                   not_hygienic
<parsing_c/lexer_c.mll>:                    not_hygienic
<parsing_cocci/lexer_cli.mll>:              not_hygienic
<parsing_cocci/lexer_script.mll>:           not_hygienic
<parsing_cocci/lexer_cocci.mll>:            not_hygienic
<parsing_cocci/parser_cocci_menhir.mly>:    not_hygienic
<parsing_cocci/parser_cocci_menhir.ml{,i}>: precious
<ocaml/coccilib/coccilib.cmi>:		    not_hygienic


#
# Applications
# Main is the entry point of spatch.
#

# library dependencies of spatch.
<main.{byte,native}>: thread, use_base, use_menhirLib, use_pcre, use_pycaml

# some test tools in the subdirectories
<parsing_cocci/main.{byte,native}>: use_base, use_pcre
<ctl/test_ctl.{byte,native}>: use_base


# Build tools/all.otarget for all tools, or
# tools/all.opt.otarget for all tools with the native compiler.

<tools/gitgrep.{byte,native}>:             use_base
<tools/gitsort.{byte,native}>:             use_base
<tools/process_isoprofile.{byte,native}>:  use_base
<tools/alloc_free.{byte,native}>:          use_base
<tools/bridge.{byte,native}>:              use_base
<tools/spp.{byte,native}>:                 use_base
<tools/splitpatch.{byte,native}>:          use_base
<tools/extract_c_and_res.{byte,native}>:   use_base
<tools/cstripenv.{byte,native}>:           use_base, use_pcre
<tools/distributed/cleanup.{byte,native}>: use_base


#
# Documentation
#

<ocaml/man.docdir/index.html>: gen_man, use_menhirLib, use_pcre, use_pycaml
<ocaml/html.docdir/index.html>: gen_html, use_menhirLib, use_pcre, use_pycaml
