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