new tests + update
[mono.git] / mono / mini / Makefile.am
1 count=100000
2 mtest=for_loop
3 monodir=$(top_builddir)
4
5 # This is needed for automake dependency generation
6 if INCLUDED_LIBGC
7 libgc_libs=$(monodir)/libgc/libmonogc.la
8 libgc_static_libs=$(monodir)/libgc/libmonogc-static.la
9 else
10 libgc_libs=$(LIBGC_LIBS)
11 libgc_static_libs=$(LIBGC_STATIC_LIBS)
12 endif
13
14 libs=   \
15         $(monodir)/mono/metadata/libmonoruntime.la      \
16         $(monodir)/mono/io-layer/libwapi.la     \
17         $(monodir)/mono/utils/libmonoutils.la \
18         $(GMODULE_LIBS) \
19         $(GLIB_LIBS)    \
20         $(libgc_libs)   \
21         $(ICU_LIBS)
22
23 static_libs=    \
24         $(monodir)/mono/metadata/libmonoruntime-static.la       \
25         $(monodir)/mono/io-layer/libwapi.la     \
26         $(monodir)/mono/utils/libmonoutils.la \
27         $(GMODULE_LIBS) \
28         $(GLIB_LIBS)    \
29         $(libgc_static_libs) \
30         $(ICU_LIBS)
31
32 RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/default $(top_builddir)/runtime/mono-wrapper
33
34 MCS = $(RUNTIME) $(mcs_topdir)/class/lib/default/mcs.exe -unsafe -nowarn:0162
35 ILASM = $(RUNTIME) $(mcs_topdir)/ilasm/ilasm.exe
36
37 AM_CFLAGS = \
38         -I$(top_srcdir)         \
39         $(LIBGC_CFLAGS)         \
40         $(GMODULE_CFLAGS)               \
41         $(GLIB_CFLAGS)
42
43 if PLATFORM_WIN32
44 export HOST_CC
45 # The mingw math.h has "extern inline" functions that dont appear in libs, so
46 # optimisation is required to actually inline them
47 AM_CFLAGS += -O
48 PLATFORM_LIB = ../os/libmonoos.la
49 endif
50
51 # hack for automake to have the same source file in a library and a bin
52 genmdesc_CFLAGS = $(AM_CFLAGS)
53
54 if NO_VERSION_SCRIPT
55 monoldflags=
56 monobinldflags=
57 else
58 monoldflags=-Wl,-version-script=$(srcdir)/ldscript
59 monobinldflags=-Wl,-version-script=$(srcdir)/ldscript.mono
60 endif
61
62 if PLATFORM_WIN32
63 libmono_la_LDFLAGS=-no-undefined -version-info 1:0:0 $(monoldflags)
64 else
65 libmono_la_LDFLAGS=$(monoldflags)
66 endif
67
68 if JIT_SUPPORTED
69 bin_PROGRAMS = mono
70
71 noinst_PROGRAMS = genmdesc
72
73 lib_LTLIBRARIES = libmono.la
74 noinst_LTLIBRARIES = libmono-static.la
75 endif
76
77 mono_SOURCES = \
78         main.c
79
80 if STATIC_MONO
81 # Link libmono into mono statically
82 # This leads to higher performance, especially with TLS
83 MONO_LIB=libmono-static.la
84 else 
85 MONO_LIB=libmono.la
86 endif
87
88 mono_LDADD = \
89         $(MONO_LIB)                     \
90         $(PLATFORM_LIB)         \
91         $(GLIB_LIBS)            \
92         $(GMODULE_LIBS) -lm     \
93         $(ICU_LIBS)
94
95 mono_LDFLAGS = \
96         $(static_flags) -export-dynamic $(monobinldflags)
97
98 genmdesc_SOURCES = \
99         mini.h          \
100         genmdesc.c      \
101         helpers.c
102
103 # Don't link this against libmonoruntime to speed up rebuilds
104 genmdesc_LDADD = \
105         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
106         $(PLATFORM_LIB)         \
107         $(GLIB_LIBS)            \
108         $(GMODULE_LIBS)
109
110 x86_sources = \
111         mini-x86.c              \
112         mini-x86.h              \
113         exceptions-x86.c        \
114         tramp-x86.c                     \
115         mini-codegen.c          \
116         mini-trampolines.c
117
118 amd64_sources = \
119         mini-amd64.c            \
120         mini-amd64.h            \
121         exceptions-amd64.c      \
122         tramp-amd64.c           \
123         mini-codegen.c          \
124         mini-trampolines.c
125
126 ppc_sources = \
127         mini-ppc.c              \
128         mini-ppc.h              \
129         exceptions-ppc.c        \
130         tramp-ppc.c
131
132 arm_sources = \
133         mini-arm.c              \
134         mini-arm.h              \
135         exceptions-arm.c        \
136         tramp-arm.c             \
137         mini-codegen.c
138
139 sparc_sources = \
140         mini-sparc.c            \
141         mini-sparc.h            \
142         exceptions-sparc.c      \
143         tramp-sparc.c           \
144         mini-codegen.c          \
145         mini-trampolines.c
146
147 s390_sources = \
148         mini-s390.c             \
149         mini-s390.h             \
150         exceptions-s390.c       \
151         tramp-s390.c
152
153 s390x_sources = \
154         mini-s390x.c            \
155         mini-s390x.h            \
156         exceptions-s390x.c      \
157         tramp-s390x.c
158
159 ia64_sources = \
160         mini-ia64.c                     \
161         mini-ia64.h                     \
162         exceptions-ia64.c       \
163         tramp-ia64.c            \
164         mini-codegen.c          \
165         mini-trampolines.c
166
167 common_sources = \
168         mini.c          \
169         mini.h          \
170         trace.c         \
171         trace.h         \
172         mini-ops.h      \
173         mini-arch.h     \
174         dominators.c    \
175         cfold.c         \
176         regalloc.c      \
177         regalloc.h      \
178         helpers.c       \
179         liveness.c      \
180         ssa.c           \
181         abcremoval.c    \
182         abcremoval.h    \
183         ssapre.c        \
184         ssapre.h        \
185         ssapre-cee-ops.h \
186         ssapre-mini-ops.h \
187         driver.c        \
188         debug-mini.c    \
189         linear-scan.c   \
190         aot.c           \
191         graph.c         \
192         mini-exceptions.c       \
193         declsec.c       \
194         declsec.h
195
196 test_sources =          \
197         basic-calls.cs  \
198         basic-long.cs   \
199         bench.cs                \
200         objects.cs              \
201         arrays.cs               \
202         basic-float.cs  \
203         basic-math.cs   \
204         basic.cs                \
205         exceptions.cs   \
206         iltests.il              \
207         test.cs
208
209 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
210
211 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
212
213 if X86
214 libmono_la_SOURCES = \
215         $(common_sources) $(x86_sources)
216
217 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
218 arch_built=cpu-pentium.h
219 endif
220
221 if AMD64
222 libmono_la_SOURCES = \
223         $(common_sources) $(amd64_sources)
224 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
225 arch_built=cpu-amd64.h
226 endif
227
228 if POWERPC
229 libmono_la_SOURCES = \
230         $(common_sources) $(ppc_sources)
231
232 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
233 arch_built=cpu-g4.h
234 endif
235
236 if ARM
237
238 # pick up arm_dpimacros.h and arm_fpamacros.h
239 AM_CFLAGS += -I../arch/arm
240
241 libmono_la_SOURCES = \
242         $(common_sources) $(arm_sources)
243
244 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg
245 arch_built=cpu-arm.h
246 endif
247
248 if SPARC
249 libmono_la_SOURCES = \
250         $(common_sources) $(sparc_sources)
251
252 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
253 arch_built=cpu-sparc.h
254 endif
255
256 if SPARC64
257 libmono_la_SOURCES = \
258         $(common_sources) $(sparc_sources)
259
260 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
261 arch_built=cpu-sparc.h
262 endif
263
264 if S390
265 libmono_la_SOURCES = \
266         $(common_sources) $(s390_sources)
267
268 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
269 arch_built=cpu-s390.h
270 endif
271
272 if S390x
273 libmono_la_SOURCES = \
274         $(common_sources) $(s390x_sources)
275
276 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
277 arch_built=cpu-s390x.h
278 endif
279
280 if IA64
281 libmono_la_SOURCES = \
282     $(common_sources) $(ia64_sources)
283
284 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
285 arch_built = cpu-ia64.h
286 endif
287
288 nodist_libmono_la_SOURCES = inssel.c inssel.h
289
290 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
291 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
292 libmono_static_la_LDFLAGS = -static
293 libmono_static_la_LIBADD = $(static_libs) $(PLATFORM_LIB)
294
295 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
296
297 libmonoincludedir = $(includedir)/mono/jit
298
299 libmonoinclude_HEADERS = jit.h
300
301 libmono_la_LIBADD = \
302         $(libs) \
303         $(PLATFORM_LIB)
304
305 %.exe: %.cs TestDriver.dll
306         $(MCS) /out:$*.exe /unsafe $< /r:TestDriver.dll
307
308 %.exe: %.il
309         $(ILASM) /output=$*.exe $<
310
311 TestDriver.dll: $(srcdir)/TestDriver.cs
312         $(MCS) /out:TestDriver.dll /target:library $(srcdir)/TestDriver.cs
313
314 cpu-pentium.h: cpu-pentium.md genmdesc$(EXEEXT)
315         ./genmdesc $(srcdir)/cpu-pentium.md cpu-pentium.h pentium_desc
316
317 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
318         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
319
320 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
321         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
322
323 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
324         ./genmdesc $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
325
326 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
327         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
328
329 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
330         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390
331
332 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
333         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x
334
335 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
336         ./genmdesc $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
337
338 inssel.c inssel.h: $(BURGSRC)
339         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
340
341 testi: mono test.exe
342         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
343
344 # ensure the tests are actually correct
345 checktests: $(regtests)
346         for i in $(regtests); do $(RUNTIME) $$i; done
347
348 rcheck: mono $(regtests)
349         $(RUNTIME) --regression $(regtests)
350
351 aotcheck: mono $(regtests)
352         for i in $(regtests); do $(RUNTIME) --aot $$i; done
353         $(RUNTIME) --verbose --regression $(regtests)
354         rm -f *.exe.so
355
356 bench: mono test.exe
357         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
358
359 mbench: test.exe
360         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
361
362 stat1: mono bench.exe
363         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
364         perl viewstat.pl stats.pl
365
366 stat2: mono basic.exe
367         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
368         perl viewstat.pl -e stats.pl
369
370 stat3: mono bench.exe
371         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
372         perl viewstat.pl stats.pl
373
374 docu: mini.sgm
375         docbook2txt mini.sgm
376
377 check-local: rcheck
378
379 clean-local:
380         rm -f mono a.out gmon.out *.o test.exe
381
382 pkgconfigdir = $(libdir)/pkgconfig
383
384 if JIT_SUPPORTED
385 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
386 endif
387
388 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
389 EXTRA_DIST = $(common_BURGSRC) jit-icalls.c cprop.c TestDriver.cs ldscript ldscript.mono $(test_sources) \
390         inssel-long.brg inssel-long32.brg \
391         $(x86_sources) inssel-x86.brg cpu-pentium.md \
392         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
393         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
394         $(arm_sources) inssel-arm.brg cpu-arm.md \
395         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
396         $(s390_sources) inssel-s390.brg cpu-s390.md \
397         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
398         $(ia64_sources) inssel-ia64.brg cpu-ia64.md