svn path=/trunk/mono/; revision=53658
[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 $(top_builddir)/runtime/mono-wrapper
33
34 MCS = $(RUNTIME) $(mcs_topdir)/class/lib/default/mcs.exe -unsafe -nowarn:0162
35 ILASM = $(RUNTIME) $(mcs_topdir)/class/lib/default/ilasm.exe
36
37 AM_CFLAGS = \
38         -I$(top_srcdir)         \
39         $(LIBGC_CFLAGS)         \
40         $(GMODULE_CFLAGS)               \
41         $(GLIB_CFLAGS)
42         $(PLATFORM_CFLAGS) $(ARCH_CFLAGS)
43
44 if PLATFORM_WIN32
45 export HOST_CC
46 # The mingw math.h has "extern inline" functions that dont appear in libs, so
47 # optimisation is required to actually inline them
48 PLATFORM_CFLAGS = -O
49 endif
50
51 PLATFORM_LIB = ../os/libmonoos.la
52
53 # hack for automake to have the same source file in a library and a bin
54 genmdesc_CFLAGS = $(AM_CFLAGS)
55
56 if NO_VERSION_SCRIPT
57 monoldflags=
58 monobinldflags=
59 else
60 monoldflags=-Wl,-version-script=$(srcdir)/ldscript
61 monobinldflags=-Wl,-version-script=$(srcdir)/ldscript.mono
62 endif
63
64 if PLATFORM_WIN32
65 libmono_la_LDFLAGS=-no-undefined -version-info 1:0:0 $(monoldflags)
66 else
67 libmono_la_LDFLAGS=$(monoldflags)
68 endif
69
70 if JIT_SUPPORTED
71 bin_PROGRAMS = mono
72
73 noinst_PROGRAMS = genmdesc
74
75 lib_LTLIBRARIES = libmono.la
76 noinst_LTLIBRARIES = libmono-static.la
77 endif
78
79 mono_SOURCES = \
80         main.c
81
82 if STATIC_MONO
83 # Link libmono into mono statically
84 # This leads to higher performance, especially with TLS
85 MONO_LIB=libmono-static.la
86 else 
87 MONO_LIB=libmono.la
88 endif
89
90 mono_LDADD = \
91         $(MONO_LIB)                     \
92         $(PLATFORM_LIB)         \
93         $(GLIB_LIBS)            \
94         $(GMODULE_LIBS) -lm     \
95         $(ICU_LIBS)
96
97 mono_LDFLAGS = \
98         $(static_flags) -export-dynamic $(monobinldflags)
99
100 genmdesc_SOURCES = \
101         mini.h          \
102         genmdesc.c      \
103         helpers.c
104
105 # Don't link this against libmonoruntime to speed up rebuilds
106 genmdesc_LDADD = \
107         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
108         $(PLATFORM_LIB)         \
109         $(GLIB_LIBS)            \
110         $(GMODULE_LIBS)
111
112 x86_sources = \
113         mini-x86.c              \
114         mini-x86.h              \
115         exceptions-x86.c        \
116         tramp-x86.c                     \
117         mini-codegen.c          \
118         mini-trampolines.c
119
120 amd64_sources = \
121         mini-amd64.c            \
122         mini-amd64.h            \
123         exceptions-amd64.c      \
124         tramp-amd64.c           \
125         mini-codegen.c          \
126         mini-trampolines.c
127
128 ppc_sources = \
129         mini-ppc.c              \
130         mini-ppc.h              \
131         exceptions-ppc.c        \
132         tramp-ppc.c
133
134 arm_sources = \
135         mini-arm.c              \
136         mini-arm.h              \
137         exceptions-arm.c        \
138         tramp-arm.c             \
139         mini-codegen.c
140
141 sparc_sources = \
142         mini-sparc.c            \
143         mini-sparc.h            \
144         exceptions-sparc.c      \
145         tramp-sparc.c           \
146         mini-codegen.c          \
147         mini-trampolines.c
148
149 s390_sources = \
150         mini-s390.c             \
151         mini-s390.h             \
152         exceptions-s390.c       \
153         tramp-s390.c
154
155 s390x_sources = \
156         mini-s390x.c            \
157         mini-s390x.h            \
158         exceptions-s390x.c      \
159         tramp-s390x.c
160
161 ia64_sources = \
162         mini-ia64.c                     \
163         mini-ia64.h                     \
164         exceptions-ia64.c       \
165         tramp-ia64.c            \
166         mini-codegen.c          \
167         mini-trampolines.c
168
169 common_sources = \
170         mini.c          \
171         mini.h          \
172         trace.c         \
173         trace.h         \
174         mini-ops.h      \
175         mini-arch.h     \
176         dominators.c    \
177         cfold.c         \
178         regalloc.c      \
179         regalloc.h      \
180         helpers.c       \
181         liveness.c      \
182         ssa.c           \
183         abcremoval.c    \
184         abcremoval.h    \
185         ssapre.c        \
186         ssapre.h        \
187         aliasing.c      \
188         aliasing.h      \
189         ssapre-cee-ops.h \
190         ssapre-mini-ops.h \
191         driver.c        \
192         debug-mini.c    \
193         linear-scan.c   \
194         aot.c           \
195         graph.c         \
196         mini-exceptions.c       \
197         declsec.c       \
198         declsec.h       \
199         branch-opts.c
200
201 test_sources =          \
202         basic-calls.cs  \
203         basic-long.cs   \
204         bench.cs                \
205         objects.cs              \
206         arrays.cs               \
207         basic-float.cs  \
208         basic-math.cs   \
209         basic.cs                \
210         exceptions.cs   \
211         iltests.il              \
212         test.cs
213
214 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
215
216 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
217
218 if X86
219 libmono_la_SOURCES = \
220         $(common_sources) $(x86_sources)
221
222 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
223 arch_built=cpu-pentium.h
224 endif
225
226 if AMD64
227 libmono_la_SOURCES = \
228         $(common_sources) $(amd64_sources)
229 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
230 arch_built=cpu-amd64.h
231 endif
232
233 if POWERPC
234 libmono_la_SOURCES = \
235         $(common_sources) $(ppc_sources)
236
237 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
238 arch_built=cpu-g4.h
239 endif
240
241 if ARM
242
243 # pick up arm_dpimacros.h and arm_fpamacros.h
244 ARCH_CFLAGS = -I../arch/arm
245
246 libmono_la_SOURCES = \
247         $(common_sources) $(arm_sources)
248
249 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg
250 arch_built=cpu-arm.h
251 endif
252
253 if SPARC
254 libmono_la_SOURCES = \
255         $(common_sources) $(sparc_sources)
256
257 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
258 arch_built=cpu-sparc.h
259 endif
260
261 if SPARC64
262 libmono_la_SOURCES = \
263         $(common_sources) $(sparc_sources)
264
265 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
266 arch_built=cpu-sparc.h
267 endif
268
269 if S390
270 libmono_la_SOURCES = \
271         $(common_sources) $(s390_sources)
272
273 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
274 arch_built=cpu-s390.h
275 endif
276
277 if S390x
278 libmono_la_SOURCES = \
279         $(common_sources) $(s390x_sources)
280
281 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
282 arch_built=cpu-s390x.h
283 endif
284
285 if IA64
286 libmono_la_SOURCES = \
287     $(common_sources) $(ia64_sources)
288
289 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
290 arch_built = cpu-ia64.h
291 endif
292
293 nodist_libmono_la_SOURCES = inssel.c inssel.h
294
295 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
296 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
297 libmono_static_la_LDFLAGS = -static
298 libmono_static_la_LIBADD = $(static_libs) $(PLATFORM_LIB)
299
300 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
301
302 libmonoincludedir = $(includedir)/mono/jit
303
304 libmonoinclude_HEADERS = jit.h
305
306 libmono_la_LIBADD = \
307         $(libs) \
308         $(PLATFORM_LIB)
309
310 %.exe: %.cs TestDriver.dll
311         $(MCS) /out:$*.exe /unsafe $< /r:TestDriver.dll
312
313 %.exe: %.il
314         $(ILASM) /output=$*.exe $<
315
316 TestDriver.dll: $(srcdir)/TestDriver.cs
317         $(MCS) /out:TestDriver.dll /target:library $(srcdir)/TestDriver.cs
318
319 if CROSS_COMPILING
320
321 cpu-pentium.h: cpu-pentium.md
322 cpu-amd64.h: cpu-amd64.md
323 cpu-g4.h: cpu-g4.md
324 cpu-arm.h: cpu-arm.md
325 cpu-sparc.h: cpu-sparc.md
326 cpu-s390.h: cpu-s390.md
327 cpu-s390x.h: cpu-s390x.md
328 cpu-ia64.h: cpu-ia64.md
329
330 ## Gross hack.  Making 'genmdesc' a host binary takes more effort
331 $(arch_built):
332         echo "*** please build $(arch_built) on a native build tree and copy it here"
333         exit 1
334
335 else !CROSS_COMPILING
336
337 cpu-pentium.h: cpu-pentium.md genmdesc$(EXEEXT)
338         ./genmdesc $(srcdir)/cpu-pentium.md cpu-pentium.h pentium_desc
339
340 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
341         ./genmdesc $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
342
343 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
344         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
345
346 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
347         ./genmdesc $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
348
349 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
350         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
351
352 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
353         ./genmdesc $(srcdir)/cpu-s390.md cpu-s390.h s390
354
355 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
356         ./genmdesc $(srcdir)/cpu-s390x.md cpu-s390x.h s390x
357
358 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
359         ./genmdesc $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
360
361 endif !CROSS_COMPILING
362
363 inssel.c inssel.h: $(BURGSRC)
364         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
365
366 testi: mono test.exe
367         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
368
369 # ensure the tests are actually correct
370 checktests: $(regtests)
371         for i in $(regtests); do $(RUNTIME) $$i; done
372
373 rcheck: mono $(regtests)
374         $(RUNTIME) --regression $(regtests)
375
376 aotcheck: mono $(regtests)
377         for i in $(regtests); do $(RUNTIME) --aot $$i; done
378         $(RUNTIME) --verbose --regression $(regtests)
379         rm -f *.exe.so
380
381 bench: mono test.exe
382         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
383
384 mbench: test.exe
385         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
386
387 stat1: mono bench.exe
388         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
389         perl viewstat.pl stats.pl
390
391 stat2: mono basic.exe
392         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
393         perl viewstat.pl -e stats.pl
394
395 stat3: mono bench.exe
396         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
397         perl viewstat.pl stats.pl
398
399 docu: mini.sgm
400         docbook2txt mini.sgm
401
402 check-local: rcheck
403
404 clean-local:
405         rm -f mono a.out gmon.out *.o test.exe
406
407 pkgconfigdir = $(libdir)/pkgconfig
408
409 if JIT_SUPPORTED
410 BUILT_SOURCES= inssel.c inssel.h $(arch_built)
411 endif
412
413 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
414 EXTRA_DIST = $(common_BURGSRC) jit-icalls.c cprop.c TestDriver.cs ldscript ldscript.mono $(test_sources) \
415         inssel-long.brg inssel-long32.brg \
416         $(x86_sources) inssel-x86.brg cpu-pentium.md \
417         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
418         $(ppc_sources) inssel-ppc.brg cpu-g4.md \
419         $(arm_sources) inssel-arm.brg cpu-arm.md \
420         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
421         $(s390_sources) inssel-s390.brg cpu-s390.md \
422         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
423         $(ia64_sources) inssel-ia64.brg cpu-ia64.md