OCAMLDSORT(1)

NAME
ocamldsort - Dependency sorter for OCaml source files

SYNOPSIS

ocamldsort [ -pp pre-command ] [ -d dep-command ]
         [ -mli ] [ -nox ] [ -obj | -byte | -opt ] [ filename ] ...

DESCRIPTION

The ocamldsort(1) command scans a set of Objective Caml source files (.ml and .mli files), sorts them according to their dependencies and prints the sorted files in order to link their corresponding .cmo files.

For ocamldsort(1) to work it must get a list of dependencies generated by ocamldep(1), if the standard input to ocamldsort(1) has been redirected then ocamldsort assumes that this is a dependency file generated by ocamldep(1). Otherwise ocamldsort calls ocamldep(1) to generate the dependency list itself. In either case the source files to be sorted should be given as arguments to the ocamldsort(1) command.

ocamldsort(1) can be used to compile and link simple projects with one command, such as:

ocamlc $(ocamldsort *.ml)

if your project doesn't contain .mli files or:

@nf ocamlc -c $(ocamldsort -mli *.ml *.mli) && ocamlc $(ocamldsort -byte *.ml) @fi @cc

if it contains .mli files.

However for larger projects where separate compilation is desirable, ocamldsort(1) can also be used from within a makefile. Here is a typical makefile example:

@nf TARGET=my_program OCAMLC=ocamlc OCAMLOPT=ocamlopt OCAMLDEP=ocamldep OCAMLDSORT=ocamldsort PPFLAGS=-pp camlp4o

CMO_FILES=$(shell < .depend ocamldsort $(PPFLAGS) -byte *.ml || echo ERROR) CMX_FILES=$(shell < .depend ocamldsort $(PPFLAGS) -opt *.ml || echo ERROR)

$(TARGET): $(CMO_FILES)
    $(OCAMLC) -o $@ $^

$(TARGET).opt: $(CMX_FILES)
    $(OCAMLOPT) -o $@ $^

ERROR:
    @echo Did you run `make depend'?
    @false

%.cmi:%.mli
    $(OCAMLC) $(PPFLAGS) -c $<

%.cmo:%.ml
    $(OCAMLC) $(PPFLAGS) -c $<

%.cmx:%.ml
    $(OCAMLOPT) $(PPFLAGS) -c $<

clean:
    rm *.cmo *.cmi *.cmx

depend:
    $(OCAMLDEP) $(PPFLAGS) *.ml *.mli > .depend

include .depend @fi @cc

OPTIONS

The following command-line options are recognized by ocamlsort(1):

-I directory
    Add the given directory to the list of directories searched for source files.

-pp pre-command
    Command to preprocess file.

-d dep-command
    Command to compute dependencies. ocamldep(1) by default.

-mli
    Sort files using mli dependencies.

-nox
    Ignore filenames containg `*' so that unexpanded wildcards are ignored.

-obj
    Print bytecode filenames (.cmo and .cmi) (deprecated: use -byte).

-byte
    Print bytecode filenames (.cmo and .cmi).

-opt
    Print opt filenames (.cmx and .cmi).

-v  Output version information and exit.

-help, --help
    Output help and exit.

SEE ALSO
ocamldep(1).