0c3b38d0ab57e468feff8a13b338b5dc91df4eec
[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         $(LIBGC_LIBS)
10
11 MCS=mcs
12 RUNTIME=mono
13
14 INCLUDES = \
15         -I$(top_srcdir)         \
16         $(LIBGC_CFLAGS)         \
17         $(GMODULE_CFLAGS)               \
18         $(GLIB_CFLAGS)
19
20 if PLATFORM_WIN32
21 export HOST_CC
22 # The mingw math.h has "extern inline" functions that dont appear in libs, so
23 # optimisation is required to actually inline them
24 AM_CFLAGS = -O
25 endif
26
27 # hack for automake to have the same source file in a library and a bin
28 genmdesc_CFLAGS = $(AM_CFLAGS)
29
30 regtests=basic.exe arrays.exe basic-float.exe basic-long.exe objects.exe basic-calls.exe iltests.exe exceptions.exe bench.exe
31
32 libmono_la_LDFLAGS=-Wl,-version-script=$(srcdir)/ldscript
33
34 if JIT_SUPPORTED
35 bin_PROGRAMS = mono
36
37 noinst_PROGRAMS = genmdesc
38
39 lib_LTLIBRARIES = libmono.la
40 endif
41
42 mono_SOURCES = \
43         main.c
44
45 mono_LDADD = \
46         libmono.la              \
47         $(GLIB_LIBS)            \
48         $(GMODULE_LIBS) -lm
49
50 mono_LDFLAGS = \
51         -export-dynamic
52
53 genmdesc_SOURCES = \
54         mini.h          \
55         genmdesc.c      \
56         helpers.c
57
58 genmdesc_LDADD = \
59         $(libs) -lm     \
60         $(GLIB_LIBS)            \
61         $(GMODULE_LIBS)
62
63 x86_sources = \
64         mini-x86.c              \
65         mini-x86.h              \
66         exceptions-x86.c        \
67         tramp-x86.c
68
69 ppc_sources = \
70         mini-ppc.c              \
71         mini-ppc.h              \
72         exceptions-ppc.c        \
73         tramp-ppc.c
74
75 sparc_sources = \
76         mini-sparc.c            \
77         mini-sparc.h            \
78         exceptions-sparc.c      \
79         tramp-sparc.c
80
81 common_sources = \
82         mini.c          \
83         mini.h          \
84         mini-ops.h      \
85         mini-arch.h     \
86         dominators.c    \
87         cfold.c         \
88         regalloc.c      \
89         regalloc.h      \
90         inssel.c        \
91         helpers.c       \
92         liveness.c      \
93         ssa.c           \
94         driver.c        \
95         debug-mini.c    \
96         linear-scan.c   \
97         aot.c           \
98         graph.c 
99
100 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-long32.brg $(srcdir)/inssel-float.brg
101
102 if X86
103 libmono_la_SOURCES = \
104         $(common_sources) $(x86_sources)
105
106 arch_BURGSRC= $(srcdir)/inssel-x86.brg
107 endif
108
109 if POWERPC
110 libmono_la_SOURCES = \
111         $(common_sources) $(ppc_sources)
112
113 arch_BURGSRC= $(srcdir)/inssel-ppc.brg
114 endif
115
116 if SPARC
117 libmono_la_SOURCES = \
118         $(common_sources) $(sparc_sources)
119
120 arch_BURGSRC= $(srcdir)/inssel-sparc.brg
121 endif
122
123 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
124
125 libmonoincludedir = $(includedir)/mono/jit
126
127 libmonoinclude_HEADERS = jit.h
128
129 libmono_la_LIBADD = \
130         $(libs)
131
132 %.exe: %.cs TestDriver.dll
133         $(MCS) /unsafe $< /r:TestDriver.dll
134
135 %.exe: %.il
136         ilasm /OUTPUT=$*.exe $<
137
138 TestDriver.dll: TestDriver.cs
139         $(MCS) /out:TestDriver.dll /target:library TestDriver.cs
140
141 cpu-pentium.h: cpu-pentium.md genmdesc$(EXEEXT)
142         ./genmdesc $(srcdir)/cpu-pentium.md cpu-pentium.h pentium_desc
143
144 cpu-g4.h: cpu-g4.md genmdesc$(EXEEXT)
145         ./genmdesc $(srcdir)/cpu-g4.md cpu-g4.h ppcg4
146
147 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
148         ./genmdesc $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
149
150 inssel.c inssel.h: $(BURGSRC)
151         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
152
153 testi: mono test.exe
154         ./mono -v -v --ncompile 1 --compile Test:$(mtest) test.exe
155
156 # ensure the tests are actually correct
157 checktests: $(regtests)
158         for i in $(regtests); do $(RUNTIME) $$i; done
159
160 rcheck: mono $(regtests)
161         ./mono --verbose --regression $(regtests)
162
163 aotcheck: mono $(regtests)
164         for i in $(regtests); do ./mono --aot $$i; done
165         ./mono --verbose --regression $(regtests)
166         rm -f *.exe.so
167
168 bench: mono test.exe
169         time ./mono --ncompile $(count) --compile Test:$(mtest) test.exe
170
171 mbench: test.exe
172         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
173
174 stat1: mono bench.exe
175         ./mono --verbose --statfile stats.pl --regression bench.exe
176         perl viewstat.pl stats.pl
177
178 stat2: mono basic.exe
179         ./mono --verbose --statfile stats.pl --regression basic.exe
180         perl viewstat.pl -e stats.pl
181
182 stat3: mono bench.exe
183         ./mono --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
184         perl viewstat.pl stats.pl
185
186 docu: mini.sgm
187         docbook2txt mini.sgm
188
189 clean:
190         rm -f mono a.out gmon.out *.o test.exe
191
192 pkgconfigdir = $(libdir)/pkgconfig
193
194 documents=mini-doc.txt mini-porting.txt
195
196 if JIT_SUPPORTED
197 BUILT_SOURCES= inssel.c inssel.h cpu-pentium.h cpu-g4.h cpu-sparc.h
198 endif
199
200 CLEANFILES= $(BUILT_SOURCES)
201 EXTRA_DIST = $(common_BURGSRC) $(documents) inssel-x86.brg inssel-ppc.brg \
202         $(x86_sources) $(ppc_sources) $(sparc_sources)  \
203         jit-icalls.c cprop.c inssel-sparc.brg \
204         cpu-pentium.md cpu-g4.md ldscript cpu-sparc.md
205
206