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