2008-03-04 Zoltan Varga <vargaz@gmail.com>
[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         $(GLIB_LIBS)    \
19         $(libgc_libs)
20
21 static_libs=    \
22         $(monodir)/mono/metadata/libmonoruntime-static.la       \
23         $(monodir)/mono/io-layer/libwapi.la     \
24         $(monodir)/mono/utils/libmonoutils.la \
25         $(GLIB_LIBS)    \
26         $(libgc_static_libs)
27
28 CLASS=$(mcs_topdir)/class/lib/net_2_0
29
30 RUNTIME = MONO_PATH=$(CLASS) $(top_builddir)/runtime/mono-wrapper
31 RUNTIME_AOTCHECK = MONO_PATH=$(CLASS):. $(top_builddir)/runtime/mono-wrapper
32
33 MCS = $(RUNTIME) $(CLASS)/gmcs.exe -unsafe -nowarn:0162
34 ILASM = $(RUNTIME) $(CLASS)/ilasm.exe
35
36 AM_CFLAGS = \
37         -I$(top_srcdir)         \
38         $(LIBGC_CFLAGS)         \
39         $(GLIB_CFLAGS)
40         $(PLATFORM_CFLAGS) $(ARCH_CFLAGS)
41
42 if PLATFORM_WIN32
43 export HOST_CC
44 # The mingw math.h has "extern inline" functions that dont appear in libs, so
45 # optimisation is required to actually inline them
46 PLATFORM_CFLAGS = -O
47 endif
48
49 # hack for automake to have the same source file in a library and a bin
50 genmdesc_CFLAGS = $(AM_CFLAGS)
51
52 if NO_VERSION_SCRIPT
53 monoldflags=$(export_ldflags)
54 monobinldflags=$(export_ldflags)
55 else
56 monoldflags=-Wl,-version-script=$(srcdir)/ldscript $(export_ldflags)
57 monobinldflags=-Wl,-version-script=$(srcdir)/ldscript.mono $(export_ldflags)
58 endif
59
60 if PLATFORM_WIN32
61 libmono_la_LDFLAGS=-no-undefined -avoid-version $(monoldflags)
62 else
63 libmono_la_LDFLAGS=$(monoldflags)
64 endif
65
66 if JIT_SUPPORTED
67
68 if PLATFORM_WIN32
69 bin_PROGRAMS = mono monow
70 else
71 bin_PROGRAMS = mono
72 endif
73
74 noinst_PROGRAMS = genmdesc
75
76 lib_LTLIBRARIES = libmono.la
77 noinst_LTLIBRARIES = libmono-static.la
78 endif
79
80 mono_SOURCES = \
81         main.c
82
83 if STATIC_MONO
84 # Link libmono into mono statically
85 # This leads to higher performance, especially with TLS
86 MONO_LIB=libmono-static.la
87 else 
88 MONO_LIB=libmono.la
89 endif
90
91 mono_LDADD = \
92         $(MONO_LIB)                     \
93         $(GLIB_LIBS)            \
94         -lm
95
96 mono_LDFLAGS = \
97         $(static_flags) -export-dynamic $(monobinldflags)
98
99 # Create monow.exe, linked for the 'windows' subsystem
100 if PLATFORM_WIN32
101 monow_LDADD = $(mono_LDADD)
102 monow_LDFLAGS = $(mono_LDFLAGS) -mwindows
103 monow_SOURCES = $(mono_SOURCES)
104 endif
105
106 genmdesc_SOURCES = \
107         mini.h          \
108         genmdesc.c      \
109         helpers.c
110
111 # Don't link this against libmonoruntime to speed up rebuilds
112 genmdesc_LDADD = \
113         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
114         $(GLIB_LIBS)
115
116 x86_sources = \
117         mini-x86.c              \
118         mini-x86.h              \
119         exceptions-x86.c        \
120         tramp-x86.c
121
122 amd64_sources = \
123         mini-amd64.c            \
124         mini-amd64.h            \
125         exceptions-amd64.c      \
126         tramp-amd64.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
140 mips_sources = \
141         mini-mips.c             \
142         mini-mips.h             \
143         exceptions-mips.c       \
144         tramp-mips.c
145
146 sparc_sources = \
147         mini-sparc.c            \
148         mini-sparc.h            \
149         exceptions-sparc.c      \
150         tramp-sparc.c
151
152 s390_sources = \
153         mini-s390.c             \
154         mini-s390.h             \
155         exceptions-s390.c       \
156         tramp-s390.c
157
158 s390x_sources = \
159         mini-s390x.c            \
160         mini-s390x.h            \
161         exceptions-s390x.c      \
162         tramp-s390x.c
163
164 ia64_sources = \
165         mini-ia64.c                     \
166         mini-ia64.h                     \
167         exceptions-ia64.c       \
168         tramp-ia64.c
169
170 alpha_sources = \
171         mini-alpha.c    \
172         mini-alpha.h    \
173         exceptions-alpha.c      \
174         tramp-alpha.c
175
176 hppa_sources = \
177         mini-hppa.c     \
178         mini-hppa.h     \
179         exceptions-hppa.c       \
180         tramp-hppa.c
181
182 common_sources = \
183         mini.c          \
184         mini.h          \
185         version.h       \
186         optflags-def.h          \
187         jit-icalls.h \
188         jit-icalls.c \
189         trace.c         \
190         trace.h         \
191         patch-info.h    \
192         mini-ops.h      \
193         mini-arch.h     \
194         dominators.c    \
195         cfold.c         \
196         regalloc.c      \
197         regalloc.h      \
198         helpers.c       \
199         liveness.c      \
200         ssa.c           \
201         abcremoval.c    \
202         abcremoval.h    \
203         ssapre.c        \
204         ssapre.h        \
205         aliasing.c      \
206         aliasing.h      \
207         local-propagation.c     \
208         simple-cee-ops.h \
209         simple-mini-ops.h \
210         driver.c        \
211         debug-mini.c    \
212         debug-mini.h    \
213         linear-scan.c   \
214         aot-compiler.c          \
215         aot-runtime.c           \
216         graph.c         \
217         mini-exceptions.c       \
218         mini-codegen.c          \
219         mini-trampolines.c  \
220         declsec.c       \
221         declsec.h       \
222         wapihandles.c   \
223         branch-opts.c   \
224         generic-sharing.c
225
226 test_sources =          \
227         basic-calls.cs  \
228         basic-long.cs   \
229         bench.cs                \
230         objects.cs              \
231         arrays.cs               \
232         basic-float.cs  \
233         basic-math.cs   \
234         basic.cs                \
235         exceptions.cs   \
236         devirtualization.cs     \
237         iltests.il.in           \
238         test.cs                 \
239         generics.cs     \
240         il2tests.il     \
241         generics-variant-types.il
242
243 if MONO_DEBUGGER_SUPPORTED
244 if AMD64
245 mono_debugger_arch_sources = mdb-debug-info64.s
246 else
247 if ALPHA
248 mono_debugger_arch_sources = mdb-debug-info64.s
249 else
250 mono_debugger_arch_sources = mdb-debug-info32.s
251 endif
252 endif
253 mono_debugger_sources = debug-debugger.c debug-debugger.h $(mono_debugger_arch_sources)
254 else
255 mono_debugger_sources =
256 endif
257
258 regtests=basic.exe basic-float.exe basic-long.exe basic-calls.exe objects.exe arrays.exe basic-math.exe exceptions.exe iltests.exe devirtualization.exe generics.exe il2tests.exe bench.exe
259
260 common_BURGSRC= $(srcdir)/inssel.brg $(srcdir)/inssel-float.brg
261
262 if X86
263 arch_sources = $(x86_sources) $(mono_debugger_sources)
264 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-x86.brg
265 arch_built=cpu-x86.h
266 arch_define=__i386__
267 endif
268
269 if AMD64
270 arch_sources = $(amd64_sources) $(mono_debugger_sources)
271 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-amd64.brg
272 arch_built=cpu-amd64.h
273 arch_define=__x86_64__
274 endif
275
276 if POWERPC
277 arch_sources = $(ppc_sources)
278 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-ppc.brg
279 arch_built=cpu-ppc.h
280 arch_define=__ppc__
281 endif
282
283 if MIPS
284 arch_sources = $(mips_sources)
285 arch_BURGSRC= $(srcdir)/inssel-long32-mips.brg $(srcdir)/inssel-mips.brg
286 arch_built=cpu-mips.h
287 arch_define=__mips__
288 endif
289
290 if ARM
291 # pick up arm_dpimacros.h and arm_fpamacros.h
292 ARCH_CFLAGS = -I../arch/arm
293 arch_sources = $(arm_sources)
294 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-arm.brg $(srcdir)/inssel-softfloat.brg
295 arch_built=cpu-arm.h
296 arch_define=__arm__
297 endif
298
299 if SPARC
300 arch_sources = $(sparc_sources)
301 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-sparc.brg
302 arch_built=cpu-sparc.h
303 arch_define=__sparc__
304 endif
305
306 if SPARC64
307 arch_sources = $(sparc_sources)
308 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-sparc.brg
309 arch_built=cpu-sparc.h
310 arch_define=__sparc__
311 endif
312
313 if S390
314 arch_sources = $(s390_sources)
315 arch_BURGSRC= $(srcdir)/inssel-long32.brg $(srcdir)/inssel-s390.brg
316 arch_built=cpu-s390.h
317 arch_define=__s390__
318 endif
319
320 if S390x
321 arch_sources = $(s390x_sources)
322 arch_BURGSRC= $(srcdir)/inssel-long.brg $(srcdir)/inssel-s390x.brg
323 arch_built=cpu-s390x.h
324 arch_define=__s390__
325 endif
326
327 if IA64
328 arch_sources = $(ia64_sources)
329 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-ia64.brg
330 arch_built = cpu-ia64.h
331 arch_define=__ia64__
332 endif
333
334 if ALPHA
335 arch_sources = $(alpha_sources) $(mono_debugger_sources)
336 arch_BURGSRC = $(srcdir)/inssel-long.brg $(srcdir)/inssel-alpha.brg
337 arch_built = cpu-alpha.h
338 arch_define=__alpha__
339 endif
340
341 if HPPA
342 # Only support 32-bit targets for now
343 arch_sources = $(hppa_sources)
344 arch_BURGSRC = $(srcdir)/inssel-long32.brg $(srcdir)/inssel-hppa.brg
345 arch_built = cpu-hppa.h
346 arch_define=__hppa__
347 endif
348
349 libmono_la_SOURCES = $(common_sources) $(arch_sources)
350
351 nodist_libmono_la_SOURCES = inssel.c inssel.h
352
353 libmono_static_la_SOURCES = $(libmono_la_SOURCES)
354 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
355 libmono_static_la_LDFLAGS = -static
356 libmono_static_la_LIBADD = $(static_libs)
357
358 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
359
360 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
361
362 libmonoinclude_HEADERS = jit.h
363
364 libmono_la_LIBADD = \
365         $(libs)
366
367 generics.exe: generics.cs TestDriver.dll generics-variant-types.dll
368         $(MCS) -out:$@ $< -r:TestDriver.dll -r:generics-variant-types.dll
369
370 %.exe: %.cs TestDriver.dll
371         $(MCS) -out:$@ -unsafe $< -r:TestDriver.dll
372
373 iltests.il: iltests.il.in Makefile.am
374         echo '// DO NOT EDIT: This file has been generated from iltests.il.in' > iltests.il
375         cpp -Darch=$(arch_define) < $(srcdir)/iltests.il.in | sed 's/^#.*//' >> iltests.il
376
377 %.exe: %.il
378         $(ILASM) -output=$@ $<
379
380 TestDriver.dll: $(srcdir)/TestDriver.cs
381         $(MCS) -out:$@ -target:library $<
382
383 generics-variant-types.dll: generics-variant-types.il
384         $(ILASM) -dll -output=$@ $<
385
386 # we don't always use the perl impl because it's an additional
387 # build dependency for the poor windows users
388 # $(arch_define) is the preprocessor symbol that enables all the opcodes
389 # for the specific platform in mini-ops.h
390 if CROSS_COMPILING
391 GENMDESC_PRG=perl genmdesc.pl $(arch_define) $(srcdir)
392 else !CROSS_COMPILING
393 GENMDESC_PRG=./genmdesc
394 endif !CROSS_COMPILING
395
396 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
397         $(GENMDESC_PRG) $(srcdir)/cpu-x86.md cpu-x86.h x86_desc
398
399 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
400         $(GENMDESC_PRG) $(srcdir)/cpu-amd64.md cpu-amd64.h amd64_desc
401
402 cpu-ppc.h: cpu-ppc.md genmdesc$(EXEEXT)
403         $(GENMDESC_PRG) $(srcdir)/cpu-ppc.md cpu-ppc.h ppcg4
404
405 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
406         $(GENMDESC_PRG) $(srcdir)/cpu-arm.md cpu-arm.h arm_cpu_desc
407
408 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
409         $(GENMDESC_PRG) $(srcdir)/cpu-sparc.md cpu-sparc.h sparc_desc
410
411 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
412         $(GENMDESC_PRG) $(srcdir)/cpu-s390.md cpu-s390.h s390_cpu_desc
413
414 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
415         $(GENMDESC_PRG) $(srcdir)/cpu-s390x.md cpu-s390x.h s390x_cpu_desc
416
417 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
418         $(GENMDESC_PRG) $(srcdir)/cpu-ia64.md cpu-ia64.h ia64_desc
419
420 cpu-alpha.h: cpu-alpha.md genmdesc$(EXEEXT)
421         $(GENMDESC_PRG) $(srcdir)/cpu-alpha.md cpu-alpha.h alpha_desc
422
423 cpu-hppa.h: cpu-hppa.md genmdesc$(EXEEXT)
424         $(GENMDESC_PRG) $(srcdir)/cpu-hppa.md cpu-hppa.h hppa_desc
425
426 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
427         $(GENMDESC_PRG) $(srcdir)/cpu-mips.md cpu-mips.h mips_desc
428
429 inssel.c inssel.h: $(BURGSRC)
430         $(monodir)/mono/monoburg/monoburg -c 1 -p -e $(BURGSRC) -d inssel.h -s inssel.c
431
432 testi: mono test.exe
433         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
434
435 # ensure the tests are actually correct
436 checktests: $(regtests)
437         for i in $(regtests); do $(RUNTIME) $$i; done
438
439 rcheck: mono $(regtests)
440         $(RUNTIME) --regression $(regtests)
441
442 aotcheck: mono $(regtests)
443         for i in $(regtests); do $(RUNTIME) --aot $$i || exit 1; done
444         for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
445         rm -f *.exe.so
446
447 bench: mono test.exe
448         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
449
450 mbench: test.exe
451         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
452
453 stat1: mono bench.exe
454         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
455         perl viewstat.pl stats.pl
456
457 stat2: mono basic.exe
458         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
459         perl viewstat.pl -e stats.pl
460
461 stat3: mono bench.exe
462         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
463         perl viewstat.pl stats.pl
464
465 docu: mini.sgm
466         docbook2txt mini.sgm
467
468 check-local: rcheck
469
470 clean-local:
471         rm -f mono a.out gmon.out *.o test.exe
472
473 pkgconfigdir = $(libdir)/pkgconfig
474
475 if JIT_SUPPORTED
476 BUILT_SOURCES = version.h inssel.c inssel.h $(arch_built)
477 else
478 BUILT_SOURCES = version.h
479 endif
480
481 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
482 EXTRA_DIST = $(common_BURGSRC) cprop.c TestDriver.cs ldscript ldscript.mono \
483         genmdesc.pl     \
484         $(test_sources) \
485         inssel-long.brg inssel-long32.brg \
486         inssel-softfloat.brg    \
487         $(x86_sources) inssel-x86.brg cpu-x86.md \
488         $(amd64_sources) inssel-amd64.brg cpu-amd64.md \
489         $(ppc_sources) inssel-ppc.brg cpu-ppc.md \
490         $(arm_sources) inssel-arm.brg cpu-arm.md \
491         $(mips_sources) inssel-mips.brg inssel-long32-mips.brg cpu-mips.md \
492         $(sparc_sources) inssel-sparc.brg cpu-sparc.md \
493         $(s390_sources) inssel-s390.brg cpu-s390.md \
494         $(s390x_sources) inssel-s390x.brg cpu-s390x.md \
495         $(ia64_sources) inssel-ia64.brg cpu-ia64.md \
496         $(alpha_sources) inssel-alpha.brg cpu-alpha.md \
497         $(hppa_sources) inssel-hppa.brg cpu-hppa.md
498
499 version.h: Makefile
500         if test -d $(srcdir)/.svn; then \
501                 (cd $(srcdir);  \
502                         LANG=C; \
503                         export LANG;    \
504                         branch=`svn info | grep URL | sed -e 's/.*source//' -e 's,mono/mono/mini,,'`; \
505                         version=`svn info | grep Revision | sed 's/.*: //'`; \
506                         echo "#define FULL_VERSION \"$$branch r$$version\""; \
507                 ); \
508         else \
509                 echo "#define FULL_VERSION \"tarball\""; \
510         fi > version.h
511