[profiler] Implement call context introspection for enter/leave events.
[mono.git] / mono / mini / Makefile.am.in
1 count=100000
2 mtest=for_loop
3 monodir=$(top_builddir)
4 mono=$(if $(MONO_EXECUTABLE),$(MONO_EXECUTABLE),mono)
5
6 if HOST_WIN32
7 PLATFORM_PATH_SEPARATOR=;
8 else
9 PLATFORM_PATH_SEPARATOR=:
10 endif
11
12 # This is needed for automake dependency generation
13 if SUPPORT_NULLGC
14 libgc_libs=
15 libgc_static_libs=
16 else
17 libgc_libs=$(monodir)/libgc/libmonogc.la
18 libgc_static_libs=$(monodir)/libgc/libmonogc-static.la
19 endif
20
21 boehm_libs=     \
22         $(monodir)/mono/metadata/libmonoruntime.la      \
23         $(monodir)/mono/utils/libmonoutils.la \
24         $(GLIB_LIBS) $(LIBICONV) \
25         $(libgc_libs)
26
27 sgen_libs = \
28         $(monodir)/mono/metadata/libmonoruntimesgen.la  \
29         $(monodir)/mono/sgen/libmonosgen.la     \
30         $(monodir)/mono/utils/libmonoutils.la \
31         $(GLIB_LIBS) $(LIBICONV)
32
33 boehm_static_libs=      \
34         $(monodir)/mono/metadata/libmonoruntime-static.la       \
35         $(monodir)/mono/utils/libmonoutils.la \
36         $(GLIB_LIBS) $(LIBICONV) \
37         $(libgc_static_libs)
38
39 sgen_static_libs = \
40         $(monodir)/mono/metadata/libmonoruntimesgen-static.la   \
41         $(monodir)/mono/sgen/libmonosgen-static.la      \
42         $(monodir)/mono/utils/libmonoutils.la \
43         $(GLIB_LIBS) $(LIBICONV)
44
45 if FULL_AOT_TESTS
46 # if the tests are going to run with framework assemblies compiled with
47 # -d:MOBILE, tell the runtime to remap framework assemblies using the mobile
48 # runtime info
49 MOBILE_RUNTIME_ARG=--runtime=mobile
50 else
51 MOBILE_RUNTIME_ARG=
52 endif
53
54 CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
55
56 RUNTIME_EXECUTABLE = $(if $(BOEHM),$(top_builddir)/mono/mini/mono-boehm,$(top_builddir)/runtime/mono-wrapper)
57
58 MINI_RUNTIME = MONO_PATH=$(CLASS) $(RUNTIME_EXECUTABLE) $(MOBILE_RUNTIME_ARG)
59 TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(top_builddir)/runtime/mono-wrapper
60 INTERP_RUNTIME = $(MINI_RUNTIME) --interpreter
61 RUNTIME_AOTCHECK = MONO_PATH="$(CLASS)$(PLATFORM_PATH_SEPARATOR)." $(RUNTIME_EXECUTABLE)
62
63 MCS = CSC_SDK_PATH_DISABLED= $(TOOLS_RUNTIME) $(CSC) -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll -r:$(CLASS)/System.Core.dll
64 ILASM = $(TOOLS_RUNTIME) $(mcs_topdir)/class/lib/build/ilasm.exe
65
66 AM_CFLAGS = \
67         -I$(top_srcdir)         \
68         $(GLIB_CFLAGS)          \
69         $(LLVM_CFLAGS)          \
70         $(PLATFORM_CFLAGS) $(ARCH_CFLAGS) $(SHARED_CFLAGS)
71
72 AM_CXXFLAGS = $(LLVM_CXXFLAGS) $(GLIB_CFLAGS)
73
74 if HOST_WIN32
75 export HOST_CC
76 # The mingw math.h has "extern inline" functions that dont appear in libs, so
77 # optimisation is required to actually inline them
78 PLATFORM_CFLAGS = -O
79 endif
80
81 # hack for automake to have the same source file in a library and a bin
82 genmdesc_CFLAGS = $(AM_CFLAGS)
83
84 monoldflags=$(export_ldflags)
85 monobinldflags=$(export_ldflags) $(extra_runtime_ldflags)
86
87 if HOST_WIN32
88 libmonoldflags=-no-undefined -avoid-version -Wl,--kill-at $(monoldflags)
89 else
90 if PLATFORM_ANDROID
91 libmonoldflags= -avoid-version $(monoldflags)
92 else
93 libmonoldflags=$(monoldflags) -version-info 1:0:0
94 endif
95 endif
96
97 if SUPPORT_SGEN
98 sgen_binaries = mono-sgen
99 sgen_libraries = libmonosgen-2.0.la
100 sgen_static_libraries = libmini-static.la $(sgen_static_libs)
101 endif
102
103 if SUPPORT_BOEHM
104 boehm_libraries = libmonoboehm-2.0.la
105 boehm_static_libraries = libmini-static.la $(boehm_static_libs)
106 boehm_binaries  = mono-boehm
107 endif
108
109 if SUPPORT_SGEN
110 mono_bin_suffix = sgen
111 libmono_suffix = sgen
112 else
113 mono_bin_suffix = boehm
114 libmono_suffix = boehm
115 endif
116
117 if DISABLE_EXECUTABLES
118 else
119 mono: mono-$(mono_bin_suffix)
120         ln -sf $< $@
121
122 mono.exe: mono-$(mono_bin_suffix).exe
123         ln -sf $< $@
124
125 install-exec-hook:
126         (cd $(DESTDIR)$(bindir) && ln -sf mono-$(mono_bin_suffix) mono)
127         (cd $(DESTDIR)$(libdir); shopt -s nullglob 2>/dev/null; for i in libmono$(libmono_suffix)*; do ln -sf $$i `echo $$i | sed s/$(libmono_suffix)//` ; done)
128 endif
129
130 if DISABLE_EXECUTABLES
131 else
132 if HOST_WIN32
133 bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) monow
134 else
135 bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries)
136 endif
137 endif
138
139 if DISABLE_EXECUTABLES
140 noinst_PROGRAMS = genmdesc
141 else
142 noinst_PROGRAMS = genmdesc mono
143 endif
144
145 if DISABLE_EXECUTABLES
146 shared_libraries = $(boehm_libraries) $(sgen_libraries)
147 else
148 if SHARED_MONO
149 shared_libraries = $(boehm_libraries) $(sgen_libraries)
150 endif
151 endif
152
153 lib_LTLIBRARIES = $(shared_libraries)
154
155 if SHARED_MONO
156 mini_common_lib = libmini.la
157 else
158 mini_common_lib = 
159 endif
160
161 if DISABLE_EXECUTABLES
162 noinst_LTLIBRARIES = $(mini_common_lib)
163 else
164 noinst_LTLIBRARIES = $(mini_common_lib) libmini-static.la
165 endif
166
167 if LOADED_LLVM
168 lib_LTLIBRARIES += libmono-llvm.la
169 libmono_llvm_la_SOURCES = mini-llvm.c mini-llvm-cpp.cpp llvm-jit.cpp
170 libmono_llvm_la_LIBADD = $(GLIB_LIBS) $(LLVM_LIBS) $(LLVM_LDFLAGS)
171 if PLATFORM_DARWIN
172 libmono_llvm_la_LDFLAGS=-Wl,-undefined -Wl,suppress -Wl,-flat_namespace
173 else
174 libmono_llvm_la_LIBADD += $(top_builddir)/mono/mini/libmonoboehm-$(API_VER).la $(boehm_libs)
175 endif
176 endif
177
178 mono_boehm_SOURCES = \
179         main.c
180
181 mono_CFLAGS = $(AM_CFLAGS)
182
183 mono_boehm_CFLAGS = $(AM_CFLAGS)
184
185 AM_CPPFLAGS = $(LIBGC_CPPFLAGS)
186
187 mono_sgen_SOURCES = \
188         main-sgen.c
189
190 mono_SOURCES = \
191         main-sgen.c
192
193 mono_sgen_CFLAGS = $(AM_CFLAGS)
194
195 # We build this after libmono was built so it contains the date when the final
196 # link was done
197 if SUPPORT_BOEHM
198 if DISABLE_EXECUTABLES
199 buildver-boehm.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntime.la
200 else
201 buildver-boehm.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntime-static.la
202 endif
203         @echo "const char *build_date = \"`date`\";" > buildver-boehm.h
204 mono_boehm-main.$(OBJEXT): buildver-boehm.h
205 endif
206
207 if DISABLE_EXECUTABLES
208 buildver-sgen.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimesgen.la $(monodir)/mono/sgen/libmonosgen.la
209 else
210 buildver-sgen.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimesgen-static.la $(monodir)/mono/sgen/libmonosgen-static.la
211 endif
212         @echo "const char *build_date = \"`date`\";" > buildver-sgen.h
213 mono_sgen-main-sgen.$(OBJEXT): buildver-sgen.h
214 main-sgen.$(OBJEXT): buildver-sgen.h
215
216 if DTRACE_G_REQUIRED
217 LIBMONO_DTRACE_OBJECT = .libs/mono-dtrace.$(OBJEXT)
218 if STATIC_MONO
219 MONO_DTRACE_OBJECT = mono-dtrace.$(OBJEXT)
220 else
221 MONO_DTRACE_OBJECT = 
222 endif
223 else
224 MONO_DTRACE_OBJECT = 
225 LIBMONO_DTRACE_OBJECT = 
226 endif
227
228 if STATIC_MONO
229 # Link libmono into mono statically
230 # This leads to higher performance, especially with TLS
231 MONO_LIB=$(boehm_static_libraries)
232 MONO_SGEN_LIB=$(sgen_static_libraries)
233 else 
234 MONO_LIB=libmonoboehm-2.0.la
235 MONO_SGEN_LIB=libmonosgen-2.0.la
236 endif
237
238 if LOADED_LLVM
239 LLVMMONOF=
240 else
241 LLVMMONOF=$(LLVM_LIBS) $(LLVM_LDFLAGS)
242 endif
243
244 mono_boehm_LDADD = \
245         $(MONO_LIB)             \
246         $(GLIB_LIBS)            \
247         $(LLVMMONOF)            \
248         $(LIBICONV)             \
249         -lm                     \
250         $(MONO_DTRACE_OBJECT)
251
252 mono_boehm_LDFLAGS = \
253         $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags)
254
255 mono_sgen_LDADD = \
256         $(MONO_SGEN_LIB)        \
257         $(GLIB_LIBS)            \
258         $(LLVMMONOF)            \
259         $(LIBICONV)             \
260         -lm                     \
261         $(MONO_DTRACE_OBJECT)
262
263 mono_sgen_LDFLAGS = $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags)
264
265 if BITCODE
266 libmonoldflags += -no-undefined
267 endif
268
269 # if SUPPORT_SGEN
270
271 # mono_LDADD = $(mono_sgen_LDADD)
272 # mono_LDFLAGS = $(mono_sgen_LDFLAGS)
273
274 # endif
275
276
277 if DTRACE_G_REQUIRED
278
279 mono-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d mini.lo $(monodir)/mono/metadata/libmonoruntime-static.la
280         DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
281         $@ $(top_srcdir)/data/mono.d $(monodir)/mono/metadata/libmonoruntime-static.la mini.lo
282
283 .libs/mono-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d mini.lo $(monodir)/mono/metadata/libmonoruntime.la
284         DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
285         --pic $@ $(top_srcdir)/data/mono.d $(monodir)/mono/metadata/libmonoruntime.la mini.lo
286
287 endif
288
289 # Create monow.exe, linked for the 'windows' subsystem
290 if HOST_WIN32
291 if SUPPORT_BOEHM
292 monow_LDADD = $(mono_boehm_LDADD)
293 monow_LDFLAGS = $(mono_boehm_LDFLAGS) -mwindows
294 monow_SOURCES = $(mono_boehm_SOURCES)
295 else
296 monow_LDADD = $(mono_sgen_LDADD)
297 monow_LDFLAGS = $(mono_sgen_LDFLAGS) -mwindows
298 monow_SOURCES = $(mono_sgen_SOURCES)
299 endif
300 endif
301
302 genmdesc_SOURCES = \
303         mini.h          \
304         seq-points.h    \
305         genmdesc.c      \
306         helpers.c       \
307         ../metadata/opcodes.c
308
309 # Don't link this against libmonoruntime to speed up rebuilds
310 genmdesc_LDADD = \
311         $(monodir)/mono/utils/libmonoutils.la -lm       \
312         $(GLIB_LIBS)                                    \
313         $(LIBICONV)
314
315 x86_sources = \
316         mini-x86.c              \
317         mini-x86.h              \
318         exceptions-x86.c        \
319         tramp-x86.c     \
320         mini-x86-gsharedvt.c    \
321         tramp-x86-gsharedvt.c
322
323 amd64_sources = \
324         mini-amd64.c            \
325         mini-amd64.h            \
326         exceptions-amd64.c      \
327         tramp-amd64.c   \
328         mini-amd64-gsharedvt.c  \
329         mini-amd64-gsharedvt.h  \
330         tramp-amd64-gsharedvt.c
331
332 ppc_sources = \
333         mini-ppc.c              \
334         mini-ppc.h              \
335         exceptions-ppc.c        \
336         tramp-ppc.c
337
338 arm_sources = \
339         mini-arm.c              \
340         mini-arm.h              \
341         exceptions-arm.c        \
342         tramp-arm.c     \
343         mini-arm-gsharedvt.c    \
344         tramp-arm-gsharedvt.c
345
346 arm64_sources = \
347         mini-arm64.c            \
348         mini-arm64.h            \
349         exceptions-arm64.c      \
350         tramp-arm64.c   \
351         mini-arm64-gsharedvt.c  \
352         mini-arm64-gsharedvt.h  \
353         tramp-arm64-gsharedvt.c
354
355 mips_sources = \
356         mini-mips.c             \
357         mini-mips.h             \
358         exceptions-mips.c       \
359         tramp-mips.c
360
361 sparc_sources = \
362         mini-sparc.c            \
363         mini-sparc.h            \
364         exceptions-sparc.c      \
365         tramp-sparc.c
366
367 s390x_sources = \
368         mini-s390x.c            \
369         mini-s390x.h            \
370         support-s390x.h         \
371         exceptions-s390x.c      \
372         tramp-s390x.c
373
374 darwin_sources = \
375         mini-darwin.c
376
377 windows_sources = \
378         mini-windows.c \
379         mini-windows.h \
380         mini-windows-dllmain.c \
381         mini-windows-dlldac.c
382
383 posix_sources = \
384         mini-posix.c
385
386 if ENABLE_LLVM
387 if LOADED_LLVM
388 llvm_sources = \
389         mini-llvm-loaded.c
390 else
391 llvm_sources = \
392         mini-llvm.c             \
393         mini-llvm-loaded.c \
394         mini-llvm-cpp.cpp \
395         llvm-jit.cpp
396 endif
397 endif
398
399 if ENABLE_INTERPRETER
400 interp_sources =        \
401         interp/hacks.h          \
402         interp/interp.h \
403         interp/interp-internals.h       \
404         interp/interp.c \
405         interp/mintops.h        \
406         interp/mintops.def      \
407         interp/mintops.c        \
408         interp/transform.c
409 else
410 interp_sources = \
411         interp/interp-stubs.c
412 endif
413
414 if ENABLE_LLVM
415 llvm_runtime_sources = \
416         llvm-runtime.cpp
417 else
418 if ENABLE_LLVM_RUNTIME
419 llvm_runtime_sources = \
420         llvm-runtime.cpp
421 endif
422 endif
423
424 common_sources = \
425         mini.c                  \
426         mini-runtime.c  \
427         seq-points.c    \
428         seq-points.h    \
429         ir-emit.h               \
430         method-to-ir.c          \
431         cfgdump.h               \
432         cfgdump.c               \
433         decompose.c             \
434         mini.h                  \
435         version.h               \
436         optflags-def.h          \
437         jit-icalls.h            \
438         jit-icalls.c            \
439         trace.c                 \
440         trace.h                 \
441         patch-info.h            \
442         mini-ops.h              \
443         mini-arch.h             \
444         dominators.c            \
445         cfold.c                 \
446         regalloc.h              \
447         helpers.c               \
448         liveness.c              \
449         ssa.c                   \
450         abcremoval.c            \
451         abcremoval.h            \
452         local-propagation.c     \
453         driver.c                \
454         debug-mini.c            \
455         linear-scan.c           \
456         aot-compiler.h          \
457         aot-compiler.c          \
458         aot-runtime.c           \
459         graph.c                 \
460         mini-codegen.c          \
461         mini-exceptions.c       \
462         mini-trampolines.c      \
463         branch-opts.c           \
464         mini-generic-sharing.c  \
465         simd-methods.h          \
466         tasklets.c              \
467         tasklets.h              \
468         simd-intrinsics.c       \
469         mini-native-types.c \
470         mini-unwind.h           \
471         unwind.c                \
472         image-writer.h          \
473         image-writer.c          \
474         dwarfwriter.h           \
475         dwarfwriter.c           \
476         mini-gc.h               \
477         mini-gc.c               \
478         debugger-agent.h        \
479         debugger-agent.c        \
480         xdebug.c                        \
481         mini-llvm.h                     \
482         mini-llvm-cpp.h \
483         llvm-jit.h              \
484         alias-analysis.c        \
485         mini-cross-helpers.c \
486         arch-stubs.c            \
487         llvm-runtime.h  \
488         type-checking.c \
489         lldb.h                  \
490         lldb.c  \
491         memory-access.c \
492         mini-profiler.c
493
494 test_sources =                  \
495         basic-calls.cs          \
496         basic-long.cs           \
497         bench.cs                \
498         builtin-types.cs        \
499         objects.cs              \
500         arrays.cs               \
501         basic-float.cs          \
502         basic-math.cs           \
503         basic.cs                \
504         exceptions.cs           \
505         devirtualization.cs     \
506         iltests.il              \
507         test.cs                 \
508         generics.cs             \
509         generics-variant-types.il\
510         basic-simd.cs \
511         basic-vectors.cs \
512         aot-tests.cs \
513         gc-test.cs \
514         gshared.cs \
515         unaligned.cs    \
516         MemoryIntrinsics.il     \
517         mixed.cs
518
519 regtests_UNIVERSAL = \
520         basic.exe \
521         basic-float.exe \
522         basic-long.exe \
523         basic-calls.exe \
524         builtin-types.exe \
525         objects.exe \
526         arrays.exe \
527         basic-math.exe \
528         exceptions.exe \
529         iltests.exe \
530         devirtualization.exe \
531         generics.exe \
532         basic-simd.exe \
533         unaligned.exe   \
534         basic-vectors.exe
535
536 regtests_DISABLED = 
537
538 if FULL_AOT_TESTS
539 regtests_DISABLED += builtin-types.exe
540 endif
541
542 regtests = $(filter-out $(regtests_DISABLED),$(regtests_UNIVERSAL))
543
544 if X86
545 arch_sources = $(x86_sources)
546 arch_built=cpu-x86.h
547 arch_define=__i386__
548 endif
549
550 if AMD64
551 arch_sources = $(amd64_sources)
552 arch_built=cpu-amd64.h
553 arch_define=__x86_64__
554 ARCH_FULLAOT_EXCLUDE=
555 endif
556
557 if POWERPC
558 arch_sources = $(ppc_sources)
559 arch_built=cpu-ppc.h
560 arch_define=__ppc__
561 endif
562
563 if POWERPC64
564 arch_sources = $(ppc_sources)
565 arch_built=cpu-ppc64.h
566 arch_define=__ppc64__
567 endif
568
569 if MIPS
570 arch_sources = $(mips_sources)
571 arch_built=cpu-mips.h
572 arch_define=__mips__
573 endif
574
575 if ARM
576 # pick up arm_dpimacros.h
577 ARCH_CFLAGS = -I../arch/arm
578 arch_sources = $(arm_sources)
579 arch_built=cpu-arm.h
580 arch_define=__arm__
581 endif
582
583 if ARM64
584 arch_sources = $(arm64_sources)
585 arch_built=cpu-arm64.h
586 arch_define=__aarch64__
587 endif
588
589 if SPARC
590 arch_sources = $(sparc_sources)
591 arch_built=cpu-sparc.h
592 arch_define=__sparc__
593 endif
594
595 if SPARC64
596 arch_sources = $(sparc_sources)
597 arch_built=cpu-sparc.h
598 arch_define=__sparc__
599 endif
600
601 if S390X
602 arch_sources = $(s390x_sources)
603 arch_built=cpu-s390x.h
604 arch_define=__s390__
605 endif
606
607 if HOST_WIN32
608 os_sources = $(windows_sources)
609 monobin_platform_ldflags=
610 endif
611
612 if PLATFORM_SIGPOSIX
613 os_sources = $(posix_sources)
614 monobin_platform_ldflags=
615 endif
616
617 if PLATFORM_DARWIN
618 os_sources = $(darwin_sources) $(posix_sources)
619 #monobin_platform_ldflags=-sectcreate __TEXT __info_plist $(top_srcdir)/mono/mini/Info.plist -framework CoreFoundation -framework Foundation
620 monobin_platform_ldflags=-framework CoreFoundation -framework Foundation
621 endif
622
623 libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(interp_sources) $(arch_sources) $(os_sources)
624 libmini_la_CFLAGS = $(mono_CFLAGS)
625
626 libmonoboehm_2_0_la_SOURCES =
627 libmonoboehm_2_0_la_CFLAGS = $(mono_boehm_CFLAGS)
628 libmonoboehm_2_0_la_LIBADD = libmini.la $(boehm_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
629 libmonoboehm_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags)
630
631 libmonosgen_2_0_la_SOURCES =
632 libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS)
633 libmonosgen_2_0_la_LIBADD = libmini.la $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
634 libmonosgen_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags)
635
636 #
637 # This library is shared between mono and mono-sgen, since the code in mini/ doesn't contain
638 # compile time dependencies on boehm/sgen.
639 #
640 libmini_static_la_SOURCES = $(libmini_la_SOURCES)
641 libmini_static_la_CFLAGS = $(AM_CFLAGS)
642 libmini_static_la_LDFLAGS = -static
643 libmini_static_la_LIBADD = $(MONO_DTRACE_OBJECT)
644
645 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
646
647 libmonoinclude_HEADERS = jit.h
648
649 CSFLAGS = -unsafe -nowarn:0219,0169,0414,0649,0618
650
651 basic-simd.exe: basic-simd.cs TestDriver.dll
652         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/Mono.Simd.dll
653
654 basic-vectors.exe: basic-vectors.cs TestDriver.dll
655         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/System.Numerics.dll -r:$(CLASS)/System.Numerics.Vectors.dll
656
657 builtin-types.exe: builtin-types.cs TestDriver.dll
658         $(MCS) -out:$@ $(CSFLAGS) -define:ARCH_$(shell echo $$((8 * $(SIZEOF_VOID_P)))) $< -r:TestDriver.dll
659
660 nacl.exe: nacl.cs TestDriver.dll
661         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/Mono.Simd.dll
662
663 generics.exe: generics.cs TestDriver.dll generics-variant-types.dll
664         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:generics-variant-types.dll -r:$(CLASS)/System.Core.dll
665
666 unaligned.exe: unaligned.cs TestDriver.dll MemoryIntrinsics.dll
667         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:MemoryIntrinsics.dll
668
669 %.exe: %.cs TestDriver.dll
670         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll
671
672 %.exe: %.il
673         $(ILASM) -output=$@ $<
674
675 TestDriver.dll: $(srcdir)/TestDriver.cs $(srcdir)/TestHelpers.cs
676         $(MCS) -out:$@ -target:library $^
677
678 generics-variant-types.dll: generics-variant-types.il
679         $(ILASM) -dll -output=$@ $<
680
681 MemoryIntrinsics.dll: MemoryIntrinsics.il
682         $(ILASM) -dll -output=$@ $<
683
684 GENMDESC_OPTS=
685
686 # we don't always use the perl impl because it's an additional
687 # build dependency for the poor windows users
688 # $(arch_define) is the preprocessor symbol that enables all the opcodes
689 # for the specific platform in mini-ops.h
690 if CROSS_COMPILING
691 GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
692 else !CROSS_COMPILING
693 GENMDESC_PRG=./genmdesc $(GENMDESC_OPTS)
694 endif !CROSS_COMPILING
695
696 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
697         $(GENMDESC_PRG) cpu-x86.h x86_desc $(srcdir)/cpu-x86.md
698
699 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
700         $(GENMDESC_PRG) cpu-amd64.h amd64_desc $(srcdir)/cpu-amd64.md
701
702 cpu-ppc.h: cpu-ppc.md genmdesc$(EXEEXT)
703         $(GENMDESC_PRG) cpu-ppc.h ppcg4 $(srcdir)/cpu-ppc.md
704
705 cpu-ppc64.h: cpu-ppc64.md genmdesc$(EXEEXT)
706         $(GENMDESC_PRG) cpu-ppc64.h ppc64_cpu_desc $(srcdir)/cpu-ppc64.md
707
708 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
709         $(GENMDESC_PRG) cpu-arm.h arm_cpu_desc $(srcdir)/cpu-arm.md
710
711 cpu-arm64.h: cpu-arm64.md genmdesc$(EXEEXT)
712         $(GENMDESC_PRG) cpu-arm64.h arm64_cpu_desc $(srcdir)/cpu-arm64.md
713
714 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
715         $(GENMDESC_PRG) cpu-sparc.h sparc_desc $(srcdir)/cpu-sparc.md
716
717 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
718         $(GENMDESC_PRG) cpu-s390x.h s390x_cpu_desc $(srcdir)/cpu-s390x.md
719
720 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
721         $(GENMDESC_PRG) cpu-mips.h mips_desc $(srcdir)/cpu-mips.md
722
723 testi: mono test.exe
724         $(MINI_RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
725
726 # ensure the tests are actually correct
727 checktests: $(regtests)
728         for i in $(regtests); do $(MINI_RUNTIME) $$i; done
729
730 rcheck-nunit: mono $(regtests)
731         $(MINI_RUNTIME) --regression $(regtests) > regressiontests.out 2>&1; cat regressiontests.out; \
732         if grep -q "100% pass" regressiontests.out; then successbool=True; failurescount=0; else successbool=False; failurescount=1; fi; \
733         echo "<?xml version='1.0' encoding='utf-8'?>\
734                 <test-results failures='$$failurescount' total='1' not-run='0' name='regression-tests.dummy' date='$$(date +%F)' time='$$(date +%T)'>\
735                         <test-suite name='regression-tests.dummy' success='$$successbool' time='0'>\
736                                 <results><test-case name='MonoTests.regressions.100percentsuccess' executed='True' success='$$successbool' time='0'>" > TestResult-regression.xml; \
737                                         if [ "$$successbool" = "False" ]; then echo "<failure><message><![CDATA[$$(cat regressiontests.out)]]></message><stack-trace></stack-trace></failure>" >> TestResult-regression.xml; fi; \
738                                 echo "</test-case></results>\
739                         </test-suite>\
740                 </test-results>" >> TestResult-regression.xml; exit $$failurescount
741
742 rcheck: mono $(regtests)
743         $(MINI_RUNTIME) --regression $(regtests)
744
745 richeck: mono $(regtests)
746         $(INTERP_RUNTIME) --regression $(regtests)
747
748 mixedcheck: mono mixed.exe
749         $(MINI_RUNTIME) --interp=jit=JitClass mixed.exe
750
751 if ARM
752 check-seq-points:
753 else
754 check-seq-points: mono $(regtests)
755         rm -f TestResult-op_il_seq_point.xml
756         for i in $(regtests); do $(srcdir)/test_op_il_seq_point.sh $$i || ($(srcdir)/test_op_il_seq_point_headerfooter.sh; exit 1) || exit 1; done
757         for i in $(regtests); do $(srcdir)/test_op_il_seq_point.sh $$i --aot || ($(srcdir)/test_op_il_seq_point_headerfooter.sh; exit 1) || exit 1; done
758         $(srcdir)/test_op_il_seq_point_headerfooter.sh
759 endif
760
761 gctest: mono gc-test.exe
762         MONO_DEBUG_OPTIONS=clear-nursery-at-gc $(MINI_RUNTIME) --regression gc-test.exe
763
764 LLVM_AOT_RUNTIME_OPTS=$(if $(LLVM),--llvm,)
765 GSHAREDVT_RUNTIME_OPTS=$(if $(GSHAREDVT),-O=gsharedvt,)
766
767 aotcheck: mono $(regtests)
768         rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
769         $(MINI_RUNTIME) $(LLVM_AOT_RUNTIME_OPTS) --aot $(regtests) || exit 1
770         for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
771         rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
772
773 llvmaotcheck:
774         $(MAKE) aotcheck LLVM=1
775
776 gsharedvtcheck:
777         $(MAKE) fullaotcheck GSHAREDVT=1
778
779 fullaot_regtests = $(regtests) aot-tests.exe $(if $(GSHAREDVT),gshared.exe)
780 fullaot_testing_deps = generics-variant-types.dll TestDriver.dll MemoryIntrinsics.dll
781
782 FULLAOT_LIBS_UNIVERSAL = \
783         mscorlib.dll \
784         System.Core.dll \
785         System.dll \
786         System.Xml.dll \
787         System.Security.dll \
788         Mono.Simd.dll \
789         Mono.Security.dll \
790         System.Numerics.dll \
791         System.Numerics.Vectors.dll \
792         Mono.Posix.dll \
793         System.Configuration.dll
794
795 FULLAOT_LIBS_DISABLED =
796
797 if FULL_AOT_TESTS
798 # Skip aoting the tests that aren't compiled 
799 # on the full aot profiles because they're skipped
800 # on mobile profiles
801 FULLAOT_LIBS_DISABLED += \
802         Mono.Posix.dll \
803         System.Configuration.dll
804 endif
805
806
807 FULLAOT_LIBS = $(filter-out $(FULLAOT_LIBS_DISABLED),$(FULLAOT_LIBS_UNIVERSAL))
808
809 FULLAOT_TMP_DIR=$(top_builddir)/mono/mini/fullaot-tmp
810
811 # This currently only works on amd64/arm
812 fullaotcheck: $(mono) $(fullaot_regtests) $(fullaot_testing_deps)
813         rm -rf $(FULLAOT_TMP_DIR)
814         mkdir $(FULLAOT_TMP_DIR)
815         $(MAKE) fullaot-libs AOT_FLAGS="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" GSHAREDVT=$(GSHAREDVT)
816         cp $(regtests) $(fullaot_regtests) $(fullaot_testing_deps) $(FULLAOT_TMP_DIR)/
817         MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(LLVM_AOT_RUNTIME_OPTS) $(GSHAREDVT_RUNTIME_OPTS) --aot="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" $(FULLAOT_TMP_DIR)/{*.dll,*.exe} || exit 1
818         ln -s $(if $(MONO_EXECUTABLE),$(MONO_EXECUTABLE),$$PWD/mono) $(FULLAOT_TMP_DIR)/
819         for i in $(fullaot_regtests); do echo $$i; MONO_PATH=$(FULLAOT_TMP_DIR) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) --full-aot $(FULLAOT_TMP_DIR)/$$i --exclude '!FULLAOT' $(ARCH_FULLAOT_EXCLUDE) || exit 1; done
820
821 # This can run in parallel
822 fullaot-libs: $(patsubst %,fullaot-tmp/%.dylib,$(FULLAOT_LIBS))
823
824 fullaot-tmp/%.dylib: $(CLASS)/%
825         cp $(CLASS)/$* fullaot-tmp/
826         mkdir fullaot-tmp/$*-tmp
827         MONO_PATH="fullaot-tmp/$(PLATFORM_PATH_SEPARATOR)$(CLASS)" $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(if $(GSHAREDVT),-O=gsharedvt) --aot=$(AOT_FLAGS),temp-path=fullaot-tmp/$*-tmp fullaot-tmp/$*
828         rm -rf fullaot-tmp/$*-tmp
829
830 llvmfullaotcheck:
831         $(MAKE) fullaotcheck LLVM=1
832
833 llvmonly_regtests = $(fullaot_regtests) gshared.exe
834
835 llvmonlycheck: mono $(llvmonly_regtests)
836         rm -rf fullaot-tmp
837         mkdir fullaot-tmp
838         $(MAKE) fullaot-libs AOT_FLAGS="llvmonly,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)"
839         cp $(llvmonly_regtests) $(fullaot_testing_deps) fullaot-tmp/
840         MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper  $(MOBILE_RUNTIME_ARG) --aot=llvmonly fullaot-tmp/{*.dll,*.exe} || exit 1
841         ln -s $$PWD/mono fullaot-tmp/
842         for i in $(llvmonly_regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) --llvmonly fullaot-tmp/$$i --exclude '!BITCODE' || exit 1; done
843
844 gccheck: gc-test.exe
845         MONO_GC_PARAMS=stack-mark=precise MONO_GC_DEBUG=clear-at-gc ./mono-sgen gc-test.exe     
846
847 bench: mono test.exe
848         time env $(MINI_RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
849
850 mbench: test.exe
851         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
852
853 stat1: mono bench.exe
854         $(MINI_RUNTIME) --verbose --statfile stats.pl --regression bench.exe
855         perl viewstat.pl stats.pl
856
857 stat2: mono basic.exe
858         $(MINI_RUNTIME) --verbose --statfile stats.pl --regression basic.exe
859         perl viewstat.pl -e stats.pl
860
861 stat3: mono bench.exe
862         $(MINI_RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
863         perl viewstat.pl stats.pl
864
865 docu: mini.sgm
866         docbook2txt mini.sgm
867
868 # We need these because automake can't process normal make conditionals
869 check_local_targets = $(if $(EMIT_NUNIT), rcheck-nunit, rcheck)
870
871 check-local: $(check_local_targets)
872
873 clean-local:
874         rm -f mono a.out gmon.out *.o buildver-boehm.h buildver-sgen.h test.exe regressionexitcode.out TestResult-op_il_seq_point.xml*
875
876 pkgconfigdir = $(libdir)/pkgconfig
877
878 BUILT_SOURCES = version.h $(arch_built)
879
880 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
881 EXTRA_DIST = TestDriver.cs \
882         TestHelpers.cs \
883         genmdesc.pl                             \
884         $(test_sources)                         \
885         $(x86_sources) cpu-x86.md               \
886         $(amd64_sources) cpu-amd64.md           \
887         $(ppc_sources) cpu-ppc.md cpu-ppc64.md  \
888         $(arm_sources) cpu-arm.md               \
889         $(arm64_sources) cpu-arm64.md           \
890         $(mips_sources) cpu-mips.md             \
891         $(sparc_sources) cpu-sparc.md           \
892         $(s390x_sources) cpu-s390x.md           \
893         $(windows_sources)                      \
894         $(darwin_sources) Info.plist            \
895         $(posix_sources)                                        \
896         test_op_il_seq_point.sh                 \
897         test_op_il_seq_point_headerfooter.sh    \
898         Makefile.am.in
899
900 version.h: Makefile
901         if test -d $(top_srcdir)/.git; then \
902                 (cd $(top_srcdir); \
903                         LANG=C; export LANG; \
904                         if test -z "$$ghprbPullId"; then \
905                                 branch=`git branch | grep '^\*' | sed 's/(detached from .*/explicit/' | cut -d ' ' -f 2`; \
906                         else \
907                                 branch="pull-request-$$ghprbPullId"; \
908                         fi; \
909                         version=`git log --no-color --first-parent -n1 --pretty=format:%h`; \
910                         echo "#define FULL_VERSION \"$$branch/$$version\""; \
911                 ); \
912         else \
913                 echo "#define FULL_VERSION \"tarball\""; \
914         fi > version.h
915
916 # Utility target for patching libtool to speed up linking
917 patch-libtool:
918         sed -e 's,if (for obj in $$oldobjs,if (for obj in "",g' < ../../libtool > 2; mv 2 ../../libtool
919         chmod a+x ../../libtool
920
921 # Utility target for patching libtool to get rid of the 'ranlib: file <file> has no symbols" warnings
922 patch-osx-libtool:
923         sed -e 's/old_archive_cmds=.*/old_archive_cmds="libtool -no_warning_for_no_symbols -static -o \\$$oldlib \\$$oldobjs"/g' < ../../libtool > 2; mv 2 ../../libtool
924         chmod a+x ../../libtool
925
926 # Utility target to patch automake to generate the same format silent output as the old mono silent build did
927 patch-automake:
928         src="@echo \"  '. \$$name . ' ' x (8 - length (\$$name)) . '\""; dst="@echo \"'. \$$name . ' ' x (7 - length (\$$name)) .'\""; sed -e "s/$$src/$$dst/g" < $$EXE > 2 && cp 2 $$EXE && rm -f 2
929
930 tags:
931         etags -o TAGS `find .. -name "*.h" -o -name "*.c"`
932
933 if HAS_EXTENSION_MODULE
934 else
935 Makefile.am: Makefile.am.in
936         cp $< $@
937 endif