Fix mono version for git
[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         $(LLVM_CFLAGS)          \
41         $(PLATFORM_CFLAGS) $(ARCH_CFLAGS)
42
43 AM_CXXFLAGS = $(LLVM_CXXFLAGS) $(GLIB_CFLAGS)
44
45 if HOST_WIN32
46 export HOST_CC
47 # The mingw math.h has "extern inline" functions that dont appear in libs, so
48 # optimisation is required to actually inline them
49 PLATFORM_CFLAGS = -O
50 endif
51
52 # hack for automake to have the same source file in a library and a bin
53 genmdesc_CFLAGS = $(AM_CFLAGS)
54
55 if NO_VERSION_SCRIPT
56 monoldflags=$(export_ldflags)
57 monobinldflags=$(export_ldflags)
58 else
59 monoldflags=-Wl,-version-script=$(srcdir)/ldscript $(export_ldflags)
60 monobinldflags=-Wl,-version-script=$(srcdir)/ldscript.mono $(export_ldflags)
61 endif
62
63 if HOST_WIN32
64 libmono_2_0_la_LDFLAGS=-no-undefined -avoid-version -Wl,--kill-at $(monoldflags)
65 else
66 libmono_2_0_la_LDFLAGS=$(monoldflags) -version-info 1:0:0
67 endif
68
69 if JIT_SUPPORTED
70
71 if HOST_WIN32
72 bin_PROGRAMS = mono monow
73 else
74 bin_PROGRAMS = mono
75 endif
76
77 noinst_PROGRAMS = genmdesc
78
79 lib_LTLIBRARIES = libmono-2.0.la
80 noinst_LTLIBRARIES = libmono-static.la
81 endif
82
83 mono_SOURCES = \
84         main.c
85
86 # We build this after libmono was built so it contains the date when the final
87 # link was done
88 buildver.h: libmono-static.la
89         @echo "const char *build_date = \"`date`\";" > buildver.h
90
91 main.$(OBJEXT): buildver.h
92
93 if DTRACE_G_REQUIRED
94 LIBMONO_DTRACE_OBJECT = .libs/mono-dtrace.$(OBJEXT)
95 if STATIC_MONO
96 MONO_DTRACE_OBJECT = mono-dtrace.$(OBJEXT)
97 else
98 MONO_DTRACE_OBJECT = 
99 endif
100 else
101 MONO_DTRACE_OBJECT = 
102 LIBMONO_DTRACE_OBJECT = 
103 endif
104
105 if STATIC_MONO
106 # Link libmono into mono statically
107 # This leads to higher performance, especially with TLS
108 MONO_LIB=libmono-static.la
109 else 
110 MONO_LIB=libmono-2.0.la
111 endif
112
113 mono_LDADD = \
114         $(MONO_LIB)                     \
115         $(GLIB_LIBS)            \
116         $(LLVM_LIBS)            \
117         -lm     \
118         $(MONO_DTRACE_OBJECT) \
119         $(LLVM_LDFLAGS)
120
121 mono_LDFLAGS = \
122         $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags)
123
124 if DTRACE_G_REQUIRED
125
126 mono-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d mini.lo $(monodir)/mono/metadata/libmonoruntime-static.la
127         DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
128         $@ $(top_srcdir)/data/mono.d $(monodir)/mono/metadata/libmonoruntime-static.la mini.lo
129
130 .libs/mono-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d mini.lo $(monodir)/mono/metadata/libmonoruntime.la
131         DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
132         --pic $@ $(top_srcdir)/data/mono.d $(monodir)/mono/metadata/libmonoruntime.la mini.lo
133
134 endif
135
136 # Create monow.exe, linked for the 'windows' subsystem
137 if HOST_WIN32
138 monow_LDADD = $(mono_LDADD)
139 monow_LDFLAGS = $(mono_LDFLAGS) -mwindows
140 monow_SOURCES = $(mono_SOURCES)
141 endif
142
143 genmdesc_SOURCES = \
144         mini.h          \
145         genmdesc.c      \
146         helpers.c
147
148 # Don't link this against libmonoruntime to speed up rebuilds
149 genmdesc_LDADD = \
150         $(monodir)/mono/utils/libmonoutils.la $(monodir)/mono/metadata/opcodes.lo -lm   \
151         $(GLIB_LIBS)
152
153 x86_sources = \
154         mini-x86.c              \
155         mini-x86.h              \
156         exceptions-x86.c        \
157         tramp-x86.c
158
159 amd64_sources = \
160         mini-amd64.c            \
161         mini-amd64.h            \
162         exceptions-amd64.c      \
163         tramp-amd64.c
164
165 ppc_sources = \
166         mini-ppc.c              \
167         mini-ppc.h              \
168         exceptions-ppc.c        \
169         tramp-ppc.c
170
171 arm_sources = \
172         mini-arm.c              \
173         mini-arm.h              \
174         exceptions-arm.c        \
175         tramp-arm.c
176
177 mips_sources = \
178         mini-mips.c             \
179         mini-mips.h             \
180         exceptions-mips.c       \
181         tramp-mips.c
182
183 sparc_sources = \
184         mini-sparc.c            \
185         mini-sparc.h            \
186         exceptions-sparc.c      \
187         tramp-sparc.c
188
189 s390_sources = \
190         mini-s390.c             \
191         mini-s390.h             \
192         exceptions-s390.c       \
193         tramp-s390.c
194
195 s390x_sources = \
196         mini-s390x.c            \
197         mini-s390x.h            \
198         exceptions-s390x.c      \
199         tramp-s390x.c
200
201 ia64_sources = \
202         mini-ia64.c             \
203         mini-ia64.h             \
204         exceptions-ia64.c       \
205         tramp-ia64.c
206
207 alpha_sources = \
208         mini-alpha.c            \
209         mini-alpha.h            \
210         exceptions-alpha.c      \
211         tramp-alpha.c
212
213 hppa_sources = \
214         mini-hppa.c             \
215         mini-hppa.h             \
216         exceptions-hppa.c       \
217         tramp-hppa.c
218
219 darwin_sources = \
220         mini-darwin.c
221
222 windows_sources = \
223         mini-windows.c
224
225 posix_sources = \
226         mini-posix.c
227
228 if ENABLE_LLVM
229 llvm_sources = \
230         mini-llvm.c             \
231         mini-llvm-cpp.cpp
232 endif
233
234 common_sources = \
235         mini.c                  \
236         ir-emit.h               \
237         method-to-ir.c          \
238         decompose.c             \
239         mini.h                  \
240         version.h               \
241         optflags-def.h          \
242         jit-icalls.h            \
243         jit-icalls.c            \
244         trace.c                 \
245         trace.h                 \
246         patch-info.h            \
247         mini-ops.h              \
248         mini-arch.h             \
249         dominators.c            \
250         cfold.c                 \
251         regalloc.c              \
252         regalloc.h              \
253         helpers.c               \
254         liveness.c              \
255         ssa.c                   \
256         abcremoval.c            \
257         abcremoval.h            \
258         ssapre.c                \
259         ssapre.h                \
260         local-propagation.c     \
261         driver.c                \
262         debug-mini.c            \
263         debug-mini.h            \
264         linear-scan.c           \
265         aot-compiler.c          \
266         aot-runtime.c           \
267         graph.c                 \
268         mini-codegen.c          \
269         mini-exceptions.c       \
270         mini-trampolines.c      \
271         declsec.c               \
272         declsec.h               \
273         wapihandles.c           \
274         branch-opts.c           \
275         mini-generic-sharing.c  \
276         regalloc2.c             \
277         simd-methods.h          \
278         tasklets.c              \
279         tasklets.h              \
280         simd-intrinsics.c       \
281         mini-unwind.h           \
282         unwind.c                \
283         image-writer.h  \
284         image-writer.c  \
285         dwarfwriter.h   \
286         dwarfwriter.c   \
287         mini-gc.h               \
288         mini-gc.c               \
289         debugger-agent.h \
290         debugger-agent.c        \
291         xdebug.c
292
293 test_sources =                  \
294         basic-calls.cs          \
295         basic-long.cs           \
296         bench.cs                \
297         objects.cs              \
298         arrays.cs               \
299         basic-float.cs          \
300         basic-math.cs           \
301         basic.cs                \
302         exceptions.cs           \
303         devirtualization.cs     \
304         iltests.il.in           \
305         test.cs                 \
306         generics.cs             \
307         generics-variant-types.il\
308         basic-simd.cs
309
310 if MONO_DEBUGGER_SUPPORTED
311 if PLATFORM_DARWIN
312 mono_debugger_arch_sources = mdb-debug-info32-darwin.s
313 else
314 if AMD64
315 mono_debugger_arch_sources = mdb-debug-info64.s
316 else
317 if X86
318 mono_debugger_arch_sources = mdb-debug-info32.s
319 endif
320 endif
321 endif
322 mono_debugger_sources = debug-debugger.c debug-debugger.h $(mono_debugger_arch_sources)
323 else
324 mono_debugger_sources =
325 endif
326
327 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 basic-simd.exe
328
329 if X86
330 arch_sources = $(x86_sources) $(mono_debugger_sources)
331 arch_built=cpu-x86.h
332 arch_define=__i386__
333 endif
334
335 if AMD64
336 arch_sources = $(amd64_sources) $(mono_debugger_sources)
337 arch_built=cpu-amd64.h
338 arch_define=__x86_64__
339 endif
340
341 if POWERPC
342 arch_sources = $(ppc_sources)
343 arch_built=cpu-ppc.h
344 arch_define=__ppc__
345 endif
346
347 if POWERPC64
348 arch_sources = $(ppc_sources)
349 arch_built=cpu-ppc64.h
350 arch_define=__ppc64__
351 endif
352
353 if MIPS
354 arch_sources = $(mips_sources)
355 arch_built=cpu-mips.h
356 arch_define=__mips__
357 endif
358
359 if ARM
360 # pick up arm_dpimacros.h and arm_fpamacros.h
361 ARCH_CFLAGS = -I../arch/arm
362 arch_sources = $(arm_sources)
363 arch_built=cpu-arm.h
364 arch_define=__arm__
365 endif
366
367 if SPARC
368 arch_sources = $(sparc_sources)
369 arch_built=cpu-sparc.h
370 arch_define=__sparc__
371 endif
372
373 if SPARC64
374 arch_sources = $(sparc_sources)
375 arch_built=cpu-sparc.h
376 arch_define=__sparc__
377 endif
378
379 if S390
380 arch_sources = $(s390_sources)
381 arch_built=cpu-s390.h
382 arch_define=__s390__
383 endif
384
385 if S390x
386 arch_sources = $(s390x_sources)
387 arch_built=cpu-s390x.h
388 arch_define=__s390__
389 endif
390
391 if IA64
392 arch_sources = $(ia64_sources)
393 arch_built = cpu-ia64.h
394 arch_define=__ia64__
395 endif
396
397 if ALPHA
398 arch_sources = $(alpha_sources) $(mono_debugger_sources)
399 arch_built = cpu-alpha.h
400 arch_define=__alpha__
401 endif
402
403 if HPPA
404 # Only support 32-bit targets for now
405 arch_sources = $(hppa_sources)
406 arch_built = cpu-hppa.h
407 arch_define=__hppa__
408 endif
409
410 if HOST_WIN32
411 os_sources = $(windows_sources)
412 monobin_platform_ldflags=
413 endif
414
415 if PLATFORM_SIGPOSIX
416 os_sources = $(posix_sources)
417 monobin_platform_ldflags=
418 endif
419
420 if PLATFORM_DARWIN
421 os_sources = $(darwin_sources) $(posix_sources)
422 #monobin_platform_ldflags=-sectcreate __TEXT __info_plist $(top_srcdir)/mono/mini/Info.plist -framework CoreFoundation
423 monobin_platform_ldflags=-framework CoreFoundation
424 endif
425
426 libmono_2_0_la_SOURCES = $(common_sources) $(llvm_sources) $(arch_sources) $(os_sources)
427
428 libmono_static_la_SOURCES = $(libmono_2_0_la_SOURCES)
429 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
430 libmono_static_la_LDFLAGS = -static
431 libmono_static_la_LIBADD = $(static_libs) $(MONO_DTRACE_OBJECT)
432
433 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
434
435 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
436
437 libmonoinclude_HEADERS = jit.h
438
439 libmono_2_0_la_LIBADD = \
440         $(libs) $(LIBMONO_DTRACE_OBJECT)
441
442 basic-simd.exe: basic-simd.cs
443         $(MCS) -out:$@ $< -r:TestDriver.dll -r:Mono.Simd.dll
444
445 generics.exe: generics.cs TestDriver.dll generics-variant-types.dll
446         $(MCS) -out:$@ $< -r:TestDriver.dll -r:generics-variant-types.dll
447
448 %.exe: %.cs TestDriver.dll
449         $(MCS) -out:$@ -unsafe $< -r:TestDriver.dll
450
451 iltests.il: iltests.il.in Makefile.am
452         echo '// DO NOT EDIT: This file has been generated from iltests.il.in' > iltests.il
453         cpp -Darch=$(arch_define) < $(srcdir)/iltests.il.in | sed 's/^#.*//' >> iltests.il
454
455 %.exe: %.il
456         $(ILASM) -output=$@ $<
457
458 TestDriver.dll: $(srcdir)/TestDriver.cs
459         $(MCS) -out:$@ -target:library $<
460
461 generics-variant-types.dll: generics-variant-types.il
462         $(ILASM) -dll -output=$@ $<
463
464 # we don't always use the perl impl because it's an additional
465 # build dependency for the poor windows users
466 # $(arch_define) is the preprocessor symbol that enables all the opcodes
467 # for the specific platform in mini-ops.h
468 if CROSS_COMPILING
469 GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir)
470 else !CROSS_COMPILING
471 GENMDESC_PRG=./genmdesc
472 endif !CROSS_COMPILING
473
474 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
475         $(GENMDESC_PRG) cpu-x86.h x86_desc $(srcdir)/cpu-x86.md
476
477 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
478         $(GENMDESC_PRG) cpu-amd64.h amd64_desc $(srcdir)/cpu-amd64.md
479
480 cpu-ppc.h: cpu-ppc.md genmdesc$(EXEEXT)
481         $(GENMDESC_PRG) cpu-ppc.h ppcg4 $(srcdir)/cpu-ppc.md
482
483 cpu-ppc64.h: cpu-ppc64.md genmdesc$(EXEEXT)
484         $(GENMDESC_PRG) cpu-ppc64.h ppc64_cpu_desc $(srcdir)/cpu-ppc64.md
485
486 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
487         $(GENMDESC_PRG) cpu-arm.h arm_cpu_desc $(srcdir)/cpu-arm.md
488
489 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
490         $(GENMDESC_PRG) cpu-sparc.h sparc_desc $(srcdir)/cpu-sparc.md
491
492 cpu-s390.h: cpu-s390.md genmdesc$(EXEEXT)
493         $(GENMDESC_PRG) cpu-s390.h s390_cpu_desc $(srcdir)/cpu-s390.md
494
495 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
496         $(GENMDESC_PRG) cpu-s390x.h s390x_cpu_desc $(srcdir)/cpu-s390x.md
497
498 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
499         $(GENMDESC_PRG) cpu-ia64.h ia64_desc $(srcdir)/cpu-ia64.md
500
501 cpu-alpha.h: cpu-alpha.md genmdesc$(EXEEXT)
502         $(GENMDESC_PRG) cpu-alpha.h alpha_desc $(srcdir)/cpu-alpha.md
503
504 cpu-hppa.h: cpu-hppa.md genmdesc$(EXEEXT)
505         $(GENMDESC_PRG) cpu-hppa.h hppa_desc $(srcdir)/cpu-hppa.md
506
507 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
508         $(GENMDESC_PRG) cpu-mips.h mips_desc $(srcdir)/cpu-mips.md
509
510 testi: mono test.exe
511         $(RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
512
513 # ensure the tests are actually correct
514 checktests: $(regtests)
515         for i in $(regtests); do $(RUNTIME) $$i; done
516
517 rcheck: mono $(regtests)
518         $(RUNTIME) --regression $(regtests)
519
520 aotcheck: mono $(regtests)
521         rm -f *.exe.so
522         $(RUNTIME) --aot $(regtests) || exit 1
523         for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
524         rm -f *.exe.so
525
526 # This currently only works on amd64/arm
527 fullaotcheck: mono $(regtests)
528         rm -rf fullaot-tmp
529         mkdir fullaot-tmp
530         cp $(CLASS)/mscorlib.dll $(CLASS)/System.Core.dll $(CLASS)/System.dll $(CLASS)/Mono.Posix.dll $(CLASS)/System.Configuration.dll $(CLASS)/System.Security.dll $(CLASS)/System.Xml.dll $(CLASS)/Mono.Security.dll $(CLASS)/Mono.Simd.dll $(regtests) generics-variant-types.dll TestDriver.dll fullaot-tmp/
531         cp $(regtests) fullaot-tmp/
532         MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --aot=full fullaot-tmp/* || exit 1
533         for i in $(regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --full-aot fullaot-tmp/$$i --exclude '!FULLAOT' || exit 1; done
534
535 bench: mono test.exe
536         time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
537
538 mbench: test.exe
539         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
540
541 stat1: mono bench.exe
542         $(RUNTIME) --verbose --statfile stats.pl --regression bench.exe
543         perl viewstat.pl stats.pl
544
545 stat2: mono basic.exe
546         $(RUNTIME) --verbose --statfile stats.pl --regression basic.exe
547         perl viewstat.pl -e stats.pl
548
549 stat3: mono bench.exe
550         $(RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
551         perl viewstat.pl stats.pl
552
553 docu: mini.sgm
554         docbook2txt mini.sgm
555
556 check-local: rcheck
557
558 clean-local:
559         rm -f mono a.out gmon.out *.o buildver.h test.exe
560
561 pkgconfigdir = $(libdir)/pkgconfig
562
563 if JIT_SUPPORTED
564 BUILT_SOURCES = version.h $(arch_built)
565 else
566 BUILT_SOURCES = version.h
567 endif
568
569 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
570 EXTRA_DIST = $(common_BURGSRC) TestDriver.cs ldscript ldscript.mono \
571         genmdesc.pl     \
572         $(test_sources) \
573         $(x86_sources) cpu-x86.md \
574         $(amd64_sources) cpu-amd64.md \
575         $(ppc_sources) cpu-ppc.md cpu-ppc64.md \
576         $(arm_sources) cpu-arm.md \
577         $(mips_sources) cpu-mips.md \
578         $(sparc_sources) cpu-sparc.md \
579         $(s390_sources) cpu-s390.md \
580         $(s390x_sources) cpu-s390x.md \
581         $(ia64_sources) cpu-ia64.md \
582         $(alpha_sources) cpu-alpha.md \
583         $(hppa_sources) cpu-hppa.md     \
584         $(windows_sources)              \
585         $(darwin_sources) Info.plist    \
586         $(posix_sources)
587
588 version.h: Makefile
589         if test -d $(top_srcdir)/.git; then svn_info="git log --no-color --first-parent -n1 --grep=git-svn-id: --pretty=format:%b | sed -n -e 's,git-svn-id: \(.*\)@\(.*\) .*,URL: \1 Revision: \2,p'"; fi; \
590         if test -d $(srcdir)/.svn; then svn_info='svn info'; fi; \
591         if test -n "$$svn_info"; then \
592                 (cd $(top_srcdir); \
593                         LANG=C; export LANG; \
594                         branch=`eval $$svn_info | sed -n -e '/URL/ s,.*source/\(.*\)/mono.*,/\1/mono,p'`; \
595                         version=`eval $$svn_info | sed -n -e '/Revision/ s/.*: //p'`; \
596                         echo "#define FULL_VERSION \"$$branch r$$version\""; \
597                 ); \
598         else \
599                 echo "#define FULL_VERSION \"tarball\""; \
600         fi > version.h
601
602 # Utility target for patching libtool to speed up linking
603 patch-libtool:
604         sed -e 's,if (for obj in $$oldobjs,if (for obj in "",g' < ../../libtool > 2; mv 2 ../../libtool
605         chmod a+x ../../libtool
606
607 tags:
608         etags -o TAGS `find .. -name "*.h" -o -name "*.c"`