Automake-fu to easily add more jit ports.
[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
10 MCS=mcs
11 RUNTIME=mono
12 WARN=-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations \
13         -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs \
14         -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings
15
16 INCLUDES = \
17         $(WARN) -fexceptions -DMONO_USE_EXC_TABLES      \
18         -I$(top_srcdir)         \
19         $(GMODULE_CFLAGS)               \
20         $(GLIB_CFLAGS)
21
22 if PLATFORM_WIN32
23 export HOST_CC
24 endif
25
26 # hack for automake to have the same source file in a library and a bin
27 genmdesc_CFLAGS = $(AM_CFLAGS)
28
29 regtests=basic.exe arrays.exe basic-float.exe basic-long.exe objects.exe basic-calls.exe iltests.exe exceptions.exe bench.exe
30
31 libmono_la_LDFLAGS=-Wl,-version-script=$(srcdir)/ldscript
32
33 if JIT_SUPPORTED
34 bin_PROGRAMS = mono genmdesc
35
36 lib_LTLIBRARIES = libmono.la
37 endif
38
39 mono_SOURCES = \
40         main.c
41
42 mono_LDADD = \
43         libmono.la              \
44         $(GLIB_LIBS)            \
45         $(GMODULE_LIBS) -lm
46
47 mono_LDFLAGS = \
48         -export-dynamic
49
50 genmdesc_SOURCES = \
51         mini.h          \
52         genmdesc.c      \
53         helpers.c
54
55 genmdesc_LDADD = \
56         $(libs) -lm     \
57         $(GLIB_LIBS)            \
58         $(GMODULE_LIBS)
59
60 x86_sources = \
61         mini-x86.c              \
62         mini-x86.h              \
63         exceptions-x86.c        \
64         tramp-x86.c
65
66 ppc_sources = \
67         mini-ppc.c              \
68         mini-ppc.h              \
69         exceptions-ppc.c        \
70         tramp-ppc.c
71
72 common_sources = \
73         mini.c          \
74         mini.h          \
75         mini-ops.h      \
76         mini-arch.h     \
77         dominators.c    \
78         cfold.c         \
79         regalloc.c      \
80         regalloc.h      \
81         inssel.c        \
82         helpers.c       \
83         liveness.c      \
84         ssa.c           \
85         driver.c        \
86         debug-mini.c    \
87         linear-scan.c   \
88         aot.c           \
89         graph.c 
90
91 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-long32.brg $(srcdir)/inssel-float.brg
92
93 if X86
94 libmono_la_SOURCES = \
95         $(common_sources) $(x86_sources)
96
97 BURGSRC= $(common_BURGSRC) $(srcdir)/inssel-x86.brg
98 endif
99
100 if POWERPC
101 libmono_la_SOURCES = \
102         $(common_sources) $(ppc_sources)
103
104 BURGSRC= $(common_BURGSRC) $(srcdir)/inssel-ppc.brg
105 endif
106
107 libmono_la_LIBADD = \
108         $(libs)
109
110 %.exe: %.cs TestDriver.dll
111         $(MCS) /unsafe $< /r:TestDriver.dll
112
113 %.exe: %.il
114         ilasm /OUTPUT=$*.exe $<
115
116 TestDriver.dll: TestDriver.cs
117         $(MCS) /out:TestDriver.dll /target:library TestDriver.cs
118
119 cpu-pentium.h: cpu-pentium.md genmdesc$(EXEEXT)
120         ./genmdesc $(srcdir)/cpu-pentium.md cpu-pentium.h pentium
121
122 inssel.c inssel.h: $(BURGSRC)
123         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
124
125 testi: mono test.exe
126         ./mono -v -v --ncompile 1 --compile Test:$(mtest) test.exe
127
128 # ensure the tests are actually correct
129 checktests: $(regtests)
130         for i in $(regtests); do $(RUNTIME) $$i; done
131
132 rcheck: mono $(regtests)
133         ./mono --verbose --regression $(regtests)
134
135 aotcheck: mono $(regtests)
136         for i in $(regtests); do ./mono --aot $$i; done
137         ./mono --verbose --regression $(regtests)
138         rm -f *.exe.so
139
140 bench: mono test.exe
141         time ./mono --ncompile $(count) --compile Test:$(mtest) test.exe
142
143 mbench: test.exe
144         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
145
146 stat1: mono bench.exe
147         ./mono --verbose --statfile stats.pl --regression bench.exe
148         perl viewstat.pl stats.pl
149
150 stat2: mono basic.exe
151         ./mono --verbose --statfile stats.pl --regression basic.exe
152         perl viewstat.pl -e stats.pl
153
154 stat3: mono bench.exe
155         ./mono --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
156         perl viewstat.pl stats.pl
157
158 docu: mini.sgm
159         docbook2txt mini.sgm
160
161 clean:
162         rm -f mono a.out gmon.out *.o test.exe
163
164 pkgconfigdir = $(libdir)/pkgconfig
165
166 BUILT_SOURCES= inssel.c inssel.h cpu-pentium.h
167 CLEANFILES= $(BUILT_SOURCES)
168 EXTRA_DIST = $(common_BURGSRC) inssel-x86.brg \
169         jit-icalls.c cprop.c \
170         cpu-pentium.md cpu-g4.md ldscript
171
172