Tue Jan 16 11:28:45 CET 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         $(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         patch-info.h    \
197         mini-ops.h      \
198         mini-arch.h     \
199         dominators.c    \
200         cfold.c         \
201         regalloc.c      \
202         regalloc.h      \
203         helpers.c       \
204         liveness.c      \
205         ssa.c           \
206         abcremoval.c    \
207         abcremoval.h    \
208         ssapre.c        \
209         ssapre.h        \
210         aliasing.c      \
211         aliasing.h      \
212         local-propagation.c     \
213         simple-cee-ops.h \
214         simple-mini-ops.h \
215         driver.c        \
216         debug-mini.c    \
217         linear-scan.c   \
218         aot-compiler.c          \
219         aot-runtime.c           \
220         graph.c         \
221         mini-exceptions.c       \
222         mini-codegen.c          \
223         declsec.c       \
224         declsec.h       \
225         wapihandles.c   \
226         branch-opts.c
227
228 test_sources =          \
229         basic-calls.cs  \
230         basic-long.cs   \
231         bench.cs                \
232         objects.cs              \
233         arrays.cs               \
234         basic-float.cs  \
235         basic-math.cs   \
236         basic.cs                \
237         exceptions.cs   \
238         iltests.il              \
239         test.cs
240
241 test_sources2 = generics.2.cs il2tests.2.il
242
243 if MONO_DEBUGGER_SUPPORTED
244 if AMD64
245 mono_debugger_arch_sources = mdb-debug-info64.s
246 else
247 if ALPHA
248 mono_debugger_arch_sources = mdb-debug-info64.s
249 else
250 mono_debugger_arch_sources = mdb-debug-info32.s
251 endif
252 endif
253 mono_debugger_sources = debug-debugger.c debug-debugger.h $(mono_debugger_arch_sources)
254 else
255 mono_debugger_sources =
256 endif
257
258 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
259 regtests2=generics.exe il2tests.exe
260
261 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
262
263 if X86
264 arch_sources = \
265         $(x86_sources) $(mono_debugger_sources)
266 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
267 arch_built=cpu-x86.h
268 endif
269
270 if AMD64
271 arch_sources = \
272         $(amd64_sources) $(mono_debugger_sources)
273 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
274 arch_built=cpu-amd64.h
275 endif
276
277 if POWERPC
278 arch_sources = \
279         $(ppc_sources)
280 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
281 arch_built=cpu-g4.h
282 endif
283
284 if MIPS
285 arch_sources = $(mips_sources)
286 arch_BURGSRC= $(srcdir)/inssel-long32-mips.brg $(srcdir)/inssel-mips.brg
287 arch_built=cpu-mips.h
288 endif
289
290 if ARM
291
292 # pick up arm_dpimacros.h and arm_fpamacros.h
293 ARCH_CFLAGS = -I../arch/arm
294
295 arch_sources = $(arm_sources)
296
297 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg $(srcdir)/inssel-softfloat.brg
298 arch_built=cpu-arm.h
299 endif
300
301 if SPARC
302 arch_sources = \
303         $(sparc_sources)
304
305 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
306 arch_built=cpu-sparc.h
307 endif
308
309 if SPARC64
310 arch_sources = \
311         $(sparc_sources)
312
313 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
314 arch_built=cpu-sparc.h
315 endif
316
317 if S390
318 arch_sources = \
319         $(s390_sources)
320
321 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
322 arch_built=cpu-s390.h
323 endif
324
325 if S390x
326 arch_sources = \
327         $(s390x_sources)
328
329 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
330 arch_built=cpu-s390x.h
331 endif
332
333 if IA64
334 arch_sources = \
335     $(ia64_sources)
336
337 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
338 arch_built = cpu-ia64.h
339 endif
340
341 if ALPHA
342 arch_sources = \
343         $(alpha_sources) $(mono_debugger_sources)
344
345 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-alpha.brg
346 arch_built = cpu-alpha.h
347 endif
348
349 libmono_la_SOURCES = $(common_sources) $(arch_sources)
350
351 nodist_libmono_la_SOURCES = inssel.c inssel.h
352
353 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
354 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
355 libmono_static_la_LDFLAGS = -static
356 libmono_static_la_LIBADD = $(static_libs)
357
358 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
359
360 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
361
362 libmonoinclude_HEADERS = jit.h
363
364 libmono_la_LIBADD = \
365         $(libs)
366
367 %.exe: %.2.cs TestDriver.dll
368         $(GMCS) -out:$@ $< -r:TestDriver.dll 
369
370 %.exe: %.cs TestDriver.dll
371         $(MCS) -out:$@ -unsafe $< -r:TestDriver.dll
372
373 %.exe: %.2.il
374         $(ILASM2) -output=$@ $<
375
376 %.exe: %.il
377         $(ILASM) -output=$@ $<
378
379 TestDriver.dll: $(srcdir)/TestDriver.cs
380         $(MCS) -out:$@ -target:library $<
381
382 if CROSS_COMPILING
383
384 cpu-x86.h: cpu-x86.md
385 cpu-amd64.h: cpu-amd64.md
386 cpu-g4.h: cpu-g4.md
387 cpu-arm.h: cpu-arm.md
388 cpu-sparc.h: cpu-sparc.md
389 cpu-s390.h: cpu-s390.md
390 cpu-s390x.h: cpu-s390x.md
391 cpu-ia64.h: cpu-ia64.md
392 cpu-alpha.h: cpu-alpha.md
393 cpu-mips.h: cpu-mips.md
394
395 ## Gross hack.  Making 'genmdesc' a host binary takes more effort
396 $(arch_built):
397         echo "*** please build $(arch_built) on a native build tree and copy it here"
398         exit 1
399
400 else !CROSS_COMPILING
401
402 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
403         ./genmdesc $(srcdir)/cpu-x86.md cpu-x86.h x86_desc
404
405 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
406         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
407
408 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
409         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
410
411 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
412         ./genmdesc $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
413
414 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
415         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
416
417 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
418         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390_cpu_desc
419
420 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
421         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x_cpu_desc
422
423 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
424         ./genmdesc $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
425
426 cpu-alpha.h: cpu-alpha.md genmdesc$(EXEEXT)
427         ./genmdesc $(srcdir)/cpu-alpha.md cpu-alpha.h alpha_desc
428
429 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
430         ./genmdesc $(srcdir)/cpu-mips.md cpu-mips.h mips_desc
431
432 endif !CROSS_COMPILING
433
434 inssel.c inssel.h: $(BURGSRC)
435         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
436
437 testi: mono test.exe
438         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
439
440 # ensure the tests are actually correct
441 checktests: $(regtests)
442         for i in $(regtests); do $(RUNTIME) $$i; done
443
444 checktests2: $(regtests2)
445         for i in $(regtests); do $(RUNTIME2) $$i; done
446
447 rcheck: mono $(regtests) $(regtests2)
448         $(RUNTIME) --regression $(regtests)
449         $(RUNTIME2) --regression $(regtests2)
450
451 aotcheck: mono $(regtests)
452         for i in $(regtests); do $(RUNTIME) --aot $$i; done
453 #       for i in $(regtests2); do $(RUNTIME2) --aot $$i; done
454         $(RUNTIME) --regression $(regtests)
455 #       $(RUNTIME2) --verbose --regression $(regtests2)
456         rm -f *.exe.so
457
458 bench: mono test.exe
459         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
460
461 mbench: test.exe
462         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
463
464 stat1: mono bench.exe
465         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
466         perl viewstat.pl stats.pl
467
468 stat2: mono basic.exe
469         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
470         perl viewstat.pl -e stats.pl
471
472 stat3: mono bench.exe
473         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
474         perl viewstat.pl stats.pl
475
476 docu: mini.sgm
477         docbook2txt mini.sgm
478
479 check-local: rcheck
480
481 clean-local:
482         rm -f mono a.out gmon.out *.o test.exe
483
484 pkgconfigdir = $(libdir)/pkgconfig
485
486 if JIT_SUPPORTED
487 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
488 endif
489
490 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
491 EXTRA_DIST = $(common_BURGSRC) cprop.c TestDriver.cs ldscript ldscript.mono \
492         $(test_sources) $(test_sources2) \
493         inssel-long.brg inssel-long32.brg \
494         inssel-softfloat.brg    \
495         $(x86_sources) inssel-x86.brg cpu-x86.md \
496         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
497         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
498         $(arm_sources) inssel-arm.brg cpu-arm.md \
499         $(mips_sources) inssel-mips.brg inssel-long32-mips.brg cpu-mips.md \
500         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
501         $(s390_sources) inssel-s390.brg cpu-s390.md \
502         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
503         $(ia64_sources) inssel-ia64.brg cpu-ia64.md \
504         $(alpha_sources) inssel-alpha.brg cpu-alpha.md