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