Revert "OCaml build: enforce .mli generation to clean-build in parallel"
[scilab.git] / scilab / modules / scicos / Makefile.modelica.am
1 # Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 # Copyright (C) 2008 - INRIA - Sylvestre Ledru <sylvestre.ledru@inria.fr>
3 # Copyright (C) 2010 - DIGITEO - Sylvestre Ledru
4 # Copyright (C) 2014 - Scilab Enterprises - Clement DAVID
5 #
6 # Copyright (C) 2012 - 2016 - Scilab Enterprises
7 #
8 # This file is hereby licensed under the terms of the GNU GPL v2.0,
9 # pursuant to article 5.3.4 of the CeCILL v.2.1.
10 # This file was originally licensed under the terms of the CeCILL v2.1,
11 # and continues to be available under such terms.
12 # For more information, see the COPYING file which you should have received
13 # along with this program.
14
15 # TODO:
16 # * see if we can do more factorization (on the lexer for example)
17
18 ######### Common Modelica elements #############
19
20 if XCOS
21 if OCAML
22 TARGET = modelicac XML2Modelica modelicat
23 BASE_PATH = $(srcdir)/src/
24 bin_PROGRAMS = $(TARGET)
25 OCAMLLIBS=nums.cma
26
27
28 ### XML2Modelica
29
30 XML2Modelica_SOURCES = \
31         $(srcdir)/src/xml2modelica/xMLTree.ml \
32         $(srcdir)/src/xml2modelica/linenum.mll \
33         $(srcdir)/src/xml2modelica/stringParser.ml \
34         $(srcdir)/src/xml2modelica/stringLexer.ml \
35         $(srcdir)/src/xml2modelica/xMLParser.ml \
36         $(srcdir)/src/xml2modelica/xMLLexer.ml \
37         $(srcdir)/src/xml2modelica/modelicaCodeGenerator.ml \
38         $(srcdir)/src/xml2modelica/xML2Modelica.ml
39
40 XML2Modelica_SOURCES_mly = $(XML2Modelica_SOURCES:.mly=.ml)
41 MLS_XML2Modelica = $(XML2Modelica_SOURCES_mly:.mll=.ml)
42 MLIS_XML2Modelica = $(MLS_XML2Modelica:.ml=.mli)
43
44 BASE_PATH_XML2Modelica = $(srcdir)/src/xml2modelica
45
46
47 ### Translator
48
49 modelicat_SOURCES = \
50         $(srcdir)/src/translator/parsing/syntax.ml \
51         $(srcdir)/src/translator/parsing/parser.mly \
52         $(srcdir)/src/translator/parsing/lexer.mll \
53         $(srcdir)/src/translator/parsing/linenum.mll \
54         $(srcdir)/src/translator/compilation/types.ml \
55         $(srcdir)/src/translator/compilation/nameResolve.ml \
56         $(srcdir)/src/translator/instantiation/instantiation.ml \
57         $(srcdir)/src/translator/exceptionHandling/msgDico.ml \
58         $(srcdir)/src/translator/exceptionHandling/errorDico.ml \
59         $(srcdir)/src/translator/exceptionHandling/exceptHandler.ml \
60         $(srcdir)/src/translator/translation/libraryManager.ml \
61         $(srcdir)/src/translator/translation/codeGeneration.ml \
62         $(srcdir)/src/translator/translation/versiondate.ml \
63         $(srcdir)/src/translator/translation/translator.ml
64
65 modelicat_SOURCES_mly = $(modelicat_SOURCES:.mly=.ml)
66 MLS_modelicat = $(modelicat_SOURCES_mly:.mll=.ml)
67 MLIS_modelicat = $(MLS_modelicat:.ml=.mli)
68
69 INCLUDE_modelicat = -I $(srcdir)/src/translator/compilation \
70 -I $(srcdir)/src/translator/exceptionHandling \
71 -I $(srcdir)/src/translator/parsing \
72 -I $(srcdir)/src/translator/instantiation \
73 -I $(srcdir)/src/translator/translation
74
75 ### Modelicac
76
77 modelicac_SOURCES = \
78         $(srcdir)/src/modelica_compiler/parseTree.ml \
79         $(srcdir)/src/modelica_compiler/linenum.mll \
80         $(srcdir)/src/modelica_compiler/parser.mly \
81         $(srcdir)/src/modelica_compiler/lexer.mll \
82         $(srcdir)/src/modelica_compiler/precompilation.ml \
83         $(srcdir)/src/modelica_compiler/compilation.ml \
84         $(srcdir)/src/modelica_compiler/instantiation.ml \
85         $(srcdir)/src/modelica_compiler/graphNodeSet.ml \
86         $(srcdir)/src/modelica_compiler/symbolicExpression.ml \
87         $(srcdir)/src/modelica_compiler/squareSparseMatrix.ml \
88         $(srcdir)/src/modelica_compiler/bipartiteGraph.ml \
89         $(srcdir)/src/modelica_compiler/hungarianMethod.ml \
90         $(srcdir)/src/modelica_compiler/causalityGraph.ml \
91         $(srcdir)/src/modelica_compiler/optimization.ml \
92         $(srcdir)/src/modelica_compiler/xMLCodeGeneration.ml \
93         $(srcdir)/src/modelica_compiler/optimizingCompiler.ml \
94         $(srcdir)/src/modelica_compiler/scicosCodeGeneration.ml \
95         $(srcdir)/src/modelica_compiler/scicosOptimizingCompiler.ml
96
97 modelicac_SOURCES_mly = $(modelicac_SOURCES:.mly=.ml)
98 MLS_modelicac = $(modelicac_SOURCES_mly:.mll=.ml)
99 MLIS_modelicac = $(MLS:.ml=.mli)
100
101 BASE_PATH_MODELICAC = $(srcdir)/src/modelica_compiler
102
103 INCLUDE = -I $(BASE_PATH_MODELICAC) -I $(BASE_PATH_XML2Modelica)
104
105 ########## COMMON
106 SUFFIXES += .ml .mli .mll .mly .cmo .cmi .cmx
107
108 # @TODO check how to avoid the rebuild of the parser/lexer
109
110 .cmi.cmo:
111         @if echo "$<"|grep src/translator; then \
112                 echo $(OCAMLC) $(INCLUDE_modelicat) $(OCAMLCFLAGS) -c $*.ml; \
113                 $(OCAMLC) $(INCLUDE_modelicat) $(OCAMLCFLAGS) -c $*.ml; \
114         else \
115                 echo $(OCAMLC) $(INCLUDE) $(OCAMLCFLAGS) -c $*.ml; \
116                 $(OCAMLC) $(INCLUDE) $(OCAMLCFLAGS) -c $*.ml; \
117         fi
118
119 .cmi.cmx:
120         @if echo "$<"|grep src/translator; then \
121                 echo $(OCAMLOPT) $(INCLUDE_modelicat) $(OCAMLOPTFLAGS) -c $*.ml; \
122                 $(OCAMLOPT) $(INCLUDE_modelicat) $(OCAMLOPTFLAGS) -c $*.ml; \
123         else \
124                 echo $(OCAMLOPT) $(INCLUDE) $(OCAMLOPTFLAGS) -c $*.ml; \
125                 $(OCAMLOPT) $(INCLUDE) $(OCAMLOPTFLAGS) -c $*.ml; \
126         fi
127
128 .mli.cmi:
129         @if echo "$<"|grep src/translator; then \
130                 echo $(OCAMLC) $(INCLUDE_modelicat) $(OCAMLCFLAGS) -c $<; \
131                 $(OCAMLC) $(INCLUDE_modelicat) $(OCAMLCFLAGS) -c $<; \
132         else \
133                 echo $(OCAMLC) $(INCLUDE) $(OCAMLCFLAGS) -c $<; \
134                 $(OCAMLC) $(INCLUDE) $(OCAMLCFLAGS) -c $<; \
135         fi
136
137 .ml.mli:
138         @if echo "$<"|grep src/translator; then \
139                 echo $(OCAMLC) $(INCLUDE_modelicat) $(OCAMLCFLAGS) -i $< > $@; \
140                 $(OCAMLC) $(INCLUDE_modelicat) $(OCAMLCFLAGS) -i $< > $@; \
141         else \
142                 echo $(OCAMLC) $(INCLUDE) $(OCAMLCFLAGS) -i $< > $@; \
143                 $(OCAMLC) $(INCLUDE) $(OCAMLCFLAGS) -i $< > $@; \
144         fi
145
146 .mll.ml:
147         $(OCAMLLEX) $<
148
149 .mly.ml:
150         $(OCAMLYACC) $<
151         @rm $*.mli
152
153 # Build the binaries, disabling parallel building
154
155 modelicac: $(modelicac_SOURCES)
156         $(MAKE) MAKEFLAGS=-j1 $(MLS_modelicac:.ml=.cmx)
157         $(OCAMLOPT) -o $@ $(INCLUDE) $(OCAMLOPTFLAGS) $(OCAMLLIBS:.cma=.cmxa) $(MLS_modelicac:.ml=.cmx)
158
159 modelicac.ocamlc: $(modelicac_SOURCES)
160         $(MAKE) MAKEFLAGS=-j1 $(MLS_modelicac:.ml=.cmo)
161         $(OCAMLC) -o $@ $(INCLUDE) $(OCAMLOPTFLAGS) $(OCAMLLIBS) $(MLS_modelicac:.ml=.cmo)
162
163 XML2Modelica: $(XML2Modelica_SOURCES)
164         $(MAKE) MAKEFLAGS=-j1 $(MLS_XML2Modelica:.ml=.cmx)
165         $(OCAMLOPT) -o $@ $(INCLUDE) $(OCAMLCFLAGS) $(OCAMLLIBS:.cma=.cmxa) $(MLS_XML2Modelica:.ml=.cmx)
166
167 XML2Modelica.ocamlc: $(XML2Modelica_SOURCES)
168         $(MAKE) MAKEFLAGS=-j1 $(MLS_XML2Modelica:.ml=.cmo)
169         $(OCAMLC) -o $@ $(INCLUDE) $(OCAMLCFLAGS) $(OCAMLLIBS) $(MLS_XML2Modelica:.ml=.cmo)
170
171 modelicat: $(modelicat_SOURCES)
172         $(MAKE) MAKEFLAGS=-j1 $(MLS_modelicat:.ml=.cmx)
173         $(OCAMLOPT) -o $@ $(INCLUDE_modelicat) $(OCAMLOPTFLAGS) $(OCAMLLIBS:.cma=.cmxa) $(MLS_modelicat:.ml=.cmx)
174
175 modelicat.ocamlc: $(modelicat_SOURCES)
176         $(MAKE) MAKEFLAGS=-j1 $(MLS_modelicat:.ml=.cmo)
177         $(OCAMLC) -o $@ $(INCLUDE_modelicat) $(OCAMLOPTFLAGS) $(OCAMLLIBS) $(MLS_modelicat:.ml=.cmo)
178
179 CLEANFILES = $(BASE_PATH)/*/*.cmi \
180         $(BASE_PATH)/*/*.o \
181         $(BASE_PATH)/*/*.cmo \
182         $(BASE_PATH)/*/*.cm[aiox] \
183         $(BASE_PATH)/*/parser.mli \
184         $(BASE_PATH)/*/lexer.mli \
185         $(BASE_PATH)/*/linenum.mli \
186         $(BASE_PATH)/*/parser.ml \
187         $(BASE_PATH)/*/lexer.ml \
188         $(BASE_PATH)/*/linenum.ml \
189         $(BASE_PATH)/translator/*/*.cmi \
190         $(BASE_PATH)/translator/*/*.o \
191         $(BASE_PATH)/translator/*/*.a \
192         $(BASE_PATH)/translator/*/*.cmo \
193         $(BASE_PATH)/translator/*/*.cmxa \
194         $(BASE_PATH)/translator/*/*.cm[aiox] \
195         $(BASE_PATH)/translator/*/parser.mli \
196         $(BASE_PATH)/translator/*/lexer.mli \
197         $(BASE_PATH)/translator/*/parser.ml \
198         $(BASE_PATH)/translator/*/linenum.ml \
199         $(BASE_PATH)/translator/*/lexer.ml \
200         $(TARGET) \
201         $(BASE_PATH)/modelica_compiler/linenum.mli \
202         $(BASE_PATH)/modelica_compiler/scicosOptimizingCompiler.mli \
203         $(BASE_PATH)/translator/compilation/nameResolve.mli \
204         $(BASE_PATH)/translator/compilation/types.mli \
205         $(BASE_PATH)/translator/exceptionHandling/errorDico.mli \
206         $(BASE_PATH)/translator/exceptionHandling/exceptHandler.mli \
207         $(BASE_PATH)/translator/exceptionHandling/msgDico.mli \
208         $(BASE_PATH)/translator/instantiation/instantiation.mli \
209         $(BASE_PATH)/translator/parsing/linenum.mli \
210         $(BASE_PATH)/translator/parsing/syntax.mli \
211         $(BASE_PATH)/translator/translation/codeGeneration.mli \
212         $(BASE_PATH)/translator/translation/libraryManager.mli \
213         $(BASE_PATH)/translator/translation/translator.mli \
214         $(BASE_PATH)/translator/translation/versiondate.mli
215
216 #BUILT_SOURCES = depend
217
218 depend: $(MLS_XML2Modelica) $(MLS_modelicac) $(MLS_modelicat)
219         $(OCAMLDEP) -all $(INCLUDE) $(MLS_XML2Modelica) $(MLIS_XML2Modelica) > .depend
220         $(OCAMLDEP) -all $(INCLUDE_modelicat) $(MLS_modelicat) $(MLIS_modelicat) >> .depend
221         $(OCAMLDEP) -all $(INCLUDE) $(MLS_modelicac) $(MLIS_modelicac) >> .depend
222
223 include .depend
224
225 endif # OCAML
226 endif # XCOS