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