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