-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
242 lines (188 loc) · 6.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#*********************************************************************#
# #
# Objective Caml #
# #
# Pierre Weis, projet Cristal, INRIA Rocquencourt #
# #
# Copyright 1998 Institut National de Recherche en Informatique et #
# en Automatique. Distributed only by permission. #
# #
#*********************************************************************#
#
# Modified by Didier Remy
#
# Generic Makefile for Objective Caml Programs
############################ Documentation ######################
#
# To use this Makefile:
# -- You must fix the value of the variable SOURCES below.
# (The variable SOURCES is the list of your Caml source files.)
# -- You must create a file .depend, using
# $touch .depend
# (This file will contain the dependancies between your Caml modules,
# automatically computed by this Makefile.)
# Usage of this Makefile:
# To incrementally recompile the system, type
# make
# To recompute dependancies between modules, type
# make depend
# To remove the executable and all the compiled files, type
# make clean
# To compile using the native code compiler
# make opt
#
##################################################################
##################################################################
#
# Advanced usage:
# ---------------
# If you want to fix the name of the executable, set the variable
# EXEC, for instance, if you want to obtain a program named my_prog:
# EXEC = my_prog
# If you need special libraries provided with the Caml system,
# (graphics, arbitrary precision numbers, regular expression on strings, ...),
# you must set the variable LIBS to the proper set of libraries. For
# instance, to use the graphics library set LIBS to $(WITHGRAPHICS):
# LIBS=$(WITHGRAPHICS)
# You may use any of the following predefined variable
# WITHGRAPHICS : provides the graphics library
# WITHUNIX : provides the Unix interface library
# WITHSTR : provides the regular expression string manipulation library
# WITHNUMS : provides the arbitrary precision arithmetic package
# WITHTHREADS : provides the byte-code threads library
# WITHDBM : provides the Data Base Manager library
#
#
########################## End of Documentation ####################
########################## User's variables #####################
#
# The Caml sources (including camlyacc and camllex source files)
SOURCES = \
src/ord.ml \
src/mystack.ml \
src/mystack_test.ml \
src/trie.ml \
src/trie_test.ml \
src/setoid.ml \
src/setoid_test.ml \
src/functor.ml \
src/functor_test.ml \
src/algebra.ml \
src/algebra_test.ml \
src/myqueue.ml \
src/myqueue_test.ml \
src/finite_state_machine.ml \
src/finite_state_machine_test.ml \
src/wire.ml \
src/wire_test.ml \
src/binary_search_tree.ml \
src/binary_search_tree_test.ml \
src/red_black_tree.ml \
src/red_black_tree_test.ml \
src/levenshtein.ml \
src/levenshtein_test.ml \
src/binary_heap.ml \
src/binary_heap_test.ml \
src/huffman_coding.ml \
src/huffman_coding_test.ml
# The executable file to generate
EXEC = run_tests
########################## Advanced user's variables #####################
#
# The Caml compilers.
# You may fix here the path to access the Caml compiler on your machine
# You may also have to add various -I options.
INCLUDES = -I src
CAMLC = ocamlc -rectypes $(INCLUDES)
CAMLOPT = ocamlopt $(INCLUDES)
CAMLDEP = ocamldep $(INCLUDES)
CAMLLEX = ocamllex $(INCLUDES)
CAMLYACC = ocamlyacc $(INCLUDES)
# The list of Caml libraries needed by the program
# For instance:
# LIBS=$(WITHGRAPHICS) $(WITHUNIX) $(WITHSTR) $(WITHNUMS) $(WITHTHREADS)\
# $(WITHDBM)
# LIBS=$(WITHGRAPHICS)
# Should be set to -custom if you use any of the libraries above
# or if any C code have to be linked with your program
# (irrelevant for ocamlopt)
# CUSTOM=-custom
# Default setting of the WITH* variables. Should be changed if your
# local libraries are not found by the compiler.
WITHGRAPHICS =graphics.cma -cclib -lgraphics -cclib -L/usr/X11R6/lib -cclib -lX11
WITHUNIX =unix.cma -cclib -lunix
WITHSTR =str.cma -cclib -lstr
WITHNUMS =nums.cma -cclib -lnums
WITHTHREADS =threads.cma -cclib -lthreads
WITHDBM =dbm.cma -cclib -lmldbm -cclib -lndbm
################ End of user's variables #####################
##############################################################
################ This part should be generic
################ Nothing to set up or fix here
##############################################################
all:: .depend.input .depend $(EXEC)
opt : $(EXEC).opt
.PHONY: test docs
test: $(EXEC)
@./$(EXEC) && echo "All tests pass"
docs: $(EXEC)
ocamldoc -I src -html -rectypes -d docs $(SOURCES)
#ocamlc -custom other options graphics.cma other files -cclib -lgraphics -cclib -lX11
#ocamlc -thread -custom other options threads.cma other files -cclib -lthreads
#ocamlc -custom other options str.cma other files -cclib -lstr
#ocamlc -custom other options nums.cma other files -cclib -lnums
#ocamlc -custom other options unix.cma other files -cclib -lunix
#ocamlc -custom other options dbm.cma other files -cclib -lmldbm -cclib -lndbm
SMLIY = $(SOURCES:.mly=.ml)
SMLIYL = $(SMLIY:.mll=.ml)
SMLYL = $(filter %.ml,$(SMLIYL))
OBJS = $(SMLYL:.ml=.cmo)
OPTOBJS = $(OBJS:.cmx=.cmx)
$(EXEC): $(OBJS)
$(CAMLC) $(CUSTOM) -o $(EXEC) $(LIBS) $(OBJS)
# $(EXEC)-opt: $(OPTOBJS)
# $(CAMLOPT) -o $(EXEC) $(LIBS:.cma=.cmxa) $(OPTOBJS)
.SUFFIXES: .ml .mli .cmo .cmi .cmx .mll .mly
.ml.cmo:
$(CAMLC) -c $<
.mli.cmi:
$(CAMLC) -c $<
.ml.cmx:
$(CAMLOPT) -c $<
.mll.cmo:
$(CAMLLEX) $<
$(CAMLC) -c $*.ml
.mll.cmx:
$(CAMLLEX) $<
$(CAMLOPT) -c $*.ml
.mly.cmo:
$(CAMLYACC) $<
$(CAMLC) -c $*.mli
$(CAMLC) -c $*.ml
.mly.cmx:
$(CAMLYACC) $<
$(CAMLOPT) -c $*.mli
$(CAMLOPT) -c $*.ml
.mly.cmi:
$(CAMLYACC) $<
$(CAMLC) -c $*.mli
.mll.ml:
$(CAMLLEX) $<
.mly.ml:
$(CAMLYACC) $<
clean::
rm -f **/*.cm[iox] *~ .*~ #*#
rm -f $(EXEC)
rm -f $(EXEC).opt
.depend.input: Makefile
@echo -n '--Checking Ocaml input files: '
@(ls $(SMLIY) $(SMLIY:.ml=.mli) 2>/dev/null || true) \
> .depend.new
@diff .depend.new .depend.input 2>/dev/null 1>/dev/null && \
(echo 'unchanged'; rm -f .depend.new) || \
(echo 'changed'; mv .depend.new .depend.input)
depend: .depend
.depend:: $(SMLIY) .depend.input
@echo '--Re-building dependencies'
$(CAMLDEP) $(SMLIY) $(SMLIY:.ml=.mli) > .depend
-include .depend