2005-01-06 Zoltan Varga <vargaz@freemail.hu>
[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/metadata/libmetadata.la \
17         $(monodir)/mono/io-layer/libwapi.la     \
18         $(monodir)/mono/utils/libmonoutils.la \
19         $(GMODULE_LIBS) \
20         $(GLIB_LIBS)    \
21         $(libgc_libs)   \
22         $(ICU_LIBS)
23
24 static_libs=    \
25         $(monodir)/mono/metadata/libmonoruntime-static.la       \
26         $(monodir)/mono/metadata/libmetadata-static.la  \
27         $(monodir)/mono/io-layer/libwapi.la     \
28         $(monodir)/mono/utils/libmonoutils.la \
29         $(GMODULE_LIBS) \
30         $(GLIB_LIBS)    \
31         $(libgc_static_libs) \
32         $(ICU_LIBS)
33
34 RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/default MONO_SHARED_DIR=$(mono_build_root)/runtime ./mono --config $(top_builddir)/data/config
35
36 MCS = $(RUNTIME) $(mcs_topdir)/class/lib/default/mcs.exe --unsafe -nowarn:0162
37 ILASM = $(RUNTIME) $(mcs_topdir)/ilasm/ilasm.exe
38
39 INCLUDES = \
40         -I$(top_srcdir)         \
41         $(LIBGC_CFLAGS)         \
42         $(GMODULE_CFLAGS)               \
43         $(GLIB_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 AM_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=
57 else
58 monoldflags=-Wl,-version-script=$(srcdir)/ldscript
59 endif
60
61 if PLATFORM_WIN32
62 libmono_la_LDFLAGS=-no-undefined -version-info 1:0:0 $(monoldflags)
63 else
64 libmono_la_LDFLAGS=$(monoldflags)
65 endif
66
67 if JIT_SUPPORTED
68 bin_PROGRAMS = mono
69
70 noinst_PROGRAMS = genmdesc
71
72 lib_LTLIBRARIES = libmono.la
73 noinst_LTLIBRARIES = libmono-static.la
74 endif
75
76 mono_SOURCES = \
77         main.c
78
79 if STATIC_MONO
80 # Link libmono into mono statically
81 # This leads to higher performance, especially with TLS
82 MONO_LIB=libmono-static.la
83 else 
84 MONO_LIB=libmono.la
85 endif
86
87 mono_LDADD = \
88         $(MONO_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 libmetadata to speed up rebuilds
102 genmdesc_LDADD = \
103         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
104         $(GLIB_LIBS)            \
105         $(GMODULE_LIBS)
106
107 x86_sources = \
108     mini-exceptions.c   \
109         mini-x86.c              \
110         mini-x86.h              \
111         exceptions-x86.c        \
112         tramp-x86.c
113
114 amd64_sources = \
115         mini-exceptions.c       \
116         mini-amd64.c            \
117         mini-amd64.h            \
118         exceptions-amd64.c      \
119         tramp-amd64.c
120
121 ppc_sources = \
122         mini-exceptions.c       \
123         mini-ppc.c              \
124         mini-ppc.h              \
125         exceptions-ppc.c        \
126         tramp-ppc.c
127
128 sparc_sources = \
129         mini-sparc.c            \
130         mini-sparc.h            \
131     mini-exceptions.c   \
132         exceptions-sparc.c      \
133         tramp-sparc.c
134
135 s390_sources = \
136         mini-s390.c             \
137         mini-s390.h             \
138         exceptions-s390.c       \
139         tramp-s390.c
140
141 s390x_sources = \
142         mini-s390x.c            \
143         mini-s390x.h            \
144         exceptions-s390x.c      \
145         tramp-s390x.c
146
147 common_sources = \
148         mini.c          \
149         mini.h          \
150         trace.c         \
151         trace.h         \
152         mini-ops.h      \
153         mini-arch.h     \
154         dominators.c    \
155         cfold.c         \
156         regalloc.c      \
157         regalloc.h      \
158         helpers.c       \
159         liveness.c      \
160         ssa.c           \
161         abcremoval.c    \
162         abcremoval.h    \
163         ssapre.c        \
164         ssapre.h        \
165         driver.c        \
166         debug-mini.c    \
167         linear-scan.c   \
168         aot.c           \
169         graph.c         \
170         declsec.c       \
171         declsec.h
172
173 test_sources =          \
174         basic-calls.cs  \
175         basic-long.cs   \
176         bench.cs                \
177         objects.cs              \
178         arrays.cs               \
179         basic-float.cs  \
180         basic-math.cs   \
181         basic.cs                \
182         exceptions.cs   \
183         iltests.il              \
184         test.cs
185
186 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
187
188 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
189
190 if X86
191 libmono_la_SOURCES = \
192         $(common_sources) $(x86_sources)
193
194 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
195 arch_built=cpu-pentium.h
196 endif
197
198 if AMD64
199 libmono_la_SOURCES = \
200         $(common_sources) $(amd64_sources)
201 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
202 arch_built=cpu-amd64.h
203 endif
204
205 if POWERPC
206 libmono_la_SOURCES = \
207         $(common_sources) $(ppc_sources)
208
209 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
210 arch_built=cpu-g4.h
211 endif
212
213 if SPARC
214 libmono_la_SOURCES = \
215         $(common_sources) $(sparc_sources)
216
217 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
218 arch_built=cpu-sparc.h
219 endif
220
221 if SPARC64
222 libmono_la_SOURCES = \
223         $(common_sources) $(sparc_sources)
224
225 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
226 arch_built=cpu-sparc.h
227 endif
228
229 if S390
230 libmono_la_SOURCES = \
231         $(common_sources) $(s390_sources)
232
233 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
234 arch_built=cpu-s390.h
235 endif
236
237 if S390x
238 libmono_la_SOURCES = \
239         $(common_sources) $(s390x_sources)
240
241 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
242 arch_built=cpu-s390x.h
243 endif
244
245 nodist_libmono_la_SOURCES = inssel.c inssel.h
246
247 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
248 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
249 libmono_static_la_LDFLAGS = -static
250 libmono_static_la_LIBADD = $(static_libs)
251
252 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
253
254 libmonoincludedir = $(includedir)/mono/jit
255
256 libmonoinclude_HEADERS = jit.h
257
258 libmono_la_LIBADD = \
259         $(libs)
260
261 %.exe: %.cs TestDriver.dll
262         $(MCS) /out:$*.exe /unsafe $< /r:TestDriver.dll
263
264 %.exe: %.il
265         $(ILASM) /output=$*.exe $<
266
267 TestDriver.dll: $(srcdir)/TestDriver.cs
268         $(MCS) /out:TestDriver.dll /target:library $(srcdir)/TestDriver.cs
269
270 cpu-pentium.h: cpu-pentium.md genmdesc$(EXEEXT)
271         ./genmdesc $(srcdir)/cpu-pentium.md cpu-pentium.h pentium_desc
272
273 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
274         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
275
276 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
277         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
278
279 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
280         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
281
282 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
283         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390
284
285 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
286         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x
287
288 inssel.c inssel.h: $(BURGSRC)
289         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
290
291 testi: mono test.exe
292         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
293
294 # ensure the tests are actually correct
295 checktests: $(regtests)
296         for i in $(regtests); do $(RUNTIME) $$i; done
297
298 rcheck: mono $(regtests)
299         $(RUNTIME) --regression $(regtests)
300
301 aotcheck: mono $(regtests)
302         for i in $(regtests); do $(RUNTIME) --aot $$i; done
303         $(RUNTIME) --verbose --regression $(regtests)
304         rm -f *.exe.so
305
306 bench: mono test.exe
307         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
308
309 mbench: test.exe
310         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
311
312 stat1: mono bench.exe
313         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
314         perl viewstat.pl stats.pl
315
316 stat2: mono basic.exe
317         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
318         perl viewstat.pl -e stats.pl
319
320 stat3: mono bench.exe
321         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
322         perl viewstat.pl stats.pl
323
324 docu: mini.sgm
325         docbook2txt mini.sgm
326
327 check-local: rcheck
328
329 clean-local:
330         rm -f mono a.out gmon.out *.o test.exe
331
332 pkgconfigdir = $(libdir)/pkgconfig
333
334 if JIT_SUPPORTED
335 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
336 endif
337
338 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
339 EXTRA_DIST = $(common_BURGSRC) jit-icalls.c cprop.c TestDriver.cs ldscript $(test_sources) \
340         inssel-long.brg inssel-long32.brg \
341         $(x86_sources) inssel-x86.brg cpu-pentium.md \
342         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
343         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
344         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
345         $(s390_sources) inssel-s390.brg cpu-s390.md \
346         $(s390x_sources) inssel-s390x.brg cpu-s390x.md