1OCAMLDSORT(1)               General Commands Manual              OCAMLDSORT(1)
2
3
4

NAME

6       ocamldsort - Dependency sorter for OCaml source files
7
8

SYNOPSIS

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

DESCRIPTION

15       The  ocamldsort(1)  command  scans a set of OCaml source files (.ml and
16       .mli files), sorts them according to their dependencies and prints  the
17       sorted files in order to link their corresponding .cmo files.
18
19       For  ocamldsort(1) to work it must get a list of dependencies generated
20       by ocamldep(1), if the standard input to ocamldsort(1) has  been  redi‐
21       rected then ocamldsort assumes that this is a dependency file generated
22       by ocamldep(1).  Otherwise ocamldsort calls ocamldep(1) to generate the
23       dependency  list  itself.  In either case the source files to be sorted
24       should be given as arguments to the ocamldsort(1) command.
25
26       ocamldsort(1) can be used to compile and link simple projects with  one
27       command, such as:
28
29       ocamlc $(ocamldsort *.ml)
30
31       if your project doesn't contain .mli files or:
32
33       ocamlc -c $(ocamldsort -mli *.ml *.mli) && ocamlc $(ocamldsort -byte *.ml)
34
35       if it contains .mli files.
36
37       However  for  larger  projects where separate compilation is desirable,
38       ocamldsort(1) can also be used from within a makefile. Here is a  typi‐
39       cal makefile example:
40
41       TARGET=my_program
42       OCAMLC=ocamlc
43       OCAMLOPT=ocamlopt
44       OCAMLDEP=ocamldep
45       OCAMLDSORT=ocamldsort
46
47       PPFLAGS=-pp camlp4o
48
49       MLY=$(shell echo *.mly)
50       MLL=$(shell echo *.mll)
51       GENERATED_ML=$(MLY:.mly=.ml) $(MLL:.mll=.ml)
52
53       include .generated .depend .ocamldsort
54
55       $(TARGET): $(CMO_FILES)
56            $(OCAMLC) $(COMPFLAGS) $(LIBS) $^ -o $@
57
58       $(TARGET).opt: $(CMX_FILES)
59            $(OCAMLOPT) $(COMPFLAGS) $(LIBS_OPT) $^ -o $@
60
61       .generated: $(GENERATED_ML)
62            @touch .generated
63
64       .depend: .generated
65            $(OCAMLDEP) *.ml *.mli > $@
66
67       .ocamldsort: .depend
68            echo CMO_FILES=`< .depend $(OCAMLDSORT) -byte *.ml` > .ocamldsort
69            echo CMX_FILES=`< .depend $(OCAMLDSORT) -opt *.ml` >> .ocamldsort
70
71       distclean: clean
72            rm -f .generated .depend .ocamldsort
73            rm -f $(GENERATED_ML)
74            rm -f *~
75            rm -f $(TARGET)
76
77       clean:
78            rm -f *.cmo *.cmi *.cmx *.o
79
80       .SUFFIXES: .mli .ml .cmi .cmo .cmx .mll .mly
81
82       %.cmi:%.mli
83            $(OCAMLC) $(PPFLAGS) $(COMPFLAGS) -c $<
84
85       %.cmo:%.ml
86            $(OCAMLC) $(PPFLAGS) $(COMPFLAGS) -c $<
87
88       %.cmi %.cmo:%.ml
89            $(OCAMLC) $(PPFLAGS) $(COMPFLAGS) -c $<
90
91       %.cmx %.o:%.ml
92            $(OCAMLOPT) $(PPFLAGS) $(COMPFLAGS) -c $<
93
94       %.ml:%.mll
95            $(OCAMLLEX) $<
96
97       %.mli %.ml:%.mly
98            $(OCAMLYACC) -v $<
99
100

OPTIONS

102       The following command-line options are recognized by ocamlsort(1):
103
104
105       -I directory
106              Add  the given directory to the list of directories searched for
107              source files.
108
109
110       -pp pre-command
111              Command to preprocess file.
112
113
114       -d dep-command
115              Command to compute dependencies.  ocamldep(1) by default.
116
117
118       -mli   Sort files using mli dependencies.
119
120
121       -nox   Ignore filenames containg `*' so that unexpanded  wildcards  are
122              ignored.
123
124
125       -obj   Print  bytecode  filenames  (.cmo  and  .cmi)  (deprecated:  use
126              -byte).
127
128
129       -byte  Print bytecode filenames (.cmo and .cmi).
130
131
132       -opt   Print opt filenames (.cmx and .cmi).
133
134
135       -v     Output version information and exit.
136
137
138       -help, --help
139              Output help and exit.
140
141

SEE ALSO

143       ocamldep(1).
144
145
146
147                                                                 OCAMLDSORT(1)
Impressum