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