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