New test.
[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
22 static_libs=    \
23         $(monodir)/mono/metadata/libmonoruntime-static.la       \
24         $(monodir)/mono/io-layer/libwapi.la     \
25         $(monodir)/mono/utils/libmonoutils.la \
26         $(GMODULE_LIBS) \
27         $(GLIB_LIBS)    \
28         $(libgc_static_libs)
29
30 CLASS1=$(mcs_topdir)/class/lib/default
31 CLASS2=$(mcs_topdir)/class/lib/net_2_0
32
33 RUNTIME = MONO_PATH=$(CLASS1) $(top_builddir)/runtime/mono-wrapper
34 RUNTIME2 = MONO_PATH=$(CLASS2) $(top_builddir)/runtime/mono-wrapper
35
36 MCS = $(RUNTIME) $(CLASS1)/mcs.exe -unsafe -nowarn:0162
37 GMCS = $(RUNTIME2) $(CLASS2)/gmcs.exe -unsafe -nowarn:0162
38 ILASM = $(RUNTIME) $(CLASS1)/ilasm.exe
39 ILASM2 = $(RUNTIME2) $(CLASS2)/ilasm.exe
40
41 AM_CFLAGS = \
42         -I$(top_srcdir)         \
43         $(LIBGC_CFLAGS)         \
44         $(GMODULE_CFLAGS)               \
45         $(GLIB_CFLAGS)
46         $(PLATFORM_CFLAGS) $(ARCH_CFLAGS)
47
48 if PLATFORM_WIN32
49 export HOST_CC
50 # The mingw math.h has "extern inline" functions that dont appear in libs, so
51 # optimisation is required to actually inline them
52 PLATFORM_CFLAGS = -O
53 endif
54
55 # hack for automake to have the same source file in a library and a bin
56 genmdesc_CFLAGS = $(AM_CFLAGS)
57
58 if NO_VERSION_SCRIPT
59 monoldflags=
60 monobinldflags=
61 else
62 monoldflags=-Wl,-version-script=$(srcdir)/ldscript
63 monobinldflags=-Wl,-version-script=$(srcdir)/ldscript.mono
64 endif
65
66 if PLATFORM_WIN32
67 libmono_la_LDFLAGS=-no-undefined -avoid-version $(monoldflags)
68 else
69 libmono_la_LDFLAGS=$(monoldflags)
70 endif
71
72 if JIT_SUPPORTED
73
74 if PLATFORM_WIN32
75 bin_PROGRAMS = mono monow
76 else
77 bin_PROGRAMS = mono
78 endif
79
80 noinst_PROGRAMS = genmdesc
81
82 lib_LTLIBRARIES = libmono.la
83 noinst_LTLIBRARIES = libmono-static.la
84 endif
85
86 mono_SOURCES = \
87         main.c
88
89 if STATIC_MONO
90 # Link libmono into mono statically
91 # This leads to higher performance, especially with TLS
92 MONO_LIB=libmono-static.la
93 else 
94 MONO_LIB=libmono.la
95 endif
96
97 mono_LDADD = \
98         $(MONO_LIB)                     \
99         $(GLIB_LIBS)            \
100         $(GMODULE_LIBS) -lm
101
102 mono_LDFLAGS = \
103         $(static_flags) -export-dynamic $(monobinldflags)
104
105 # Create monow.exe, linked for the 'windows' subsystem
106 if PLATFORM_WIN32
107 monow_LDADD = $(mono_LDADD)
108 monow_LDFLAGS = $(mono_LDFLAGS) -mwindows
109 monow_SOURCES = $(mono_SOURCES)
110 endif
111
112 genmdesc_SOURCES = \
113         mini.h          \
114         genmdesc.c      \
115         helpers.c
116
117 # Don't link this against libmonoruntime to speed up rebuilds
118 genmdesc_LDADD = \
119         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
120         $(GLIB_LIBS)            \
121         $(GMODULE_LIBS)
122
123 x86_sources = \
124         mini-x86.c              \
125         mini-x86.h              \
126         exceptions-x86.c        \
127         tramp-x86.c                     \
128         mini-trampolines.c
129
130 amd64_sources = \
131         mini-amd64.c            \
132         mini-amd64.h            \
133         exceptions-amd64.c      \
134         tramp-amd64.c           \
135         mini-trampolines.c
136
137 ppc_sources = \
138         mini-ppc.c              \
139         mini-ppc.h              \
140         exceptions-ppc.c        \
141         tramp-ppc.c
142
143 arm_sources = \
144         mini-arm.c              \
145         mini-arm.h              \
146         exceptions-arm.c        \
147         tramp-arm.c
148
149 mips_sources = \
150         mini-mips.c             \
151         mini-mips.h             \
152         exceptions-mips.c       \
153         tramp-mips.c
154
155 sparc_sources = \
156         mini-sparc.c            \
157         mini-sparc.h            \
158         exceptions-sparc.c      \
159         tramp-sparc.c           \
160         mini-trampolines.c
161
162 s390_sources = \
163         mini-s390.c             \
164         mini-s390.h             \
165         exceptions-s390.c       \
166         tramp-s390.c
167
168 s390x_sources = \
169         mini-s390x.c            \
170         mini-s390x.h            \
171         exceptions-s390x.c      \
172         tramp-s390x.c
173
174 ia64_sources = \
175         mini-ia64.c                     \
176         mini-ia64.h                     \
177         exceptions-ia64.c       \
178         tramp-ia64.c            \
179         mini-trampolines.c
180
181 alpha_sources = \
182         mini-alpha.c    \
183         mini-alpha.h    \
184         exceptions-alpha.c      \
185         tramp-alpha.c   \
186         mini-trampolines.c
187
188 common_sources = \
189         mini.c          \
190         mini.h          \
191         optflags-def.h          \
192         jit-icalls.h \
193         jit-icalls.c \
194         trace.c         \
195         trace.h         \
196         mini-ops.h      \
197         mini-arch.h     \
198         dominators.c    \
199         cfold.c         \
200         regalloc.c      \
201         regalloc.h      \
202         helpers.c       \
203         liveness.c      \
204         ssa.c           \
205         abcremoval.c    \
206         abcremoval.h    \
207         ssapre.c        \
208         ssapre.h        \
209         aliasing.c      \
210         aliasing.h      \
211         local-propagation.c     \
212         simple-cee-ops.h \
213         simple-mini-ops.h \
214         driver.c        \
215         debug-mini.c    \
216         linear-scan.c   \
217         aot-compiler.c          \
218         aot-runtime.c           \
219         graph.c         \
220         mini-exceptions.c       \
221         mini-codegen.c          \
222         declsec.c       \
223         declsec.h       \
224         wapihandles.c   \
225         branch-opts.c
226
227 test_sources =          \
228         basic-calls.cs  \
229         basic-long.cs   \
230         bench.cs                \
231         objects.cs              \
232         arrays.cs               \
233         basic-float.cs  \
234         basic-math.cs   \
235         basic.cs                \
236         exceptions.cs   \
237         iltests.il              \
238         test.cs
239
240 test_sources2 = generics.2.cs il2tests.2.il
241
242 if MONO_DEBUGGER_SUPPORTED
243 mono_debugger_sources = debug-debugger.c debug-debugger.h
244 else
245 mono_debugger_sources =
246 endif
247
248 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
249 regtests2=generics.exe il2tests.exe
250
251 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
252
253 if X86
254 arch_sources = \
255         $(x86_sources) $(mono_debugger_sources)
256 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
257 arch_built=cpu-x86.h
258 endif
259
260 if AMD64
261 arch_sources = \
262         $(amd64_sources) $(mono_debugger_sources)
263 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
264 arch_built=cpu-amd64.h
265 endif
266
267 if POWERPC
268 arch_sources = \
269         $(ppc_sources)
270 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
271 arch_built=cpu-g4.h
272 endif
273
274 if MIPS
275 arch_sources = $(mips_sources)
276 arch_BURGSRC= $(srcdir)/inssel-long32-mips.brg $(srcdir)/inssel-mips.brg
277 arch_built=cpu-mips.h
278 endif
279
280 if ARM
281
282 # pick up arm_dpimacros.h and arm_fpamacros.h
283 ARCH_CFLAGS = -I../arch/arm
284
285 arch_sources = $(arm_sources)
286
287 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg $(srcdir)/inssel-softfloat.brg
288 arch_built=cpu-arm.h
289 endif
290
291 if SPARC
292 arch_sources = \
293         $(sparc_sources)
294
295 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
296 arch_built=cpu-sparc.h
297 endif
298
299 if SPARC64
300 arch_sources = \
301         $(sparc_sources)
302
303 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
304 arch_built=cpu-sparc.h
305 endif
306
307 if S390
308 arch_sources = \
309         $(s390_sources)
310
311 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
312 arch_built=cpu-s390.h
313 endif
314
315 if S390x
316 arch_sources = \
317         $(s390x_sources)
318
319 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
320 arch_built=cpu-s390x.h
321 endif
322
323 if IA64
324 arch_sources = \
325     $(ia64_sources)
326
327 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
328 arch_built = cpu-ia64.h
329 endif
330
331 if ALPHA
332 arch_sources = \
333         $(alpha_sources)
334
335 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-alpha.brg
336 arch_built = cpu-alpha.h
337 endif
338
339 libmono_la_SOURCES = $(common_sources) $(arch_sources)
340
341 nodist_libmono_la_SOURCES = inssel.c inssel.h
342
343 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
344 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
345 libmono_static_la_LDFLAGS = -static
346 libmono_static_la_LIBADD = $(static_libs)
347
348 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
349
350 libmonoincludedir = $(includedir)/mono/jit
351
352 libmonoinclude_HEADERS = jit.h
353
354 libmono_la_LIBADD = \
355         $(libs)
356
357 %.exe: %.2.cs TestDriver.dll
358         $(GMCS) -out:$@ $< -r:TestDriver.dll 
359
360 %.exe: %.cs TestDriver.dll
361         $(MCS) -out:$@ -unsafe $< -r:TestDriver.dll
362
363 %.exe: %.2.il
364         $(ILASM2) -output=$@ $<
365
366 %.exe: %.il
367         $(ILASM) -output=$@ $<
368
369 TestDriver.dll: $(srcdir)/TestDriver.cs
370         $(MCS) -out:$@ -target:library $<
371
372 if CROSS_COMPILING
373
374 cpu-x86.h: cpu-x86.md
375 cpu-amd64.h: cpu-amd64.md
376 cpu-g4.h: cpu-g4.md
377 cpu-arm.h: cpu-arm.md
378 cpu-sparc.h: cpu-sparc.md
379 cpu-s390.h: cpu-s390.md
380 cpu-s390x.h: cpu-s390x.md
381 cpu-ia64.h: cpu-ia64.md
382 cpu-alpha.h: cpu-alpha.md
383 cpu-mips.h: cpu-mips.md
384
385 ## Gross hack.  Making 'genmdesc' a host binary takes more effort
386 $(arch_built):
387         echo "*** please build $(arch_built) on a native build tree and copy it here"
388         exit 1
389
390 else !CROSS_COMPILING
391
392 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
393         ./genmdesc $(srcdir)/cpu-x86.md cpu-x86.h x86_desc
394
395 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
396         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
397
398 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
399         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
400
401 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
402         ./genmdesc $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
403
404 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
405         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
406
407 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
408         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390_cpu_desc
409
410 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
411         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x_cpu_desc
412
413 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
414         ./genmdesc $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
415
416 cpu-alpha.h: cpu-alpha.md genmdesc$(EXEEXT)
417         ./genmdesc $(srcdir)/cpu-alpha.md cpu-alpha.h alpha_desc
418
419 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
420         ./genmdesc $(srcdir)/cpu-mips.md cpu-mips.h mips_desc
421
422 endif !CROSS_COMPILING
423
424 inssel.c inssel.h: $(BURGSRC)
425         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
426
427 testi: mono test.exe
428         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
429
430 # ensure the tests are actually correct
431 checktests: $(regtests)
432         for i in $(regtests); do $(RUNTIME) $$i; done
433
434 checktests2: $(regtests2)
435         for i in $(regtests); do $(RUNTIME2) $$i; done
436
437 rcheck: mono $(regtests) $(regtests2)
438         $(RUNTIME) --regression $(regtests)
439         $(RUNTIME2) --regression $(regtests2)
440
441 aotcheck: mono $(regtests)
442         for i in $(regtests); do $(RUNTIME) --aot $$i; done
443 #       for i in $(regtests2); do $(RUNTIME2) --aot $$i; done
444         $(RUNTIME) --regression $(regtests)
445 #       $(RUNTIME2) --verbose --regression $(regtests2)
446         rm -f *.exe.so
447
448 bench: mono test.exe
449         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
450
451 mbench: test.exe
452         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
453
454 stat1: mono bench.exe
455         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
456         perl viewstat.pl stats.pl
457
458 stat2: mono basic.exe
459         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
460         perl viewstat.pl -e stats.pl
461
462 stat3: mono bench.exe
463         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
464         perl viewstat.pl stats.pl
465
466 docu: mini.sgm
467         docbook2txt mini.sgm
468
469 check-local: rcheck
470
471 clean-local:
472         rm -f mono a.out gmon.out *.o test.exe
473
474 pkgconfigdir = $(libdir)/pkgconfig
475
476 if JIT_SUPPORTED
477 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
478 endif
479
480 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
481 EXTRA_DIST = $(common_BURGSRC) cprop.c TestDriver.cs ldscript ldscript.mono \
482         $(test_sources) $(test_sources2) \
483         inssel-long.brg inssel-long32.brg \
484         inssel-softfloat.brg    \
485         $(x86_sources) inssel-x86.brg cpu-x86.md \
486         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
487         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
488         $(arm_sources) inssel-arm.brg cpu-arm.md \
489         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
490         $(s390_sources) inssel-s390.brg cpu-s390.md \
491         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
492         $(ia64_sources) inssel-ia64.brg cpu-ia64.md \
493         $(alpha_sources) inssel-alpha.brg cpu-alpha.md