Source

camlspotter.bitbucket.org / omy / _sources / OMyMakefile.txt

Full commit

==========================
OMyMakefile
==========================
Useful functions to build OCaml projects

Directories
=====================================================================

.. index::
    single: BIG_ROOT

**BIG_ROOT**
    

    ::
    

    

        = $(dir .)


    The build root directory  

.. index::
    single: PREFIX

**PREFIX**
    

    ::
    

    

        = $(getenv PREFIX)


    The prefix. Equal to the PREFIX environment variable

Installation mark files
=======================================================================

.. index::
    single: INSTALLED

**INSTALLED**
    

    ::
    

    

        = $(BIG_ROOT)/installed


    Installation mark files are put inside this directory.

.. index::
    Installed()

**Installed(packs)**

    Returns the installation mark files of $(packs)

.. index::
    CreateInstalled()

**CreateInstalled(pack, targets)**

    Create $(Installed $(pack)) file from the digests of $(targets)

Misc tools
======================================================================

.. index::
    mkdir_if_not_exists()

**mkdir_if_not_exists(dir)**

    ditto.

OCamlFind
========================================================================

.. index::
    single: USE_OCAMLFIND

**USE_OCAMLFIND**
    

    ::
    

    

        =  true


    OMy requires OCamlFind! Do not ask me how to use OMy without OCamlFind. Please.

.. index::
    single: OCAML_PREINSTALLED_PACKS[]

**OCAML_PREINSTALLED_PACKS[]**
    

    ::
    

    

        =  bigarray camlp4 dbm dynlink graphics num num-top stdlib str threads unix findlib


    Preinstalled libraries which are always available for normal ocaml.
    
    You may want to add the required packages which are built and installed out of OMy framework:
    
    ::
    
      include OMyMakefile
      
      OCAML_PREINSTALLED_PACKS += llvm # llvm has been installed already, independently
      
      Subdirs()
    
    It includes "findlib" by default. If you want to build findlib in OMy framework, you have to remove it from the list.


.. index::
    single: BYTE_ENABLED

**BYTE_ENABLED**
    

    ::
    

    

        =  true


    If set false in a project directory, byte compilation is disabled there.



Spot files (OCamlSpotter)
==================================================================

.. index::
    single: setenv(OCAML_ANNOT, 1)

**setenv(OCAML_ANNOT, 1)**

    Define OCAML_ANNOT so that custom ocamlc/ocamlopt automatically create spot/spit/annot files, even without -annot option.



Packages
=========================================================

.. index::
    single: public.OCAMLPACKS[]

**public.OCAMLPACKS[]**
    OCaml packages required for compilation. MyCaml* functions automatically add necessary dependencies over packages in $(OCAMLPACKS).

.. index::
    single: public.CAMLP4PACKS[]

**public.CAMLP4PACKS[]**
    CamlP4 syntax extension packages required for parsing. MyCaml* functions automatically add necessary dependencies over packages in $(CAMLP4PACKS).

Dependencies
=========================================================================

.. index::
    RequirePackages()

**RequirePackages(packages)**

    Add dependencies of any build activity over $(packages).
    
    .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*

.. index::
    OCamlRequirePackages()

**OCamlRequirePackages(packages)**

    Add dependencies of OCaml compiled files (cmx, cmo, etc.) over $(packages).
    $(packages) listed in OCAML_PREINSTALLED_PACKS are ignored.
    
    .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*
    
    .. note:: Usually you do not need to call this function. Use OCAMLPACKS variable instead. 

.. index::
    OCamlRequireCamlP4Packages()

**OCamlRequireCamlP4Packages(packages)**

    Add dependencies of OCaml dependency analysis and build over $(packages).
    Use this for adding dependencies for CamlP4 extensions.
    $(packages) listed in OCAML_PREINSTALLED_PACKS are ignored.
    
    .. note:: These functions introduce implicit rules: *you may need to export it, if you use this function in a local context.*
    
    .. note:: Usually you do not need to call this function. Use CAML4PACKS variable instead. 

.. index::
    single: %.auto.mli: %.ml

**%.auto.mli: %.ml**

    ``omake xxx.auto.mli`` generates .mli file from xxx.ml 

Build rules
==========================================================



.. index::
    MyOCamlPackage()

**MyOCamlPackage(library_name, files, cmodules, linkopts)**

    Add a rule for OCaml package $(library_name).cmo, $(library_name).cmx and etc.
       library_name
           target package name
       files
           ML module names (without .ml)
       cmodules
           C source files (without .c)
       linkopts
           C library link option (without OCaml -cclib options)    
    
    Example::
    
        MyOCamlPackage(foo, alpha beta, $(EMPTY), $(EMPTY))
    
    Todo: external C library


.. index::
    MyOCamlProgram()

**MyOCamlProgram(name, files)**

    Add a rule to build a program $(name)
        name
            Name of the program
        files
            OCaml module names (without .ml)

.. index::
    MyOCamlLibrary()

**MyOCamlLibrary(name, files)**

    Add rules to build OCaml library $(name)
         name
             Name of the library
         files
             OCaml module name (without .ml)
    
    .. note :: Probably you should use MyOCamlPackage

Subdir traversal
=====================================================================

.. index::
    Subdirs_except()

**Subdirs_except(dirs)**

    Recursively traverse the subdirs except $(dirs)

.. index::
    Subdirs()

**Subdirs()**

    Recursively traverse all the subdirs

.. index::
    Subdirs_only()

**Subdirs_only(dirs)**

    Recursively traverse the given subdirs $(dirs)

Dependency dot files for Graphviz
======================================================================

.. index::
    Dot()

**Dot()**

    Add a rule for ``depend.dot`` for a dependency graph of OCaml files in the current directory