Wed Sep 28 17:12:48 CEST 2005 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         $(ICU_LIBS)
22
23 static_libs=    \
24         $(monodir)/mono/metadata/libmonoruntime-static.la       \
25         $(monodir)/mono/io-layer/libwapi.la     \
26         $(monodir)/mono/utils/libmonoutils.la \
27         $(GMODULE_LIBS) \
28         $(GLIB_LIBS)    \
29         $(libgc_static_libs) \
30         $(ICU_LIBS)
31
32 RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/default $(top_builddir)/runtime/mono-wrapper
33
34 MCS = $(RUNTIME) $(mcs_topdir)/class/lib/default/mcs.exe -unsafe -nowarn:0162
35 ILASM = $(RUNTIME) $(mcs_topdir)/ilasm/ilasm.exe
36
37 INCLUDES = \
38         -I$(top_srcdir)         \
39         $(LIBGC_CFLAGS)         \
40         $(GMODULE_CFLAGS)               \
41         $(GLIB_CFLAGS)
42
43 if PLATFORM_WIN32
44 export HOST_CC
45 # The mingw math.h has "extern inline" functions that dont appear in libs, so
46 # optimisation is required to actually inline them
47 AM_CFLAGS = -O
48 PLATFORM_LIB = ../os/libmonoos.la
49 endif
50
51 # hack for automake to have the same source file in a library and a bin
52 genmdesc_CFLAGS = $(AM_CFLAGS)
53
54 if NO_VERSION_SCRIPT
55 monoldflags=
56 else
57 monoldflags=-Wl,-version-script=$(srcdir)/ldscript
58 endif
59
60 if PLATFORM_WIN32
61 libmono_la_LDFLAGS=-no-undefined -version-info 1:0:0 $(monoldflags)
62 else
63 libmono_la_LDFLAGS=$(monoldflags)
64 endif
65
66 if JIT_SUPPORTED
67 bin_PROGRAMS = mono
68
69 noinst_PROGRAMS = genmdesc
70
71 lib_LTLIBRARIES = libmono.la
72 noinst_LTLIBRARIES = libmono-static.la
73 endif
74
75 mono_SOURCES = \
76         main.c
77
78 if STATIC_MONO
79 # Link libmono into mono statically
80 # This leads to higher performance, especially with TLS
81 MONO_LIB=libmono-static.la
82 else 
83 MONO_LIB=libmono.la
84 endif
85
86 mono_LDADD = \
87         $(MONO_LIB)                     \
88         $(PLATFORM_LIB)         \
89         $(GLIB_LIBS)            \
90         $(GMODULE_LIBS) -lm     \
91         $(ICU_LIBS)
92
93 mono_LDFLAGS = \
94         $(static_flags) -export-dynamic $(monoldflags)
95
96 genmdesc_SOURCES = \
97         mini.h          \
98         genmdesc.c      \
99         helpers.c
100
101 # Don't link this against libmonoruntime to speed up rebuilds
102 genmdesc_LDADD = \
103         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
104         $(PLATFORM_LIB)         \
105         $(GLIB_LIBS)            \
106         $(GMODULE_LIBS)
107
108 x86_sources = \
109         mini-x86.c              \
110         mini-x86.h              \
111         exceptions-x86.c        \
112         tramp-x86.c                     \
113         mini-codegen.c          \
114         mini-trampolines.c
115
116 amd64_sources = \
117         mini-amd64.c            \
118         mini-amd64.h            \
119         exceptions-amd64.c      \
120         tramp-amd64.c           \
121         mini-codegen.c          \
122         mini-trampolines.c
123
124 ppc_sources = \
125         mini-ppc.c              \
126         mini-ppc.h              \
127         exceptions-ppc.c        \
128         tramp-ppc.c
129
130 arm_sources = \
131         mini-arm.c              \
132         mini-arm.h              \
133         exceptions-arm.c        \
134         tramp-arm.c             \
135         mini-codegen.c
136
137 sparc_sources = \
138         mini-sparc.c            \
139         mini-sparc.h            \
140         exceptions-sparc.c      \
141         tramp-sparc.c           \
142         mini-codegen.c          \
143         mini-trampolines.c
144
145 s390_sources = \
146         mini-s390.c             \
147         mini-s390.h             \
148         exceptions-s390.c       \
149         tramp-s390.c
150
151 s390x_sources = \
152         mini-s390x.c            \
153         mini-s390x.h            \
154         exceptions-s390x.c      \
155         tramp-s390x.c
156
157 ia64_sources = \
158         mini-ia64.c                     \
159         mini-ia64.h                     \
160         exceptions-ia64.c       \
161         tramp-ia64.c            \
162         mini-codegen.c          \
163         mini-trampolines.c
164
165 common_sources = \
166         mini.c          \
167         mini.h          \
168         trace.c         \
169         trace.h         \
170         mini-ops.h      \
171         mini-arch.h     \
172         dominators.c    \
173         cfold.c         \
174         regalloc.c      \
175         regalloc.h      \
176         helpers.c       \
177         liveness.c      \
178         ssa.c           \
179         abcremoval.c    \
180         abcremoval.h    \
181         ssapre.c        \
182         ssapre.h        \
183         ssapre-cee-ops.h \
184         ssapre-mini-ops.h \
185         driver.c        \
186         debug-mini.c    \
187         linear-scan.c   \
188         aot.c           \
189         graph.c         \
190         mini-exceptions.c       \
191         declsec.c       \
192         declsec.h
193
194 test_sources =          \
195         basic-calls.cs  \
196         basic-long.cs   \
197         bench.cs                \
198         objects.cs              \
199         arrays.cs               \
200         basic-float.cs  \
201         basic-math.cs   \
202         basic.cs                \
203         exceptions.cs   \
204         iltests.il              \
205         test.cs
206
207 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
208
209 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
210
211 if X86
212 libmono_la_SOURCES = \
213         $(common_sources) $(x86_sources)
214
215 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
216 arch_built=cpu-pentium.h
217 endif
218
219 if AMD64
220 libmono_la_SOURCES = \
221         $(common_sources) $(amd64_sources)
222 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
223 arch_built=cpu-amd64.h
224 endif
225
226 if POWERPC
227 libmono_la_SOURCES = \
228         $(common_sources) $(ppc_sources)
229
230 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
231 arch_built=cpu-g4.h
232 endif
233
234 if ARM
235 libmono_la_SOURCES = \
236         $(common_sources) $(arm_sources)
237
238 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg
239 arch_built=cpu-arm.h
240 endif
241
242 if SPARC
243 libmono_la_SOURCES = \
244         $(common_sources) $(sparc_sources)
245
246 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
247 arch_built=cpu-sparc.h
248 endif
249
250 if SPARC64
251 libmono_la_SOURCES = \
252         $(common_sources) $(sparc_sources)
253
254 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
255 arch_built=cpu-sparc.h
256 endif
257
258 if S390
259 libmono_la_SOURCES = \
260         $(common_sources) $(s390_sources)
261
262 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
263 arch_built=cpu-s390.h
264 endif
265
266 if S390x
267 libmono_la_SOURCES = \
268         $(common_sources) $(s390x_sources)
269
270 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
271 arch_built=cpu-s390x.h
272 endif
273
274 if IA64
275 libmono_la_SOURCES = \
276     $(common_sources) $(ia64_sources)
277
278 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
279 arch_built = cpu-ia64.h
280 endif
281
282 nodist_libmono_la_SOURCES = inssel.c inssel.h
283
284 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
285 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
286 libmono_static_la_LDFLAGS = -static
287 libmono_static_la_LIBADD = $(static_libs) $(PLATFORM_LIB)
288
289 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
290
291 libmonoincludedir = $(includedir)/mono/jit
292
293 libmonoinclude_HEADERS = jit.h
294
295 libmono_la_LIBADD = \
296         $(libs) \
297         $(PLATFORM_LIB)
298
299 %.exe: %.cs TestDriver.dll
300         $(MCS) /out:$*.exe /unsafe $< /r:TestDriver.dll
301
302 %.exe: %.il
303         $(ILASM) /output=$*.exe $<
304
305 TestDriver.dll: $(srcdir)/TestDriver.cs
306         $(MCS) /out:TestDriver.dll /target:library $(srcdir)/TestDriver.cs
307
308 cpu-pentium.h: cpu-pentium.md genmdesc$(EXEEXT)
309         ./genmdesc $(srcdir)/cpu-pentium.md cpu-pentium.h pentium_desc
310
311 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
312         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
313
314 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
315         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
316
317 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
318         ./genmdesc $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
319
320 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
321         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
322
323 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
324         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390
325
326 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
327         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x
328
329 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
330         ./genmdesc $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
331
332 inssel.c inssel.h: $(BURGSRC)
333         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
334
335 testi: mono test.exe
336         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
337
338 # ensure the tests are actually correct
339 checktests: $(regtests)
340         for i in $(regtests); do $(RUNTIME) $$i; done
341
342 rcheck: mono $(regtests)
343         $(RUNTIME) --regression $(regtests)
344
345 aotcheck: mono $(regtests)
346         for i in $(regtests); do $(RUNTIME) --aot $$i; done
347         $(RUNTIME) --verbose --regression $(regtests)
348         rm -f *.exe.so
349
350 bench: mono test.exe
351         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
352
353 mbench: test.exe
354         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
355
356 stat1: mono bench.exe
357         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
358         perl viewstat.pl stats.pl
359
360 stat2: mono basic.exe
361         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
362         perl viewstat.pl -e stats.pl
363
364 stat3: mono bench.exe
365         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
366         perl viewstat.pl stats.pl
367
368 docu: mini.sgm
369         docbook2txt mini.sgm
370
371 check-local:
372         ok=:; $(MAKE) rcheck || ok=false; \
373         $(top_builddir)/runtime/semdel-wrapper || :; $$ok
374
375 clean-local:
376         rm -f mono a.out gmon.out *.o test.exe
377
378 pkgconfigdir = $(libdir)/pkgconfig
379
380 if JIT_SUPPORTED
381 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
382 endif
383
384 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
385 EXTRA_DIST = $(common_BURGSRC) jit-icalls.c cprop.c TestDriver.cs ldscript $(test_sources) \
386         inssel-long.brg inssel-long32.brg \
387         $(x86_sources) inssel-x86.brg cpu-pentium.md \
388         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
389         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
390         $(arm_sources) inssel-arm.brg cpu-arm.md \
391         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
392         $(s390_sources) inssel-s390.brg cpu-s390.md \
393         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
394         $(ia64_sources) inssel-ia64.brg cpu-ia64.md