2004-08-08 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / mini / Makefile.am
1 count=100000
2 mtest=for_loop
3 monodir=$(top_builddir)
4 libs=   \
5         $(monodir)/mono/metadata/libmonoruntime.la      \
6         $(monodir)/mono/metadata/libmetadata.la \
7         $(monodir)/mono/io-layer/libwapi.la     \
8         $(monodir)/mono/utils/libmonoutils.la \
9         $(LIBGC_LIBS)   \
10         $(ICU_LIBS)
11
12 MCS=mcs
13 RUNTIME=mono
14
15 INCLUDES = \
16         -I$(top_srcdir)         \
17         $(LIBGC_CFLAGS)         \
18         $(GMODULE_CFLAGS)               \
19         $(GLIB_CFLAGS)
20
21 if PLATFORM_WIN32
22 export HOST_CC
23 # The mingw math.h has "extern inline" functions that dont appear in libs, so
24 # optimisation is required to actually inline them
25 AM_CFLAGS = -O
26 endif
27
28 # hack for automake to have the same source file in a library and a bin
29 genmdesc_CFLAGS = $(AM_CFLAGS)
30
31 if NO_VERSION_SCRIPT
32 monoldflags=
33 else
34 monoldflags=-Wl,-version-script=$(srcdir)/ldscript
35 endif
36 libmono_la_LDFLAGS=$(monoldflags)
37
38 if JIT_SUPPORTED
39 bin_PROGRAMS = mono
40
41 noinst_PROGRAMS = genmdesc
42
43 lib_LTLIBRARIES = libmono.la
44 endif
45
46 mono_SOURCES = \
47         main.c
48
49 if AMD64
50 # Link libmono into mono statically on platforms where it is possible
51 # This leads to higher performance, especially with TLS
52 MONO_LIB=.libs/libmono.a
53 else
54 MONO_LIB=libmono.la
55 endif
56
57 mono_LDADD = \
58         $(MONO_LIB)                     \
59         $(GLIB_LIBS)            \
60         $(GMODULE_LIBS) -lm     \
61         $(ICU_LIBS)
62
63 mono_LDFLAGS = \
64         $(static_flags) -export-dynamic $(monoldflags)
65
66 genmdesc_SOURCES = \
67         mini.h          \
68         genmdesc.c      \
69         helpers.c
70
71 genmdesc_LDADD = \
72         $(libs) -lm     \
73         $(GLIB_LIBS)            \
74         $(GMODULE_LIBS)
75
76 x86_sources = \
77     mini-exceptions.c   \
78         mini-x86.c              \
79         mini-x86.h              \
80         exceptions-x86.c        \
81         tramp-x86.c
82
83 amd64_sources = \
84         mini-exceptions.c       \
85         mini-amd64.c            \
86         mini-amd64.h            \
87         exceptions-amd64.c      \
88         tramp-amd64.c
89
90 ppc_sources = \
91         mini-ppc.c              \
92         mini-ppc.h              \
93         exceptions-ppc.c        \
94         tramp-ppc.c
95
96 sparc_sources = \
97         mini-sparc.c            \
98         mini-sparc.h            \
99     mini-exceptions.c   \
100         exceptions-sparc.c      \
101         tramp-sparc.c
102
103 s390_sources = \
104         mini-s390.c             \
105         mini-s390.h             \
106         exceptions-s390.c       \
107         tramp-s390.c
108
109 s390x_sources = \
110         mini-s390x.c            \
111         mini-s390x.h            \
112         exceptions-s390x.c      \
113         tramp-s390x.c
114
115 common_sources = \
116         mini.c          \
117         mini.h          \
118         trace.c         \
119         trace.h         \
120         mini-ops.h      \
121         mini-arch.h     \
122         dominators.c    \
123         cfold.c         \
124         regalloc.c      \
125         regalloc.h      \
126         helpers.c       \
127         liveness.c      \
128         ssa.c           \
129         abcremoval.c    \
130         abcremoval.h    \
131         driver.c        \
132         debug-mini.c    \
133         linear-scan.c   \
134         aot.c           \
135         graph.c 
136
137 test_sources =          \
138         basic-calls.cs  \
139         basic-long.cs   \
140         bench.cs                \
141         objects.cs              \
142         arrays.cs               \
143         basic-float.cs  \
144         basic-math.cs   \
145         basic.cs                \
146         exceptions.cs   \
147         iltests.il              \
148         test.cs
149
150 regtests=basic.exe arrays.exe basic-float.exe basic-math.exe basic-long.exe objects.exe basic-calls.exe iltests.exe exceptions.exe bench.exe
151
152 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
153
154 if X86
155 libmono_la_SOURCES = \
156         $(common_sources) $(x86_sources)
157
158 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
159 arch_built=cpu-pentium.h
160 endif
161
162 if AMD64
163 libmono_la_SOURCES = \
164         $(common_sources) $(amd64_sources)
165 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
166 arch_built=cpu-amd64.h
167 endif
168
169 if POWERPC
170 libmono_la_SOURCES = \
171         $(common_sources) $(ppc_sources)
172
173 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
174 arch_built=cpu-g4.h
175 endif
176
177 if SPARC
178 libmono_la_SOURCES = \
179         $(common_sources) $(sparc_sources)
180
181 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
182 arch_built=cpu-sparc.h
183 endif
184
185 if SPARC64
186 libmono_la_SOURCES = \
187         $(common_sources) $(sparc_sources)
188
189 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
190 arch_built=cpu-sparc.h
191 endif
192
193 if S390
194 libmono_la_SOURCES = \
195         $(common_sources) $(s390_sources)
196
197 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
198 arch_built=cpu-s390.h
199 endif
200
201 if S390x
202 libmono_la_SOURCES = \
203         $(common_sources) $(s390x_sources)
204
205 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
206 arch_built=cpu-s390x.h
207 endif
208
209 nodist_libmono_la_SOURCES = inssel.c inssel.h
210
211 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
212
213 libmonoincludedir = $(includedir)/mono/jit
214
215 libmonoinclude_HEADERS = jit.h
216
217 libmono_la_LIBADD = \
218         $(libs)
219
220 %.exe: %.cs TestDriver.dll
221         $(MCS) /unsafe $< /r:TestDriver.dll
222
223 %.exe: %.il
224         ilasm /output=$*.exe $<
225
226 TestDriver.dll: TestDriver.cs
227         $(MCS) /out:TestDriver.dll /target:library TestDriver.cs
228
229 cpu-pentium.h: cpu-pentium.md genmdesc$(EXEEXT)
230         ./genmdesc $(srcdir)/cpu-pentium.md cpu-pentium.h pentium_desc
231
232 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
233         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
234
235 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
236         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
237
238 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
239         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
240
241 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
242         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390
243
244 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
245         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x
246
247 inssel.c inssel.h: $(BURGSRC)
248         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
249
250 testi: mono test.exe
251         ./mono -v -v --ncompile 1 --compile Test:$(mtest) test.exe
252
253 # ensure the tests are actually correct
254 checktests: $(regtests)
255         for i in $(regtests); do $(RUNTIME) $$i; done
256
257 rcheck: mono $(regtests)
258         ./mono --regression $(regtests)
259
260 aotcheck: mono $(regtests)
261         for i in $(regtests); do ./mono --aot $$i; done
262         ./mono --verbose --regression $(regtests)
263         rm -f *.exe.so
264
265 bench: mono test.exe
266         time ./mono --ncompile $(count) --compile Test:$(mtest) test.exe
267
268 mbench: test.exe
269         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
270
271 stat1: mono bench.exe
272         ./mono --verbose --statfile stats.pl --regression bench.exe
273         perl viewstat.pl stats.pl
274
275 stat2: mono basic.exe
276         ./mono --verbose --statfile stats.pl --regression basic.exe
277         perl viewstat.pl -e stats.pl
278
279 stat3: mono bench.exe
280         ./mono --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
281         perl viewstat.pl stats.pl
282
283 docu: mini.sgm
284         docbook2txt mini.sgm
285
286 clean:
287         rm -f mono a.out gmon.out *.o test.exe
288
289 pkgconfigdir = $(libdir)/pkgconfig
290
291 if JIT_SUPPORTED
292 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
293 endif
294
295 CLEANFILES= $(BUILT_SOURCES)
296 EXTRA_DIST = $(common_BURGSRC) jit-icalls.c cprop.c TestDriver.cs ldscript $(test_sources) \
297         inssel-long.brg inssel-long32.brg \
298         $(x86_sources) inssel-x86.brg cpu-pentium.md \
299         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
300         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
301         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
302         $(s390_sources) inssel-s390.brg cpu-s390.md \
303         $(s390x_sources) inssel-s390x.brg cpu-s390x.md
304