Merge pull request #5714 from alexischr/update_bockbuild
[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 HOST_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 HOST_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 wasm_sources = \
316         mini-wasm.c             \
317         mini-wasm.h             \
318         exceptions-wasm.c       \
319         tramp-wasm.c
320
321 x86_sources = \
322         mini-x86.c              \
323         mini-x86.h              \
324         exceptions-x86.c        \
325         tramp-x86.c     \
326         mini-x86-gsharedvt.c    \
327         tramp-x86-gsharedvt.c
328
329 amd64_sources = \
330         mini-amd64.c            \
331         mini-amd64.h            \
332         exceptions-amd64.c      \
333         tramp-amd64.c   \
334         mini-amd64-gsharedvt.c  \
335         mini-amd64-gsharedvt.h  \
336         tramp-amd64-gsharedvt.c
337
338 ppc_sources = \
339         mini-ppc.c              \
340         mini-ppc.h              \
341         exceptions-ppc.c        \
342         tramp-ppc.c
343
344 arm_sources = \
345         mini-arm.c              \
346         mini-arm.h              \
347         exceptions-arm.c        \
348         tramp-arm.c     \
349         mini-arm-gsharedvt.c    \
350         tramp-arm-gsharedvt.c
351
352 arm64_sources = \
353         mini-arm64.c            \
354         mini-arm64.h            \
355         exceptions-arm64.c      \
356         tramp-arm64.c   \
357         mini-arm64-gsharedvt.c  \
358         mini-arm64-gsharedvt.h  \
359         tramp-arm64-gsharedvt.c
360
361 mips_sources = \
362         mini-mips.c             \
363         mini-mips.h             \
364         exceptions-mips.c       \
365         tramp-mips.c
366
367 sparc_sources = \
368         mini-sparc.c            \
369         mini-sparc.h            \
370         exceptions-sparc.c      \
371         tramp-sparc.c
372
373 s390x_sources = \
374         mini-s390x.c            \
375         mini-s390x.h            \
376         support-s390x.h         \
377         exceptions-s390x.c      \
378         tramp-s390x.c
379
380 darwin_sources = \
381         mini-darwin.c
382
383 windows_sources = \
384         mini-windows.c \
385         mini-windows.h \
386         mini-windows-dllmain.c \
387         mini-windows-dlldac.c
388
389 posix_sources = \
390         mini-posix.c
391
392 if ENABLE_LLVM
393 if LOADED_LLVM
394 llvm_sources = \
395         mini-llvm-loaded.c
396 else
397 llvm_sources = \
398         mini-llvm.c             \
399         mini-llvm-loaded.c \
400         mini-llvm-cpp.cpp \
401         llvm-jit.cpp
402 endif
403 endif
404
405 if ENABLE_INTERPRETER
406 interp_sources =        \
407         interp/hacks.h          \
408         interp/interp.h \
409         interp/interp-internals.h       \
410         interp/interp.c \
411         interp/mintops.h        \
412         interp/mintops.def      \
413         interp/mintops.c        \
414         interp/transform.c
415 else
416 interp_sources = \
417         interp/interp-stubs.c
418 endif
419
420 if ENABLE_LLVM
421 llvm_runtime_sources = \
422         llvm-runtime.cpp
423 else
424 if ENABLE_LLVM_RUNTIME
425 llvm_runtime_sources = \
426         llvm-runtime.cpp
427 endif
428 endif
429
430 common_sources = \
431         mini.c                  \
432         mini-runtime.c  \
433         seq-points.c    \
434         seq-points.h    \
435         ir-emit.h               \
436         method-to-ir.c          \
437         cfgdump.h               \
438         cfgdump.c               \
439         decompose.c             \
440         mini.h                  \
441         version.h               \
442         optflags-def.h          \
443         jit-icalls.h            \
444         jit-icalls.c            \
445         trace.c                 \
446         trace.h                 \
447         patch-info.h            \
448         mini-ops.h              \
449         mini-arch.h             \
450         dominators.c            \
451         cfold.c                 \
452         regalloc.h              \
453         helpers.c               \
454         liveness.c              \
455         ssa.c                   \
456         abcremoval.c            \
457         abcremoval.h            \
458         local-propagation.c     \
459         driver.c                \
460         debug-mini.c            \
461         linear-scan.c           \
462         aot-compiler.h          \
463         aot-compiler.c          \
464         aot-runtime.c           \
465         aot-runtime-wasm.c      \
466         graph.c                 \
467         mini-codegen.c          \
468         mini-exceptions.c       \
469         mini-trampolines.c      \
470         branch-opts.c           \
471         mini-generic-sharing.c  \
472         simd-methods.h          \
473         tasklets.c              \
474         tasklets.h              \
475         simd-intrinsics.c       \
476         mini-native-types.c \
477         mini-unwind.h           \
478         unwind.c                \
479         image-writer.h          \
480         image-writer.c          \
481         dwarfwriter.h           \
482         dwarfwriter.c           \
483         mini-gc.h               \
484         mini-gc.c               \
485         debugger-agent.h        \
486         debugger-agent.c        \
487         xdebug.c                        \
488         mini-llvm.h                     \
489         mini-llvm-cpp.h \
490         llvm-jit.h              \
491         alias-analysis.c        \
492         mini-cross-helpers.c \
493         arch-stubs.c            \
494         llvm-runtime.h  \
495         type-checking.c \
496         lldb.h                  \
497         lldb.c  \
498         memory-access.c \
499         mini-profiler.c
500
501 test_sources =                  \
502         basic-calls.cs          \
503         basic-long.cs           \
504         bench.cs                \
505         builtin-types.cs        \
506         objects.cs              \
507         arrays.cs               \
508         basic-float.cs          \
509         basic-math.cs           \
510         basic.cs                \
511         exceptions.cs           \
512         devirtualization.cs     \
513         iltests.il              \
514         test.cs                 \
515         generics.cs             \
516         generics-variant-types.il\
517         basic-simd.cs \
518         basic-vectors.cs \
519         aot-tests.cs \
520         gc-test.cs \
521         gshared.cs \
522         unaligned.cs    \
523         MemoryIntrinsics.il     \
524         mixed.cs
525
526 regtests_UNIVERSAL = \
527         basic.exe \
528         basic-float.exe \
529         basic-long.exe \
530         basic-calls.exe \
531         builtin-types.exe \
532         objects.exe \
533         arrays.exe \
534         basic-math.exe \
535         exceptions.exe \
536         iltests.exe \
537         devirtualization.exe \
538         generics.exe \
539         basic-simd.exe \
540         unaligned.exe   \
541         basic-vectors.exe
542
543 regtests_DISABLED = 
544
545 if FULL_AOT_TESTS
546 regtests_DISABLED += builtin-types.exe
547 endif
548
549 regtests = $(filter-out $(regtests_DISABLED),$(regtests_UNIVERSAL))
550
551 if WASM
552 arch_sources = $(wasm_sources)
553 arch_built=cpu-wasm.h
554 arch_define=__wasm__
555 endif
556
557 if X86
558 arch_sources = $(x86_sources)
559 arch_built=cpu-x86.h
560 arch_define=__i386__
561 endif
562
563 if AMD64
564 arch_sources = $(amd64_sources)
565 arch_built=cpu-amd64.h
566 arch_define=__x86_64__
567 ARCH_FULLAOT_EXCLUDE=
568 endif
569
570 if POWERPC
571 arch_sources = $(ppc_sources)
572 arch_built=cpu-ppc.h
573 arch_define=__ppc__
574 endif
575
576 if POWERPC64
577 arch_sources = $(ppc_sources)
578 arch_built=cpu-ppc64.h
579 arch_define=__ppc64__
580 endif
581
582 if MIPS
583 arch_sources = $(mips_sources)
584 arch_built=cpu-mips.h
585 arch_define=__mips__
586 endif
587
588 if ARM
589 # pick up arm_dpimacros.h
590 ARCH_CFLAGS = -I../arch/arm
591 arch_sources = $(arm_sources)
592 arch_built=cpu-arm.h
593 arch_define=__arm__
594 endif
595
596 if ARM64
597 arch_sources = $(arm64_sources)
598 arch_built=cpu-arm64.h
599 arch_define=__aarch64__
600 endif
601
602 if SPARC
603 arch_sources = $(sparc_sources)
604 arch_built=cpu-sparc.h
605 arch_define=__sparc__
606 endif
607
608 if SPARC64
609 arch_sources = $(sparc_sources)
610 arch_built=cpu-sparc.h
611 arch_define=__sparc__
612 endif
613
614 if S390X
615 arch_sources = $(s390x_sources)
616 arch_built=cpu-s390x.h
617 arch_define=__s390__
618 endif
619
620 if HOST_WIN32
621 os_sources = $(windows_sources)
622 monobin_platform_ldflags=
623 endif
624
625 if HOST_SIGPOSIX
626 os_sources = $(posix_sources)
627 monobin_platform_ldflags=
628 endif
629
630 if HOST_DARWIN
631 os_sources = $(darwin_sources) $(posix_sources)
632 #monobin_platform_ldflags=-sectcreate __TEXT __info_plist $(top_srcdir)/mono/mini/Info.plist -framework CoreFoundation -framework Foundation
633 monobin_platform_ldflags=-framework CoreFoundation -framework Foundation
634 endif
635
636 libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(interp_sources) $(arch_sources) $(os_sources)
637 libmini_la_CFLAGS = $(mono_CFLAGS)
638
639 libmonoboehm_2_0_la_SOURCES =
640 libmonoboehm_2_0_la_CFLAGS = $(mono_boehm_CFLAGS)
641 libmonoboehm_2_0_la_LIBADD = libmini.la $(boehm_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
642 libmonoboehm_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags)
643
644 libmonosgen_2_0_la_SOURCES =
645 libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS)
646 libmonosgen_2_0_la_LIBADD = libmini.la $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
647 libmonosgen_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags)
648
649 #
650 # This library is shared between mono and mono-sgen, since the code in mini/ doesn't contain
651 # compile time dependencies on boehm/sgen.
652 #
653 libmini_static_la_SOURCES = $(libmini_la_SOURCES)
654 libmini_static_la_CFLAGS = $(AM_CFLAGS)
655 libmini_static_la_LDFLAGS = -static
656 libmini_static_la_LIBADD = $(MONO_DTRACE_OBJECT)
657
658 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
659
660 libmonoinclude_HEADERS = jit.h
661
662 CSFLAGS = -unsafe -nowarn:0219,0169,0414,0649,0618
663
664 basic-simd.exe: basic-simd.cs TestDriver.dll
665         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/Mono.Simd.dll
666
667 basic-vectors.exe: basic-vectors.cs TestDriver.dll
668         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/System.Numerics.dll -r:$(CLASS)/System.Numerics.Vectors.dll
669
670 builtin-types.exe: builtin-types.cs TestDriver.dll
671         $(MCS) -out:$@ $(CSFLAGS) -define:ARCH_$(shell echo $$((8 * $(SIZEOF_VOID_P)))) $< -r:TestDriver.dll
672
673 nacl.exe: nacl.cs TestDriver.dll
674         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/Mono.Simd.dll
675
676 generics.exe: generics.cs TestDriver.dll generics-variant-types.dll
677         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:generics-variant-types.dll -r:$(CLASS)/System.Core.dll
678
679 unaligned.exe: unaligned.cs TestDriver.dll MemoryIntrinsics.dll
680         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:MemoryIntrinsics.dll
681
682 %.exe: %.cs TestDriver.dll
683         $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll
684
685 %.exe: %.il
686         $(ILASM) -output=$@ $<
687
688 TestDriver.dll: $(srcdir)/TestDriver.cs $(srcdir)/TestHelpers.cs
689         $(MCS) -out:$@ -target:library $^
690
691 generics-variant-types.dll: generics-variant-types.il
692         $(ILASM) -dll -output=$@ $<
693
694 MemoryIntrinsics.dll: MemoryIntrinsics.il
695         $(ILASM) -dll -output=$@ $<
696
697 GENMDESC_OPTS=
698
699 # we don't always use the perl impl because it's an additional
700 # build dependency for the poor windows users
701 # $(arch_define) is the preprocessor symbol that enables all the opcodes
702 # for the specific platform in mini-ops.h
703
704 if CROSS_COMPILING
705 GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
706 else
707 if WASM
708 GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
709 else
710 GENMDESC_PRG=./genmdesc $(GENMDESC_OPTS)
711 endif
712 endif !CROSS_COMPILING
713
714 cpu-wasm.h: cpu-wasm.md genmdesc$(EXEEXT)
715         $(GENMDESC_PRG) cpu-wasm.h wasm_desc $(srcdir)/cpu-wasm.md
716
717 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
718         $(GENMDESC_PRG) cpu-x86.h x86_desc $(srcdir)/cpu-x86.md
719
720 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
721         $(GENMDESC_PRG) cpu-amd64.h amd64_desc $(srcdir)/cpu-amd64.md
722
723 cpu-ppc.h: cpu-ppc.md genmdesc$(EXEEXT)
724         $(GENMDESC_PRG) cpu-ppc.h ppcg4 $(srcdir)/cpu-ppc.md
725
726 cpu-ppc64.h: cpu-ppc64.md genmdesc$(EXEEXT)
727         $(GENMDESC_PRG) cpu-ppc64.h ppc64_cpu_desc $(srcdir)/cpu-ppc64.md
728
729 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
730         $(GENMDESC_PRG) cpu-arm.h arm_cpu_desc $(srcdir)/cpu-arm.md
731
732 cpu-arm64.h: cpu-arm64.md genmdesc$(EXEEXT)
733         $(GENMDESC_PRG) cpu-arm64.h arm64_cpu_desc $(srcdir)/cpu-arm64.md
734
735 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
736         $(GENMDESC_PRG) cpu-sparc.h sparc_desc $(srcdir)/cpu-sparc.md
737
738 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
739         $(GENMDESC_PRG) cpu-s390x.h s390x_cpu_desc $(srcdir)/cpu-s390x.md
740
741 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
742         $(GENMDESC_PRG) cpu-mips.h mips_desc $(srcdir)/cpu-mips.md
743
744 testi: mono test.exe
745         $(MINI_RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
746
747 # ensure the tests are actually correct
748 checktests: $(regtests)
749         for i in $(regtests); do $(MINI_RUNTIME) $$i; done
750
751 rcheck-nunit: mono $(regtests)
752         $(MINI_RUNTIME) --regression $(regtests) > regressiontests.out 2>&1; cat regressiontests.out; \
753         if grep -q "100% pass" regressiontests.out; then successbool=True; failurescount=0; else successbool=False; failurescount=1; fi; \
754         echo "<?xml version='1.0' encoding='utf-8'?>\
755                 <test-results failures='$$failurescount' total='1' not-run='0' name='regression-tests.dummy' date='$$(date +%F)' time='$$(date +%T)'>\
756                         <test-suite name='regression-tests.dummy' success='$$successbool' time='0'>\
757                                 <results><test-case name='MonoTests.regressions.100percentsuccess' executed='True' success='$$successbool' time='0'>" > TestResult-regression.xml; \
758                                         if [ "$$successbool" = "False" ]; then echo "<failure><message><![CDATA[$$(cat regressiontests.out)]]></message><stack-trace></stack-trace></failure>" >> TestResult-regression.xml; fi; \
759                                 echo "</test-case></results>\
760                         </test-suite>\
761                 </test-results>" >> TestResult-regression.xml; exit $$failurescount
762
763 rcheck: mono $(regtests)
764         $(MINI_RUNTIME) --regression $(regtests)
765
766 richeck: mono $(regtests)
767         $(INTERP_RUNTIME) --regression $(regtests)
768
769 mixedcheck: mono mixed.exe
770         $(MINI_RUNTIME) --interp=jit=JitClass mixed.exe
771
772 if ARM
773 check-seq-points:
774 else
775 check-seq-points: mono $(regtests)
776         rm -f TestResult-op_il_seq_point.xml
777         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
778         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
779         $(srcdir)/test_op_il_seq_point_headerfooter.sh
780 endif
781
782 gctest: mono gc-test.exe
783         MONO_DEBUG_OPTIONS=clear-nursery-at-gc $(MINI_RUNTIME) --regression gc-test.exe
784
785 LLVM_AOT_RUNTIME_OPTS=$(if $(LLVM),--llvm,)
786 GSHAREDVT_RUNTIME_OPTS=$(if $(GSHAREDVT),-O=gsharedvt,)
787
788 aotcheck: mono $(regtests)
789         rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
790         $(MINI_RUNTIME) $(LLVM_AOT_RUNTIME_OPTS) --aot $(regtests) || exit 1
791         for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
792         rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
793
794 llvmaotcheck:
795         $(MAKE) aotcheck LLVM=1
796
797 gsharedvtcheck:
798         $(MAKE) fullaotcheck GSHAREDVT=1
799
800 fullaot_regtests = $(regtests) aot-tests.exe $(if $(GSHAREDVT),gshared.exe)
801 fullaot_testing_deps = generics-variant-types.dll TestDriver.dll MemoryIntrinsics.dll
802
803 FULLAOT_LIBS_UNIVERSAL = \
804         mscorlib.dll \
805         System.Core.dll \
806         System.dll \
807         System.Xml.dll \
808         System.Security.dll \
809         Mono.Simd.dll \
810         Mono.Security.dll \
811         System.Numerics.dll \
812         System.Numerics.Vectors.dll \
813         Mono.Posix.dll \
814         System.Configuration.dll
815
816 FULLAOT_LIBS_DISABLED =
817
818 if FULL_AOT_TESTS
819 # Skip aoting the tests that aren't compiled 
820 # on the full aot profiles because they're skipped
821 # on mobile profiles
822 FULLAOT_LIBS_DISABLED += \
823         Mono.Posix.dll \
824         System.Configuration.dll
825 endif
826
827
828 FULLAOT_LIBS = $(filter-out $(FULLAOT_LIBS_DISABLED),$(FULLAOT_LIBS_UNIVERSAL))
829
830 FULLAOT_TMP_DIR=$(top_builddir)/mono/mini/fullaot-tmp
831
832 # This currently only works on amd64/arm
833 fullaotcheck: $(mono) $(fullaot_regtests) $(fullaot_testing_deps)
834         rm -rf $(FULLAOT_TMP_DIR)
835         mkdir $(FULLAOT_TMP_DIR)
836         $(MAKE) fullaot-libs AOT_FLAGS="full,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)" GSHAREDVT=$(GSHAREDVT)
837         cp $(regtests) $(fullaot_regtests) $(fullaot_testing_deps) $(FULLAOT_TMP_DIR)/
838         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
839         ln -s $(if $(MONO_EXECUTABLE),$(MONO_EXECUTABLE),$$PWD/mono) $(FULLAOT_TMP_DIR)/
840         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
841
842 # This can run in parallel
843 fullaot-libs: $(patsubst %,fullaot-tmp/%.dylib,$(FULLAOT_LIBS))
844
845 fullaot-tmp/%.dylib: $(CLASS)/%
846         cp $(CLASS)/$* fullaot-tmp/
847         mkdir fullaot-tmp/$*-tmp
848         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/$*
849         rm -rf fullaot-tmp/$*-tmp
850
851 llvmfullaotcheck:
852         $(MAKE) fullaotcheck LLVM=1
853
854 llvmonly_regtests = $(fullaot_regtests) gshared.exe
855
856 llvmonlycheck: mono $(llvmonly_regtests)
857         rm -rf fullaot-tmp
858         mkdir fullaot-tmp
859         $(MAKE) fullaot-libs AOT_FLAGS="llvmonly,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)"
860         cp $(llvmonly_regtests) $(fullaot_testing_deps) fullaot-tmp/
861         MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper  $(MOBILE_RUNTIME_ARG) --aot=llvmonly fullaot-tmp/{*.dll,*.exe} || exit 1
862         ln -s $$PWD/mono fullaot-tmp/
863         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
864
865 gccheck: gc-test.exe
866         MONO_GC_PARAMS=stack-mark=precise MONO_GC_DEBUG=clear-at-gc ./mono-sgen gc-test.exe     
867
868 bench: mono test.exe
869         time env $(MINI_RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
870
871 mbench: test.exe
872         time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
873
874 stat1: mono bench.exe
875         $(MINI_RUNTIME) --verbose --statfile stats.pl --regression bench.exe
876         perl viewstat.pl stats.pl
877
878 stat2: mono basic.exe
879         $(MINI_RUNTIME) --verbose --statfile stats.pl --regression basic.exe
880         perl viewstat.pl -e stats.pl
881
882 stat3: mono bench.exe
883         $(MINI_RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
884         perl viewstat.pl stats.pl
885
886 docu: mini.sgm
887         docbook2txt mini.sgm
888
889 # We need these because automake can't process normal make conditionals
890 check_local_targets = $(if $(EMIT_NUNIT), rcheck-nunit, rcheck)
891
892 check-local: $(check_local_targets)
893
894 clean-local:
895         rm -f mono a.out gmon.out *.o buildver-boehm.h buildver-sgen.h test.exe regressionexitcode.out TestResult-op_il_seq_point.xml*
896
897 pkgconfigdir = $(libdir)/pkgconfig
898
899 BUILT_SOURCES = version.h $(arch_built)
900
901 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
902 EXTRA_DIST = TestDriver.cs \
903         TestHelpers.cs \
904         genmdesc.pl                             \
905         $(test_sources)                         \
906         $(wasm_sources) cpu-wasm.md             \
907         $(x86_sources) cpu-x86.md               \
908         $(amd64_sources) cpu-amd64.md           \
909         $(ppc_sources) cpu-ppc.md cpu-ppc64.md  \
910         $(arm_sources) cpu-arm.md               \
911         $(arm64_sources) cpu-arm64.md           \
912         $(mips_sources) cpu-mips.md             \
913         $(sparc_sources) cpu-sparc.md           \
914         $(s390x_sources) cpu-s390x.md           \
915         $(windows_sources)                      \
916         $(darwin_sources) Info.plist            \
917         $(posix_sources)                                        \
918         test_op_il_seq_point.sh                 \
919         test_op_il_seq_point_headerfooter.sh    \
920         Makefile.am.in
921
922 version.h: Makefile
923         if test -d $(top_srcdir)/.git; then \
924                 (cd $(top_srcdir); \
925                         LANG=C; export LANG; \
926                         if test -z "$$ghprbPullId"; then \
927                                 branch=`git branch | grep '^\*' | sed 's/(detached from .*/explicit/' | cut -d ' ' -f 2`; \
928                         else \
929                                 branch="pull-request-$$ghprbPullId"; \
930                         fi; \
931                         version=`git log --no-color --first-parent -n1 --pretty=format:%h`; \
932                         echo "#define FULL_VERSION \"$$branch/$$version\""; \
933                 ); \
934         else \
935                 echo "#define FULL_VERSION \"tarball\""; \
936         fi > version.h
937
938 # Utility target for patching libtool to speed up linking
939 patch-libtool:
940         sed -e 's,if (for obj in $$oldobjs,if (for obj in "",g' < ../../libtool > 2; mv 2 ../../libtool
941         chmod a+x ../../libtool
942
943 # Utility target for patching libtool to get rid of the 'ranlib: file <file> has no symbols" warnings
944 patch-osx-libtool:
945         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
946         chmod a+x ../../libtool
947
948 # Utility target to patch automake to generate the same format silent output as the old mono silent build did
949 patch-automake:
950         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
951
952 tags:
953         etags -o TAGS `find .. -name "*.h" -o -name "*.c"`
954
955 if HAS_EXTENSION_MODULE
956 else
957 Makefile.am: Makefile.am.in
958         cp $< $@
959 endif