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