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

OPTIONS

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

SEE ALSO

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