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