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