Examples' Makefiles are completed and tested.
[Faustine.git] / interpretor / Makefile
1 # Faustine interpreter Makefile.
2
3 ########################## User's variables #####################
4 #
5 # The Caml sources (including camlyacc and camllex source files)
6
7 SOURCES = types.ml parser.mly lexer.mll aux.ml basic.ml symbol.ml value.ml signal.ml beam.ml process.ml faustio.ml preprocess.ml main.ml preprocess_stubs.cpp
8
9 # The executable file to generate
10 EXEC = faustine
11
12 # Path to ocaml include header files
13 OCAML_INCLUDE_PATH := $(subst bin,lib,$(shell which ocaml))
14
15 # Path to sndfile library
16 SNDFILE_PATH := lib
17
18 # Path to sndfile-ocaml library
19 SNDFILE_OCAML_PATH := $(SNDFILE_PATH)/src/libsndfile-ocaml
20
21 # Path to Faust.mr3
22 FAUST_PATH = preprocessor/faust-0.9.47mr3
23
24 # Path to preprocessor library
25 PREPROCESSOR_PATH = $(FAUST_PATH)/compiler
26
27 # Path to preprocessor header files
28 PREPROCESSOR_INCLUDE_PATH = $(PREPROCESSOR_PATH)/headers
29
30 # Path to the interpretor documentation
31 OCAML_DOC_PATH = ../documentation
32
33 ########################## Advanced user's variables #####################
34 #
35 # The Caml compilers.
36 # You may fix here the path to access the Caml compiler on your machine
37 # You may also have to add various -I options.
38 CAMLC = ocamlc
39 CAMLOPT = ocamlopt
40 CAMLDEP = ocamldep
41 CAMLLEX = ocamllex
42 CAMLYACC = ocamlyacc
43 CAMLDOC = ocamldoc
44 CC = g++
45
46 # The list of Caml libraries needed by the program
47 # For instance:
48 # LIBS=$(WITHGRAPHICS) $(WITHUNIX) $(WITHSTR) $(WITHNUMS) $(WITHTHREADS)\
49 # $(WITHDBM)
50
51 LIBS = $(WITHSNDFILE) $(WITHUNIX) $(WITHSTR)
52
53 # Should be set to -INCLUDE if you use any of the libraries above
54 # or if any C code have to be linked with your program
55 # (irrelevant for ocamlopt)
56
57 # INCLUDE=-INCLUDE
58
59 INCLUDE = -I $(SNDFILE_OCAML_PATH)
60 SNDFILE_STUB := $(SNDFILE_OCAML_PATH)/sndfile_stub.o
61
62 # Default setting of the WITH* variables. Should be changed if your
63 # local libraries are not found by the compiler.
64 #WITHGRAPHICS =graphics.cma -cclib -lgraphics -cclib -L/usr/X11R6/lib -cclib -lX11
65
66 #WITHUNIX =unix.cma -cclib -lunix
67
68 #WITHSTR =str.cma -cclib -lstr
69
70 #WITHNUMS =nums.cma -cclib -lnums
71
72 #WITHTHREADS =threads.cma -cclib -lthreads
73
74 #WITHDBM =dbm.cma -cclib -lmldbm -cclib -lndbm
75
76 WITHUNIX =unix.cma
77
78 WITHSNDFILE = sndfile.cma
79
80 WITHSTR = str.cma
81
82 # c++ wrap options
83 GPP_CALL = -cc "g++"
84
85 # The list of options for each compiler
86 CAMLC_OPTIONS = $(GPP_CALL) $(INCLUDE) $(LIBS)
87
88 CAMLOPT_OPTIONS = -p $(GPP_CALL) $(INCLUDE) $(LIBS:.cma=.cmxa)
89
90 CAMLDOC_OPTIONS = -d $(OCAML_DOC_PATH) -html $(INCLUDE)
91
92 CC_OPTIONS = -c -I$(PREPROCESSOR_INCLUDE_PATH) -I$(OCAML_INCLUDE_PATH)
93
94 ################ End of user's variables #####################
95
96
97 ##############################################################
98 ################ This part should be generic
99 ################ Nothing to set up or fix here
100 ##############################################################
101
102 all:: .depend.input .depend preprocessor libsndfile-ocaml $(EXEC)
103
104 opt : .depend.input .depend preprocessor libsndfile-ocaml $(EXEC).opt
105
106 doc : document
107
108 #ocamlc -INCLUDE other options graphics.cma other files -cclib -lgraphics -cclib -lX11
109 #ocamlc -thread -INCLUDE other options threads.cma other files -cclib -lthreads
110 #ocamlc -INCLUDE other options str.cma other files -cclib -lstr
111 #ocamlc -INCLUDE other options nums.cma other files -cclib -lnums
112 #ocamlc -INCLUDE other options unix.cma other files -cclib -lunix
113 #ocamlc -INCLUDE other options dbm.cma other files -cclib -lmldbm -cclib -lndbm
114
115 SMLIY = $(SOURCES:.mly=.ml)
116 SMLIYL = $(SMLIY:.mll=.ml)
117 SMLYL = $(filter %.ml, $(SMLIYL))
118 OBJS = $(SMLYL:.ml=.cmo)
119 MLYS = $(filter %.mly, $(SOURCES))
120 MLIS = $(MLYS:.mly=.mli)
121 OPTOBJS = $(OBJS:.cmo=.cmx)
122
123 CSOURCES = $(filter %.cpp, $(SOURCES))
124 COBJS = $(CSOURCES:.cpp=.o)
125 CLIBS = $(PREPROCESSOR_PATH)/preprocess.a
126
127 PARSER_MLY = $(filter %.mly, $(SOURCES))
128 LEXER_MLL = $(filter %.mll, $(SOURCES))
129 MIDDLE_ML = $(PARSER_MLY:.mly=.ml) $(LEXER_MLL:.mll=.ml)
130
131 preprocessor::
132 @echo "Compiling preprocessor..."
133 $(MAKE) -C $(FAUST_PATH) preprocessor
134
135 libsndfile-ocaml::
136 @echo "Compiling libsndfile-ocaml..."
137 $(MAKE) -C $(SNDFILE_PATH)
138
139
140 $(EXEC): $(OBJS) $(COBJS) $(CLIBS)
141 @echo "Compiling $(EXEC)..."
142 cp $(SNDFILE_STUB) .
143 $(CAMLC) $(CAMLC_OPTIONS) -o $(EXEC) $(OBJS) $(COBJS) $(CLIBS)
144
145 $(EXEC).opt: $(OPTOBJS) $(COBJS) $(CLIBS)
146 @echo "Compiling optimized $(EXEC)..."
147 cp $(SNDFILE_STUB) .
148 $(CAMLOPT) $(CAMLOPT_OPTIONS) -o $(EXEC) $(OPTOBJS) $(COBJS) $(CLIBS)
149
150 document: $(SMLYL) $(OBJS)
151 @echo "Compiling documentation..."
152 $(CAMLDOC) $(CAMLDOC_OPTIONS) $(SMLYL)
153
154 main.cmo: main.ml
155 $(CAMLC) $(INCLUDE) -c $<
156
157 main.cmx: main.ml
158 $(CAMLOPT) $(INCLUDE) -c $<
159
160 preprocess.cmo: preprocess.ml
161 $(CAMLC) $(GPP_CALL) -c $<
162
163 preprocess.cmx: preprocess.ml
164 $(CAMLOPT) $(GPP_CALL) -c $<
165
166 preprocess_stubs.o: preprocess_stubs.cpp
167 $(CC) $(CC_OPTIONS) $<
168
169 faustio.cmo: faustio.ml
170 $(CAMLC) $(INCLUDE) $(LIBS) -c $<
171
172 faustio.cmx: faustio.ml
173 $(CAMLOPT) $(INCLUDE) $(LIBS:.cma=.cmxa) -c $<
174
175 .SUFFIXES: .ml .mli .cmo .cmi .cmx .mll .mly
176
177 .ml.cmo:
178 $(CAMLC) -c $<
179
180 .mli.cmi:
181 $(CAMLC) -c $<
182
183 .ml.cmx:
184 $(CAMLOPT) -c $<
185
186 .mll.cmo:
187 $(CAMLLEX) $<
188 $(CAMLC) -c $*.ml
189
190 .mll.cmx:
191 $(CAMLLEX) $<
192 $(CAMLOPT) -c $*.ml
193
194 .mly.cmo:
195 $(CAMLYACC) $<
196 $(CAMLC) -c $*.mli
197 $(CAMLC) -c $*.ml
198
199 .mly.cmx:
200 $(CAMLYACC) $<
201 $(CAMLOPT) -c $*.mli
202 $(CAMLOPT) -c $*.ml
203
204 .mly.cmi:
205 $(CAMLYACC) $<
206 $(CAMLC) -c $*.mli
207
208 .mll.ml:
209 $(CAMLLEX) $<
210
211 .mly.ml:
212 $(CAMLYACC) $<
213
214 clean::
215 rm -f *.cm[iox] *~ .*~
216 rm -f $(MIDDLE_ML) *.o $(MLIS) # .depend*
217 @$(MAKE) -C $(SNDFILE_PATH) clean
218
219 mrproper: clean
220 @$(MAKE) -C $(SNDFILE_PATH) mrproper
221 rm -f $(EXEC)* .depend*
222
223 .depend.input: Makefile
224 @echo -n '--Checking Ocaml input files: '
225 @(ls $(SMLIY) $(SMLIY:.ml=.mli) 2>/dev/null || true) \
226 > .depend.new
227 @diff .depend.new .depend.input 2>/dev/null 1>/dev/null && \
228 (echo 'unchanged'; rm -f .depend.new) || \
229 (echo 'changed'; mv .depend.new .depend.input)
230
231 depend: .depend
232
233 .depend:: $(SMLIY) .depend.input
234 @echo '--Re-building dependencies'
235 $(CAMLDEP) $(SMLIY) $(SMLIY:.ml=.mli) > .depend
236
237 include .depend