Tue Oct 9 21:01:03 CEST 2007 Paolo Molaro <lupus@ximian.com>
[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         $(GLIB_LIBS)    \
19         $(libgc_libs)
20
21 static_libs=    \
22         $(monodir)/mono/metadata/libmonoruntime-static.la       \
23         $(monodir)/mono/io-layer/libwapi.la     \
24         $(monodir)/mono/utils/libmonoutils.la \
25         $(GLIB_LIBS)    \
26         $(libgc_static_libs)
27
28 CLASS1=$(mcs_topdir)/class/lib/default
29 CLASS2=$(mcs_topdir)/class/lib/net_2_0
30
31 RUNTIME = MONO_PATH=$(CLASS1) $(top_builddir)/runtime/mono-wrapper
32 RUNTIME2 = MONO_PATH=$(CLASS2) $(top_builddir)/runtime/mono-wrapper
33 RUNTIME_AOTCHECK = MONO_PATH=$(CLASS1):. $(top_builddir)/runtime/mono-wrapper
34 RUNTIME_AOTCHECK2 = 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         $(GLIB_CFLAGS)
45         $(PLATFORM_CFLAGS) $(ARCH_CFLAGS)
46
47 if PLATFORM_WIN32
48 export HOST_CC
49 # The mingw math.h has "extern inline" functions that dont appear in libs, so
50 # optimisation is required to actually inline them
51 PLATFORM_CFLAGS = -O
52 endif
53
54 # hack for automake to have the same source file in a library and a bin
55 genmdesc_CFLAGS = $(AM_CFLAGS)
56
57 if NO_VERSION_SCRIPT
58 monoldflags=$(export_ldflags)
59 monobinldflags=$(export_ldflags)
60 else
61 monoldflags=-Wl,-version-script=$(srcdir)/ldscript $(export_ldflags)
62 monobinldflags=-Wl,-version-script=$(srcdir)/ldscript.mono $(export_ldflags)
63 endif
64
65 if PLATFORM_WIN32
66 libmono_la_LDFLAGS=-no-undefined -avoid-version $(monoldflags)
67 else
68 libmono_la_LDFLAGS=$(monoldflags)
69 endif
70
71 if JIT_SUPPORTED
72
73 if PLATFORM_WIN32
74 bin_PROGRAMS = mono monow
75 else
76 bin_PROGRAMS = mono
77 endif
78
79 noinst_PROGRAMS = genmdesc
80
81 lib_LTLIBRARIES = libmono.la
82 noinst_LTLIBRARIES = libmono-static.la
83 endif
84
85 mono_SOURCES = \
86         main.c
87
88 if STATIC_MONO
89 # Link libmono into mono statically
90 # This leads to higher performance, especially with TLS
91 MONO_LIB=libmono-static.la
92 else 
93 MONO_LIB=libmono.la
94 endif
95
96 mono_LDADD = \
97         $(MONO_LIB)                     \
98         $(GLIB_LIBS)            \
99         -lm
100
101 mono_LDFLAGS = \
102         $(static_flags) -export-dynamic $(monobinldflags)
103
104 # Create monow.exe, linked for the 'windows' subsystem
105 if PLATFORM_WIN32
106 monow_LDADD = $(mono_LDADD)
107 monow_LDFLAGS = $(mono_LDFLAGS) -mwindows
108 monow_SOURCES = $(mono_SOURCES)
109 endif
110
111 genmdesc_SOURCES = \
112         mini.h          \
113         genmdesc.c      \
114         helpers.c
115
116 # Don't link this against libmonoruntime to speed up rebuilds
117 genmdesc_LDADD = \
118         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
119         $(GLIB_LIBS)
120
121 x86_sources = \
122         mini-x86.c              \
123         mini-x86.h              \
124         exceptions-x86.c        \
125         tramp-x86.c                     \
126         mini-trampolines.c
127
128 amd64_sources = \
129         mini-amd64.c            \
130         mini-amd64.h            \
131         exceptions-amd64.c      \
132         tramp-amd64.c           \
133         mini-trampolines.c
134
135 ppc_sources = \
136         mini-ppc.c              \
137         mini-ppc.h              \
138         exceptions-ppc.c        \
139         mini-trampolines.c      \
140         tramp-ppc.c
141
142 arm_sources = \
143         mini-arm.c              \
144         mini-arm.h              \
145         exceptions-arm.c        \
146         mini-trampolines.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 hppa_sources = \
189         mini-hppa.c     \
190         mini-hppa.h     \
191         exceptions-hppa.c       \
192         tramp-hppa.c    \
193         mini-trampolines.c
194
195 common_sources = \
196         mini.c          \
197         mini.h          \
198         version.h       \
199         optflags-def.h          \
200         jit-icalls.h \
201         jit-icalls.c \
202         trace.c         \
203         trace.h         \
204         patch-info.h    \
205         mini-ops.h      \
206         mini-arch.h     \
207         dominators.c    \
208         cfold.c         \
209         regalloc.c      \
210         regalloc.h      \
211         helpers.c       \
212         liveness.c      \
213         ssa.c           \
214         abcremoval.c    \
215         abcremoval.h    \
216         ssapre.c        \
217         ssapre.h        \
218         aliasing.c      \
219         aliasing.h      \
220         local-propagation.c     \
221         simple-cee-ops.h \
222         simple-mini-ops.h \
223         driver.c        \
224         debug-mini.c    \
225         debug-mini.h    \
226         linear-scan.c   \
227         aot-compiler.c          \
228         aot-runtime.c           \
229         graph.c         \
230         mini-exceptions.c       \
231         mini-codegen.c          \
232         declsec.c       \
233         declsec.h       \
234         wapihandles.c   \
235         branch-opts.c   \
236         generic-sharing.c
237
238 test_sources =          \
239         basic-calls.cs  \
240         basic-long.cs   \
241         bench.cs                \
242         objects.cs              \
243         arrays.cs               \
244         basic-float.cs  \
245         basic-math.cs   \
246         basic.cs                \
247         exceptions.cs   \
248         devirtualization.cs     \
249         iltests.il.in           \
250         test.cs
251
252 test_sources2 = generics.2.cs il2tests.2.il generics-variant-types.2.il
253
254 if MONO_DEBUGGER_SUPPORTED
255 if AMD64
256 mono_debugger_arch_sources = mdb-debug-info64.s
257 else
258 if ALPHA
259 mono_debugger_arch_sources = mdb-debug-info64.s
260 else
261 mono_debugger_arch_sources = mdb-debug-info32.s
262 endif
263 endif
264 mono_debugger_sources = debug-debugger.c debug-debugger.h $(mono_debugger_arch_sources)
265 else
266 mono_debugger_sources =
267 endif
268
269 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 devirtualization.exe
270 regtests2=generics.exe il2tests.exe
271
272 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
273
274 if X86
275 arch_sources = $(x86_sources) $(mono_debugger_sources)
276 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
277 arch_built=cpu-x86.h
278 arch_define=__i386__
279 endif
280
281 if AMD64
282 arch_sources = $(amd64_sources) $(mono_debugger_sources)
283 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
284 arch_built=cpu-amd64.h
285 arch_define=__x86_64__
286 endif
287
288 if POWERPC
289 arch_sources = $(ppc_sources)
290 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
291 arch_built=cpu-g4.h
292 arch_define=__ppc__
293 endif
294
295 if MIPS
296 arch_sources = $(mips_sources)
297 arch_BURGSRC= $(srcdir)/inssel-long32-mips.brg $(srcdir)/inssel-mips.brg
298 arch_built=cpu-mips.h
299 arch_define=__mips__
300 endif
301
302 if ARM
303 # pick up arm_dpimacros.h and arm_fpamacros.h
304 ARCH_CFLAGS = -I../arch/arm
305 arch_sources = $(arm_sources)
306 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg $(srcdir)/inssel-softfloat.brg
307 arch_built=cpu-arm.h
308 arch_define=__arm__
309 endif
310
311 if SPARC
312 arch_sources = $(sparc_sources)
313 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
314 arch_built=cpu-sparc.h
315 arch_define=__sparc__
316 endif
317
318 if SPARC64
319 arch_sources = $(sparc_sources)
320 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
321 arch_built=cpu-sparc.h
322 arch_define=__sparc__
323 endif
324
325 if S390
326 arch_sources = $(s390_sources)
327 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
328 arch_built=cpu-s390.h
329 arch_define=__s390__
330 endif
331
332 if S390x
333 arch_sources = $(s390x_sources)
334 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
335 arch_built=cpu-s390x.h
336 arch_define=__s390__
337 endif
338
339 if IA64
340 arch_sources = $(ia64_sources)
341 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
342 arch_built = cpu-ia64.h
343 arch_define=__ia64__
344 endif
345
346 if ALPHA
347 arch_sources = $(alpha_sources) $(mono_debugger_sources)
348 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-alpha.brg
349 arch_built = cpu-alpha.h
350 arch_define=__alpha__
351 endif
352
353 if HPPA
354 # Only support 32-bit targets for now
355 arch_sources = $(hppa_sources)
356 arch_BURGSRC = $(srcdir)/inssel-long32.brg $(srcdir)/inssel-hppa.brg
357 arch_built = cpu-hppa.h
358 arch_define=__hppa__
359 endif
360
361 libmono_la_SOURCES = $(common_sources) $(arch_sources)
362
363 nodist_libmono_la_SOURCES = inssel.c inssel.h
364
365 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
366 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
367 libmono_static_la_LDFLAGS = -static
368 libmono_static_la_LIBADD = $(static_libs)
369
370 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
371
372 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
373
374 libmonoinclude_HEADERS = jit.h
375
376 libmono_la_LIBADD = \
377         $(libs)
378
379 %.exe: %.2.cs TestDriver.dll generics-variant-types.dll
380         $(GMCS) -out:$@ $< -r:TestDriver.dll -r:generics-variant-types.dll
381
382 %.exe: %.cs TestDriver.dll
383         $(MCS) -out:$@ -unsafe $< -r:TestDriver.dll
384
385 %.exe: %.2.il
386         $(ILASM2) -output=$@ $<
387
388 iltests.il: iltests.il.in Makefile.am
389         echo '// DO NOT EDIT: This file has been generated from iltests.il.in' > iltests.il
390         cpp -Darch=$(arch_define) < $(srcdir)/iltests.il.in | sed 's/^#.*//' >> iltests.il
391
392 %.exe: %.il
393         $(ILASM) -output=$@ $<
394
395 TestDriver.dll: $(srcdir)/TestDriver.cs
396         $(MCS) -out:$@ -target:library $<
397
398 generics-variant-types.dll: generics-variant-types.2.il
399         $(ILASM2) -dll -output=$@ $<
400
401 # we don't always use the perl impl because it's an additional
402 # build dependency for the poor windows users
403 # $(arch_define) is the preprocessor symbol that enables all the opcodes
404 # for the specific platform in mini-ops.h
405 if CROSS_COMPILING
406 GENMDESC_PRG=perl genmdesc.pl $(arch_define) $(srcdir)
407 else !CROSS_COMPILING
408 GENMDESC_PRG=./genmdesc
409 endif !CROSS_COMPILING
410
411 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
412         $(GENMDESC_PRG) $(srcdir)/cpu-x86.md cpu-x86.h x86_desc
413
414 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
415         $(GENMDESC_PRG) $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
416
417 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
418         $(GENMDESC_PRG) $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
419
420 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
421         $(GENMDESC_PRG) $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
422
423 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
424         $(GENMDESC_PRG) $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
425
426 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
427         $(GENMDESC_PRG) $(srcdir)/cpu-s390.md cpu-s390.h s390_cpu_desc
428
429 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
430         $(GENMDESC_PRG) $(srcdir)/cpu-s390x.md cpu-s390x.h s390x_cpu_desc
431
432 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
433         $(GENMDESC_PRG) $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
434
435 cpu-alpha.h: cpu-alpha.md genmdesc$(EXEEXT)
436         $(GENMDESC_PRG) $(srcdir)/cpu-alpha.md cpu-alpha.h alpha_desc
437
438 cpu-hppa.h: cpu-hppa.md genmdesc$(EXEEXT)
439         $(GENMDESC_PRG) $(srcdir)/cpu-hppa.md cpu-hppa.h hppa_desc
440
441 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
442         $(GENMDESC_PRG) $(srcdir)/cpu-mips.md cpu-mips.h mips_desc
443
444 inssel.c inssel.h: $(BURGSRC)
445         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
446
447 testi: mono test.exe
448         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
449
450 # ensure the tests are actually correct
451 checktests: $(regtests)
452         for i in $(regtests); do $(RUNTIME) $$i; done
453
454 checktests2: $(regtests2)
455         for i in $(regtests); do $(RUNTIME2) $$i; done
456
457 rcheck: mono $(regtests) $(regtests2)
458         $(RUNTIME) --regression $(regtests)
459         $(RUNTIME2) --regression $(regtests2)
460
461 aotcheck: mono $(regtests)
462         for i in $(regtests); do $(RUNTIME) --aot $$i || exit 1; done
463         for i in $(regtests2); do $(RUNTIME2) --aot $$i || exit 1; done
464         for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
465         for i in $(regtests2); do $(RUNTIME_AOTCHECK2) --regression $$i || exit 1; done
466         rm -f *.exe.so
467
468 bench: mono test.exe
469         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
470
471 mbench: test.exe
472         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
473
474 stat1: mono bench.exe
475         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
476         perl viewstat.pl stats.pl
477
478 stat2: mono basic.exe
479         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
480         perl viewstat.pl -e stats.pl
481
482 stat3: mono bench.exe
483         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
484         perl viewstat.pl stats.pl
485
486 docu: mini.sgm
487         docbook2txt mini.sgm
488
489 check-local: rcheck
490
491 clean-local:
492         rm -f mono a.out gmon.out *.o test.exe
493
494 pkgconfigdir = $(libdir)/pkgconfig
495
496 if JIT_SUPPORTED
497 BUILT_SOURCES = version.h inssel.c inssel.h $(arch_built)
498 else
499 BUILT_SOURCES = version.h
500 endif
501
502 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
503 EXTRA_DIST = $(common_BURGSRC) cprop.c TestDriver.cs ldscript ldscript.mono \
504         genmdesc.pl     \
505         $(test_sources) $(test_sources2) \
506         inssel-long.brg inssel-long32.brg \
507         inssel-softfloat.brg    \
508         $(x86_sources) inssel-x86.brg cpu-x86.md \
509         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
510         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
511         $(arm_sources) inssel-arm.brg cpu-arm.md \
512         $(mips_sources) inssel-mips.brg inssel-long32-mips.brg cpu-mips.md \
513         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
514         $(s390_sources) inssel-s390.brg cpu-s390.md \
515         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
516         $(ia64_sources) inssel-ia64.brg cpu-ia64.md \
517         $(alpha_sources) inssel-alpha.brg cpu-alpha.md \
518         $(hppa_sources) inssel-hppa.brg cpu-hppa.md
519
520 version.h: Makefile
521         if test -d $(srcdir)/.svn; then \
522                 (cd $(srcdir);  \
523                         export LANG=C;  \
524                         branch=`svn info | grep URL | sed -e 's/.*source//' -e 's,mono/mono/mini,,'`; \
525                         version=`svn info | grep Revision | sed 's/.*: //'`; \
526                         echo "#define FULL_VERSION \"$$branch r$$version\""; \
527                 ); \
528         else \
529                 echo "#define FULL_VERSION \"tarball\""; \
530         fi > version.h