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