4a5f84f4d30360b26af8193205733470cc45feb7
[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 basic.ml symbol.ml aux.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/libsndfile
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
58 # Default setting of the WITH* variables. Should be changed if your
59 # local libraries are not found by the compiler.
60 #WITHGRAPHICS =graphics.cma -cclib -lgraphics -cclib -L/usr/X11R6/lib -cclib -lX11
61
62 #WITHUNIX =unix.cma -cclib -lunix
63
64 #WITHSTR =str.cma -cclib -lstr
65
66 #WITHNUMS =nums.cma -cclib -lnums
67
68 #WITHTHREADS =threads.cma -cclib -lthreads
69
70 #WITHDBM =dbm.cma -cclib -lmldbm -cclib -lndbm
71
72 WITHUNIX =unix.cma
73
74 WITHSNDFILE = sndfile.cma
75
76 WITHSTR = str.cma
77
78 # c++ wrap options
79 GPP_CALL = -cc "g++"
80
81 # The list of options for each compiler
82 CAMLC_OPTIONS = $(GPP_CALL) $(INCLUDE) $(LIBS)
83
84 CAMLOPT_OPTIONS = -p $(GPP_CALL) $(INCLUDE) $(LIBS:.cma=.cmxa)
85
86 CAMLDOC_OPTIONS = -d $(OCAML_DOC_PATH) -html $(INCLUDE)
87
88 CC_OPTIONS = -c -I$(PREPROCESSOR_INCLUDE_PATH) -I$(OCAML_INCLUDE_PATH)
89
90 ################ End of user's variables #####################
91
92
93 ##############################################################
94 ################ This part should be generic
95 ################ Nothing to set up or fix here
96 ##############################################################
97
98 all:: .depend.input .depend preprocessor $(EXEC)
99
100 opt : .depend.input .depend preprocessor $(EXEC).opt
101
102 doc : document
103
104 #ocamlc -INCLUDE other options graphics.cma other files -cclib -lgraphics -cclib -lX11
105 #ocamlc -thread -INCLUDE other options threads.cma other files -cclib -lthreads
106 #ocamlc -INCLUDE other options str.cma other files -cclib -lstr
107 #ocamlc -INCLUDE other options nums.cma other files -cclib -lnums
108 #ocamlc -INCLUDE other options unix.cma other files -cclib -lunix
109 #ocamlc -INCLUDE other options dbm.cma other files -cclib -lmldbm -cclib -lndbm
110
111 SMLIY = $(SOURCES:.mly=.ml)
112 SMLIYL = $(SMLIY:.mll=.ml)
113 SMLYL = $(filter %.ml, $(SMLIYL))
114 OBJS = $(SMLYL:.ml=.cmo)
115 OPTOBJS = $(OBJS:.cmo=.cmx)
116
117 CSOURCES = $(filter %.cpp, $(SOURCES))
118 COBJS = $(CSOURCES:.cpp=.o)
119 CLIBS = $(PREPROCESSOR_PATH)/preprocess.a
120
121 PARSER_MLY = $(filter %.mly, $(SOURCES))
122 LEXER_MLL = $(filter %.mll, $(SOURCES))
123 MIDDLE_ML = $(PARSER_MLY:.mly=.ml) $(LEXER_MLL:.mll=.ml)
124
125 preprocessor::
126 @echo "Compiling preprocessor..."
127 cd $(FAUST_PATH) && $(MAKE)
128
129 $(EXEC): $(OBJS) $(COBJS) $(CLIBS)
130 @echo "Compiling $(EXEC)..."
131 $(CAMLC) $(CAMLC_OPTIONS) -o $(EXEC) $(OBJS) $(COBJS) $(CLIBS)
132
133 $(EXEC).opt: $(OPTOBJS) $(COBJS) $(CLIBS)
134 @echo "Compiling optimized $(EXEC)..."
135 $(CAMLOPT) $(CAMLOPT_OPTIONS) -o $(EXEC) $(OPTOBJS) $(COBJS) $(CLIBS)
136
137 document: $(SMLYL) $(OBJS)
138 @echo "Compiling documentation..."
139 $(CAMLDOC) $(CAMLDOC_OPTIONS) $(SMLYL)
140
141 main.cmo: main.ml
142 $(CAMLC) $(INCLUDE) -c $<
143
144 main.cmx: main.ml
145 $(CAMLOPT) $(INCLUDE) -c $<
146
147 preprocess.cmo: preprocess.ml
148 $(CAMLC) $(GPP_CALL) -c $<
149
150 preprocess.cmx: preprocess.ml
151 $(CAMLOPT) $(GPP_CALL) -c $<
152
153 preprocess_stubs.o: preprocess_stubs.cpp
154 $(CC) $(CC_OPTIONS) $<
155
156 faustio.cmo: faustio.ml
157 $(CAMLC) $(INCLUDE) $(LIBS) -c $<
158
159 faustio.cmx: faustio.ml
160 $(CAMLOPT) $(INCLUDE) $(LIBS:.cma=.cmxa) -c $<
161
162 .SUFFIXES: .ml .mli .cmo .cmi .cmx .mll .mly
163
164 .ml.cmo:
165 $(CAMLC) -c $<
166
167 .mli.cmi:
168 $(CAMLC) -c $<
169
170 .ml.cmx:
171 $(CAMLOPT) -c $<
172
173 .mll.cmo:
174 $(CAMLLEX) $<
175 $(CAMLC) -c $*.ml
176
177 .mll.cmx:
178 $(CAMLLEX) $<
179 $(CAMLOPT) -c $*.ml
180
181 .mly.cmo:
182 $(CAMLYACC) $<
183 $(CAMLC) -c $*.mli
184 $(CAMLC) -c $*.ml
185
186 .mly.cmx:
187 $(CAMLYACC) $<
188 $(CAMLOPT) -c $*.mli
189 $(CAMLOPT) -c $*.ml
190
191 .mly.cmi:
192 $(CAMLYACC) $<
193 $(CAMLC) -c $*.mli
194
195 .mll.ml:
196 $(CAMLLEX) $<
197
198 .mly.ml:
199 $(CAMLYACC) $<
200
201 clean::
202 rm -f *.cm[iox] *~ .*~ #*#
203 rm -f $(MIDDLE_ML) *.o *.mli .depend*
204
205 mrproper: clean
206 rm -f $(EXEC)*
207
208 .depend.input: Makefile
209 @echo -n '--Checking Ocaml input files: '
210 @(ls $(SMLIY) $(SMLIY:.ml=.mli) 2>/dev/null || true) \
211 > .depend.new
212 @diff .depend.new .depend.input 2>/dev/null 1>/dev/null && \
213 (echo 'unchanged'; rm -f .depend.new) || \
214 (echo 'changed'; mv .depend.new .depend.input)
215
216 depend: .depend
217
218 .depend:: $(SMLIY) .depend.input
219 @echo '--Re-building dependencies'
220 $(CAMLDEP) $(SMLIY) $(SMLIY:.ml=.mli) > .depend
221
222 include .depend