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(packs)

Installed(packs)

    Returns the installation mark files of $(packs)

.. index::
    CreateInstalled(pack, targets)

CreateInstalled(pack, targets)

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

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

.. index::
    mkdir_if_not_exists(dir)

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: OCAMLFIND_PREINSTALLED_PACKAGES[]

OCAMLFIND_PREINSTALLED_PACKAGES[]
    
    ::     
    
        =  bigarray camlp4 dbm dynlink graphics num num-top stdlib str threads unix

    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
      
      OCAMLFIND_PREINSTALLED_PACKAGES += findlib # findlib has been installed already, independently
      
      Subdirs()


.. 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



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(packages)

RequirePackages(packages)

    Add dependencies of any build activity over $(packages).
    This introduces implicit rule: *you may need to export it, if you use this function in a local context.*

.. index::
    OCamlRequirePackages(packages)

OCamlRequirePackages(packages)

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

.. index::
    OCamlRequireCamlP4Packages(packages)

OCamlRequireCamlP4Packages(packages)

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

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


%.auto.mli: %.ml

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

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



.. index::
    MyOCamlPackage(library_name, files, cmodules, linkopts)

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(name, files)

MyOCamlProgram(name, files)

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

.. index::
    MyOCamlLibrary(name, files)

MyOCamlLibrary(name, files)

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

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

.. index::
    Subdirs_except(dirs)

Subdirs_except(dirs)

    Recursively traverse the subdirs except $(dirs)

.. index::
    Subdirs()

Subdirs()

    Recursively traverse all the subdirs

.. index::
    Subdirs_only(dirs)

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