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