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