56a213bf7167a55600ac1e8612013e64ec2d19b4
[Faustine.git] / interpretor / Makefile
1 ########################## User's variables #####################
2 #
3 # The Caml sources (including camlyacc and camllex source files)
4
5 SOURCES = types.ml parser.mly lexer.mll value.ml signal.ml faustexp.ml interpreter.ml preprocess.ml main.ml preprocess_stubs.cpp
6
7 # The executable file to generate
8
9 EXEC = faustine
10
11 # Path to ocaml include header files
12 export OCAML_INCLUDE_PATH
13
14 # Path to sndfile library
15 #SNDFILE_PATH = /home/wang/Desktop/libsndfile-ocaml
16 export SNDFILE_PATH
17
18 # Path to Faust.mr3
19 FAUST_PATH = 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)
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 # c++ wrap options
77 GPP_CALL = -cc "g++"
78
79 # The list of options for each compiler
80 CAMLC_OPTIONS = $(GPP_CALL) $(INCLUDE) $(LIBS)
81
82 CAMLOPT_OPTIONS = -p $(GPP_CALL) $(INCLUDE) $(LIBS:.cma=.cmxa)
83
84 CAMLDOC_OPTIONS = -d $(OCAML_DOC_PATH) -html $(INCLUDE)
85 CC_OPTIONS = -c -I$(PREPROCESSOR_INCLUDE_PATH) -I$(OCAML_INCLUDE_PATH)
86
87 ################ End of user's variables #####################
88
89
90 ##############################################################
91 ################ This part should be generic
92 ################ Nothing to set up or fix here
93 ##############################################################
94
95 all:: .depend.input .depend preprocessor $(EXEC)
96
97 opt : .depend.input .depend preprocessor $(EXEC).opt
98
99 doc : document
100
101 #ocamlc -INCLUDE other options graphics.cma other files -cclib -lgraphics -cclib -lX11
102 #ocamlc -thread -INCLUDE other options threads.cma other files -cclib -lthreads
103 #ocamlc -INCLUDE other options str.cma other files -cclib -lstr
104 #ocamlc -INCLUDE other options nums.cma other files -cclib -lnums
105 #ocamlc -INCLUDE other options unix.cma other files -cclib -lunix
106 #ocamlc -INCLUDE other options dbm.cma other files -cclib -lmldbm -cclib -lndbm
107
108 SMLIY = $(SOURCES:.mly=.ml)
109 SMLIYL = $(SMLIY:.mll=.ml)
110 SMLYL = $(filter %.ml, $(SMLIYL))
111 OBJS = $(SMLYL:.ml=.cmo)
112 OPTOBJS = $(OBJS:.cmo=.cmx)
113
114 CSOURCES = $(filter %.cpp, $(SOURCES))
115 COBJS = $(CSOURCES:.cpp=.o)
116 CLIBS = $(PREPROCESSOR_PATH)/preprocess.a
117
118 PARSER_MLY = $(filter %.mly, $(SOURCES))
119 LEXER_MLL = $(filter %.mll, $(SOURCES))
120 MIDDLE_ML = $(PARSER_MLY:.mly=.ml) $(LEXER_MLL:.mll=.ml)
121
122 preprocessor:
123 @(cd $(FAUST_PATH) && $(MAKE))
124
125 $(EXEC): $(OBJS) $(COBJS)
126 $(CAMLC) $(CAMLC_OPTIONS) -o $(EXEC) $(OBJS) $(COBJS) $(CLIBS)
127
128 $(EXEC).opt: $(OPTOBJS) $(COBJS)
129 $(CAMLOPT) $(CAMLOPT_OPTIONS) -o $(EXEC) $(OPTOBJS) $(COBJS) $(CLIBS)
130
131 document: $(SMLYL) $(OBJS)
132 $(CAMLDOC) $(CAMLDOC_OPTIONS) $(SMLYL)
133
134 main.cmo: main.ml
135 $(CAMLC) $(INCLUDE) -c $<
136
137 main.cmx: main.ml
138 $(CAMLOPT) $(INCLUDE) -c $<
139
140 preprocess.cmo: preprocess.ml
141 $(CAMLC) $(GPP_CALL) -c $<
142
143 preprocess.cmx: preprocess.ml
144 $(CAMLOPT) $(GPP_CALL) -c $<
145
146 preprocess_stubs.o: preprocess_stubs.cpp
147 $(CC) $(CC_OPTIONS) $<
148
149 .SUFFIXES: .ml .mli .cmo .cmi .cmx .mll .mly
150
151 .ml.cmo:
152 $(CAMLC) -c $<
153
154 .mli.cmi:
155 $(CAMLC) -c $<
156
157 .ml.cmx:
158 $(CAMLOPT) -c $<
159
160 .mll.cmo:
161 $(CAMLLEX) $<
162 $(CAMLC) -c $*.ml
163
164 .mll.cmx:
165 $(CAMLLEX) $<
166 $(CAMLOPT) -c $*.ml
167
168 .mly.cmo:
169 $(CAMLYACC) $<
170 $(CAMLC) -c $*.mli
171 $(CAMLC) -c $*.ml
172
173 .mly.cmx:
174 $(CAMLYACC) $<
175 $(CAMLOPT) -c $*.mli
176 $(CAMLOPT) -c $*.ml
177
178 .mly.cmi:
179 $(CAMLYACC) $<
180 $(CAMLC) -c $*.mli
181
182 .mll.ml:
183 $(CAMLLEX) $<
184
185 .mly.ml:
186 $(CAMLYACC) $<
187
188 clean::
189 rm -f *.cm[iox] *~ .*~ #*#
190 rm -f $(MIDDLE_ML) *.o *.mli .depend*
191
192 mrproper: clean
193 rm -f $(EXEC)*
194
195 .depend.input: Makefile
196 @echo -n '--Checking Ocaml input files: '
197 @(ls $(SMLIY) $(SMLIY:.ml=.mli) 2>/dev/null || true) \
198 > .depend.new
199 @diff .depend.new .depend.input 2>/dev/null 1>/dev/null && \
200 (echo 'unchanged'; rm -f .depend.new) || \
201 (echo 'changed'; mv .depend.new .depend.input)
202
203 depend: .depend
204
205 .depend:: $(SMLIY) .depend.input
206 @echo '--Re-building dependencies'
207 $(CAMLDEP) $(SMLIY) $(SMLIY:.ml=.mli) > .depend
208
209 include .depend