Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Makefile.am.in « mini « mono - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 20765e4228d36d2ebb00bd074962df626ab6fee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
MAKEFLAGS := $(MAKEFLAGS) --no-builtin-rules

## Set the C++ linker based on configure settings, see comment in configure.ac
## about why we need to do this.
CXXLD=$(MONO_CXXLD)
CCLD=$(MONO_CXXLD)

count=100000
mtest=for_loop
monodir=$(top_builddir)
mono=$(if $(MONO_EXECUTABLE),$(MONO_EXECUTABLE),mono)

if HOST_WIN32
PLATFORM_PATH_SEPARATOR=;
else
PLATFORM_PATH_SEPARATOR=:
endif

if !ENABLE_MSVC_ONLY

# This is needed for automake dependency generation
if SUPPORT_NULLGC
libgc_libs=
libgc_static_libs=
else
libgc_libs=$(monodir)/external/bdwgc/libgc.la
libgc_static_libs=$(monodir)/external/bdwgc/libgc-static.la
endif

glib_libs = $(monodir)/mono/eglib/libeglib.la

boehm_libs=	\
	$(monodir)/mono/metadata/libmonoruntime.la	\
	$(monodir)/mono/utils/libmonoutils.la \
	$(glib_libs) \
	$(libgc_libs)

sgen_libs = \
	$(monodir)/mono/metadata/libmonoruntimesgen.la	\
	$(monodir)/mono/sgen/libmonosgen.la	\
	$(monodir)/mono/utils/libmonoutils.la \
	$(glib_libs)

if ENABLE_LLVM

include $(mono_build_root)/llvm/llvm_config.mk
LLVM_CFLAGS=$(LLVM_CFLAGS_INTERNAL) $(LLVM_CFLAGS_EXTERNAL)
LLVM_CXXFLAGS=$(LLVM_CXXFLAGS_INTERNAL) $(LLVM_CXXFLAGS_EXTERNAL)
LLVM_LDFLAGS=$(LLVM_LDFLAGS_INTERNAL) $(LLVM_LDFLAGS_EXTERNAL)
LLVM_LIBS=$(LLVM_LIBS_INTERNAL) $(LLVM_LIBS_EXTERNAL)

$(mono_build_root)/llvm/llvm_config.mk:
	$(MAKE) -C $(top_builddir)/llvm $(mono_build_root)/llvm/llvm_config.mk

endif

endif # !ENABLE_MSVC_ONLY

if FULL_AOT_TESTS
# if the tests are going to run with framework assemblies compiled with
# -d:MOBILE, tell the runtime to remap framework assemblies using the mobile
# runtime info
MOBILE_RUNTIME_ARG=--runtime=mobile
else
MOBILE_RUNTIME_ARG=
endif

CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)

RUNTIME_EXECUTABLE = $(if $(BOEHM),$(top_builddir)/mono/mini/mono-boehm,$(top_builddir)/runtime/mono-wrapper)

MINI_RUNTIME = MONO_PATH=$(CLASS) $(RUNTIME_EXECUTABLE) $(MOBILE_RUNTIME_ARG)
TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(top_builddir)/runtime/mono-wrapper
INTERP_RUNTIME = $(MINI_RUNTIME) --interpreter
RUNTIME_AOTCHECK = MONO_PATH="$(CLASS)$(PLATFORM_PATH_SEPARATOR)." $(RUNTIME_EXECUTABLE)

MCS = CSC_SDK_PATH_DISABLED= $(TOOLS_RUNTIME) $(CSC) -langversion:8.0 -nostdlib -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll -r:$(CLASS)/System.Core.dll
ILASM = $(TOOLS_RUNTIME) $(mcs_topdir)/class/lib/build/ilasm.exe

if !ENABLE_MSVC_ONLY

AM_CFLAGS = \
	-I$(top_srcdir) 	\
	$(GLIB_CFLAGS)		\
	$(LLVM_CFLAGS)		\
	$(JEMALLOC_CFLAGS)	\
	$(PLATFORM_CFLAGS) $(ARCH_CFLAGS) $(SHARED_CFLAGS)

AM_CXXFLAGS = -I$(top_srcdir) $(LLVM_CXXFLAGS) $(GLIB_CFLAGS)

if HOST_WIN32
export HOST_CC
# The mingw math.h has "extern inline" functions that dont appear in libs, so
# optimisation is required to actually inline them
PLATFORM_CFLAGS = -O
endif

monoldflags=$(export_ldflags)
monobinldflags=$(export_ldflags) $(extra_runtime_ldflags)

if HOST_WIN32
libmonoldflags=-no-undefined -avoid-version -Wl,--kill-at $(monoldflags)
else
if HOST_ANDROID
libmonoldflags= -avoid-version $(monoldflags)
else
libmonoldflags=$(monoldflags) -version-info 1:0:0
endif
endif

if SUPPORT_SGEN
sgen_binaries = mono-sgen
sgen_libraries = libmonosgen-2.0.la
sgen_static_libraries = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(sgen_libs)
endif

if SUPPORT_BOEHM
boehm_libraries = libmonoboehm-2.0.la
boehm_static_libraries = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(boehm_libs)
boehm_binaries  = mono-boehm
endif

endif # !ENABLE_MSVC_ONLY

if SUPPORT_SGEN
mono_bin_suffix = sgen
libmono_suffix = sgen
else
mono_bin_suffix = boehm
libmono_suffix = boehm
endif

if DISABLE_EXECUTABLES
else
if !ENABLE_MSVC_ONLY
mono: mono-$(mono_bin_suffix)
	ln -sf $< $@

mono.exe: mono-$(mono_bin_suffix).exe
	ln -sf $< $@
else # !ENABLE_MSVC_ONLY
.PHONY: mono
mono:
	make -C $(top_srcdir)/msvc mono
	ln -sf $(mono_msvc_build_bin_dir)/mono-$(mono_bin_suffix)$(EXEEXT) ./mono.exe
if SUPPORT_SGEN
	ln -sf $(mono_msvc_build_bin_dir)/mono-$(mono_bin_suffix)$(EXEEXT) ./mono-sgen.exe
endif

mono.exe: mono

monow.exe: mono

all-local: mono

clean-mono:
	make -C $(top_srcdir)/msvc clean-mono

endif # !ENABLE_MSVC_ONLY

install-exec-hook:
	(cd $(DESTDIR)$(bindir) && ln -sf mono-$(mono_bin_suffix)$(EXEEXT) mono$(EXEEXT))
	(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)
endif

if !ENABLE_MSVC_ONLY

if DISABLE_EXECUTABLES
else
if HOST_WIN32
bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) monow
else
bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries)
endif
endif

if DISABLE_EXECUTABLES
noinst_PROGRAMS =
else
noinst_PROGRAMS = mono
endif

if DISABLE_EXECUTABLES
shared_libraries = $(boehm_libraries) $(sgen_libraries)
else
if SHARED_MONO
shared_libraries = $(boehm_libraries) $(sgen_libraries)
endif
endif

lib_LTLIBRARIES = $(shared_libraries)

if DISABLE_INTERPRETER
lib_LTLIBRARIES += $(interp_libs)
endif

if SHARED_MONO
mini_common_lib = libmini.la
else
mini_common_lib = 
endif

noinst_LTLIBRARIES = $(mini_common_lib)

noinst_LIBRARIES = libmain.a

libmain_a_SOURCES = main-sgen.c
if SUPPORT_BOEHM
libmain_a_SOURCES += main.c
endif
libmain_a_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@

# we need this to prevent automake from generating a default mono_SOURCES = mono.c
mono_SOURCES =

mono_boehm_SOURCES =
mono_boehm_CFLAGS = $(AM_CFLAGS) @CXX_REMOVE_CFLAGS@

AM_CPPFLAGS = $(LIBGC_CPPFLAGS)

mono_sgen_SOURCES =
mono_sgen_CFLAGS = $(AM_CFLAGS) @CXX_REMOVE_CFLAGS@

BUILD_DATE = $(shell SOURCE_DATE_EPOCH="$${SOURCE_DATE_EPOCH:-$$(date +%s)}" ;date -u -d "@$$SOURCE_DATE_EPOCH" 2>/dev/null || date -u -r "$$SOURCE_DATE_EPOCH" 2>/dev/null || date -u)

# We build this after libmono was built so it contains the date when the final
# link was done
if SUPPORT_BOEHM
buildver-boehm.h: libmini.la $(monodir)/mono/metadata/libmonoruntime.la
	@echo "const char *build_date = \"$(BUILD_DATE)\";" > buildver-boehm.h
libmain_a-main.$(OBJEXT): buildver-boehm.h
endif

buildver-sgen.h: libmini.la $(monodir)/mono/metadata/libmonoruntimesgen.la $(monodir)/mono/sgen/libmonosgen.la
	@echo "const char *build_date = \"$(BUILD_DATE)\";" > buildver-sgen.h

libmain_a-main-sgen.$(OBJEXT): buildver-sgen.h

if DTRACE_G_REQUIRED
LIBMONO_DTRACE_OBJECT = .libs/mono-dtrace.$(OBJEXT)
if STATIC_MONO
MONO_DTRACE_OBJECT = mono-dtrace.$(OBJEXT)
else
MONO_DTRACE_OBJECT = 
endif
else
MONO_DTRACE_OBJECT = 
LIBMONO_DTRACE_OBJECT = 
endif

if STATIC_MONO
# Link libmono into mono statically
# This leads to higher performance, especially with TLS
MONO_LIB=$(boehm_static_libraries)
MONO_SGEN_LIB=$(sgen_static_libraries)
else 
MONO_LIB=libmonoboehm-2.0.la
MONO_SGEN_LIB=libmonosgen-2.0.la
endif

LLVMMONOF=$(LLVM_LIBS) $(LLVM_LDFLAGS)

mono_boehm_LDADD = \
	libmain_a-main.$(OBJEXT) \
	$(MONO_LIB)		\
	$(glib_libs)		\
	$(LLVMMONOF)		\
	$(LIBICONV)		\
	$(Z_LIBS)		\
	-lm			\
	$(MONO_DTRACE_OBJECT)

mono_boehm_LDFLAGS = \
	$(static_flags) $(monobinldflags) $(monobin_platform_ldflags) 

mono_sgen_LDADD = \
	libmain_a-main-sgen.$(OBJEXT) \
	$(MONO_SGEN_LIB)	\
	$(glib_libs)		\
	$(LLVMMONOF)		\
	$(LIBICONV)		\
	$(Z_LIBS)		\
	-lm			\
	$(MONO_DTRACE_OBJECT)


mono_sgen_LDFLAGS = $(static_flags) $(monobinldflags) $(monobin_platform_ldflags)

if ENABLE_STATIC_GCC_LIBS
mono_sgen_LDFLAGS += -all-static
endif

if BITCODE
libmonoldflags += -no-undefined
endif

# if SUPPORT_SGEN
# 
# mono_LDADD = $(mono_sgen_LDADD)
# mono_LDFLAGS = $(mono_sgen_LDFLAGS)
# 
# endif


if DTRACE_G_REQUIRED

mono-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d mini.lo $(monodir)/mono/metadata/libmonoruntime-static.la
	DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
	$@ $(top_srcdir)/data/mono.d $(monodir)/mono/metadata/libmonoruntime-static.la mini.lo

.libs/mono-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d mini.lo $(monodir)/mono/metadata/libmonoruntime.la
	DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
	--pic $@ $(top_srcdir)/data/mono.d $(monodir)/mono/metadata/libmonoruntime.la mini.lo

endif

# Create monow.exe, linked for the 'windows' subsystem
if HOST_WIN32
if SUPPORT_BOEHM
monow_LDADD = $(mono_boehm_LDADD)
monow_LDFLAGS = $(mono_boehm_LDFLAGS) -mwindows
monow_SOURCES = $(mono_boehm_SOURCES)
else
monow_LDADD = $(mono_sgen_LDADD)
monow_LDFLAGS = $(mono_sgen_LDFLAGS) -mwindows
monow_SOURCES = $(mono_sgen_SOURCES)
endif
endif

wasm_sources = \
	mini-wasm.c		\
	mini-wasm.h		\
	mini-wasm-debugger.c	\
	debugger-engine.c	\
	exceptions-wasm.c	\
	tramp-wasm.c

x86_sources = \
	mini-x86.c		\
	mini-x86.h		\
	exceptions-x86.c	\
	tramp-x86.c	\
	mini-x86-gsharedvt.c	\
	tramp-x86-gsharedvt.c

amd64_sources = \
	mini-amd64.c		\
	mini-amd64.h		\
	exceptions-amd64.c	\
	tramp-amd64.c	\
	mini-amd64-gsharedvt.c	\
	mini-amd64-gsharedvt.h	\
	tramp-amd64-gsharedvt.c

ppc_sources = \
	mini-ppc.c		\
	mini-ppc.h		\
	exceptions-ppc.c	\
	tramp-ppc.c

arm_sources = \
	mini-arm.c		\
	mini-arm.h		\
	exceptions-arm.c	\
	tramp-arm.c	\
	mini-arm-gsharedvt.c	\
	tramp-arm-gsharedvt.c

arm64_sources = \
	mini-arm64.c		\
	mini-arm64.h		\
	exceptions-arm64.c	\
	tramp-arm64.c	\
	mini-arm64-gsharedvt.c	\
	mini-arm64-gsharedvt.h	\
	tramp-arm64-gsharedvt.c

mips_sources = \
	mini-mips.c		\
	mini-mips.h		\
	exceptions-mips.c	\
	tramp-mips.c

sparc_sources = \
	mini-sparc.c		\
	mini-sparc.h		\
	exceptions-sparc.c	\
	tramp-sparc.c

s390x_sources = \
	mini-s390x.c		\
	mini-s390x.h		\
	exceptions-s390x.c	\
	tramp-s390x.c

riscv_sources = \
	mini-riscv.c \
	mini-riscv.h \
	exceptions-riscv.c \
	tramp-riscv.c

darwin_sources = \
	mini-darwin.c

windows_sources = \
	mini-windows.c \
	mini-windows-tls-callback.c \
	mini-windows.h \
	mini-windows-dllmain.c \
	mini-windows-dlldac.c

posix_sources = \
	mini-posix.c

if ENABLE_LLVM
llvm_sources = \
	mini-llvm.c		\
	mini-llvm-cpp.cpp \
	llvm-jit.cpp
endif

interp_sources =	\
	interp/interp.h	\
	interp/interp-internals.h	\
	interp/interp.c	\
	interp/interp-intrins.h	\
	interp/interp-intrins.c	\
	interp/mintops.h	\
	interp/mintops.def	\
	interp/mintops.c	\
	interp/transform.h	\
	interp/transform.c

interp_libs = libmono-ee-interp.la

if !DISABLE_INTERPRETER
interp_libs_with_mini = $(interp_libs)
endif

if ENABLE_LLVM
llvm_runtime_sources = \
	llvm-runtime.cpp
else
if ENABLE_LLVM_RUNTIME
llvm_runtime_sources = \
	llvm-runtime.cpp
endif
endif

common_sources = \
	mini.c			\
	mini-runtime.c	\
	seq-points.c	\
	seq-points.h	\
	ir-emit.h		\
	method-to-ir.c		\
	cfgdump.h		\
	cfgdump.c		\
	decompose.c		\
	mini.h			\
	version.h		\
	optflags-def.h		\
	jit-icalls.h 		\
	jit-icalls.c 		\
	trace.c			\
	trace.h			\
	patch-info.h		\
	mini-ops.h		\
	mini-arch.h		\
	dominators.c		\
	cfold.c			\
	regalloc.h		\
	helpers.c		\
	liveness.c		\
	ssa.c			\
	abcremoval.c		\
	abcremoval.h		\
	local-propagation.c	\
	driver.c		\
	debug-mini.c		\
	linear-scan.c		\
	aot-compiler.h		\
	aot-compiler.c		\
	aot-runtime.c		\
	aot-runtime-wasm.c	\
	wasm_m2n_invoke.g.h	\
	graph.c			\
	mini-codegen.c		\
	mini-exceptions.c	\
	mini-trampolines.c  	\
	branch-opts.c		\
	mini-generic-sharing.c	\
	simd-methods.h		\
	tasklets.c		\
	tasklets.h		\
	simd-intrinsics.c	\
	mini-native-types.c \
	mini-unwind.h		\
	unwind.c		\
	image-writer.h		\
	image-writer.c		\
	dwarfwriter.h		\
	dwarfwriter.c		\
	mini-gc.h		\
	mini-gc.c		\
	debugger-agent.h 	\
	debugger-engine.h	\
	debugger-agent-stubs.c	\
	debugger-state-machine.h	\
	xdebug.c			\
	mini-llvm.h			\
	mini-llvm-cpp.h	\
	llvm-jit.h		\
	alias-analysis.c	\
	mini-cross-helpers.c \
	arch-stubs.c		\
	llvm-runtime.h	\
	llvm-intrinsics.h	\
	type-checking.c \
	calls.c			\
	lldb.h			\
	lldb.c	\
	memory-access.c	\
	intrinsics.c \
	mini-profiler.c	\
	interp-stubs.c \
	llvmonly-runtime.h \
	llvmonly-runtime.c \
	aot-runtime.h	\
	ee.h \
	tiered.h \
	tiered.c \
	mini-runtime.h \
	monovm.h \
	monovm.c

endif # !ENABLE_MSVC_ONLY

# keep in sync with mcs/class/Mono.Runtime.Tests
test_sources = 			\
	basic-calls.cs 		\
	basic-long.cs 		\
	bench.cs 		\
	builtin-types.cs 	\
	objects.cs 		\
	arrays.cs		\
	basic-float.cs		\
	basic-math.cs		\
	basic.cs		\
	exceptions.cs		\
	devirtualization.cs	\
	iltests.il		\
	test.cs			\
	generics.cs		\
	generics-variant-types.il\
	basic-simd.cs \
	basic-vectors.cs \
	aot-tests.cs \
	gc-test.cs \
	gshared.cs \
	unaligned.cs	\
	MemoryIntrinsics.il	\
	mixed.cs	\
	ratests.cs

regtests_UNIVERSAL = \
	aot-tests.exe \
	basic.exe \
	basic-float.exe \
	basic-long.exe \
	basic-calls.exe \
	builtin-types.exe \
	gshared.exe \
	objects.exe \
	arrays.exe \
	basic-math.exe \
	exceptions.exe \
	iltests.exe \
	devirtualization.exe \
	generics.exe \
	basic-simd.exe \
	unaligned.exe	\
	basic-vectors.exe	\
	ratests.exe

regtests_DISABLED = 

if FULL_AOT_TESTS
regtests_DISABLED += builtin-types.exe
endif

regtests = $(filter-out $(regtests_DISABLED),$(regtests_UNIVERSAL))

if !ENABLE_MSVC_ONLY

if WASM
arch_sources = $(wasm_sources)
arch_built=cpu-wasm.h
arch_define=__wasm__
target_define=TARGET_WASM
endif

if X86
arch_sources = $(x86_sources)
arch_built=cpu-x86.h
arch_define=__i386__
target_define=TARGET_X86
endif

if AMD64
arch_sources = $(amd64_sources)
arch_built=cpu-amd64.h
arch_define=__x86_64__
target_define=TARGET_AMD64
ARCH_FULLAOT_EXCLUDE=
endif

if POWERPC
arch_sources = $(ppc_sources)
arch_built=cpu-ppc.h
arch_define=__ppc__
target_define=TARGET_POWERPC
endif

if POWERPC64
arch_sources = $(ppc_sources)
arch_built=cpu-ppc64.h
arch_define=__ppc64__
target_define=TARGET_POWERPC
endif

if MIPS
arch_sources = $(mips_sources)
arch_built=cpu-mips.h
arch_define=__mips__
target_define=TARGET_MIPS
endif

if ARM
# pick up arm_dpimacros.h
ARCH_CFLAGS = -I../arch/arm
arch_sources = $(arm_sources)
arch_built=cpu-arm.h
arch_define=__arm__
target_define=TARGET_ARM
endif

if ARM64
arch_sources = $(arm64_sources)
arch_built=cpu-arm64.h
arch_define=__aarch64__
target_define=TARGET_ARM64
endif

if SPARC
arch_sources = $(sparc_sources)
arch_built=cpu-sparc.h
arch_define=__sparc__
target_define=TARGET_SPARC
endif

if SPARC64
arch_sources = $(sparc_sources)
arch_built=cpu-sparc.h
arch_define=__sparc__
target_define=TARGET_SPARC
endif

if S390X
arch_sources = $(s390x_sources)
arch_built=cpu-s390x.h
arch_define=__s390__
target_define=TARGET_S390X
endif

if RISCV32
arch_sources = $(riscv_sources)
arch_built = cpu-riscv32.h
arch_define = __riscv
target_define = TARGET_RISCV32
endif

if RISCV64
arch_sources = $(riscv_sources)
arch_built = cpu-riscv64.h
arch_define = __riscv
target_define = TARGET_RISCV64
endif

if HOST_WIN32
os_sources = $(windows_sources)
monobin_platform_ldflags=
endif

if HOST_SIGPOSIX
os_sources = $(posix_sources)
monobin_platform_ldflags=
endif

if HOST_DARWIN
os_sources = $(darwin_sources) $(posix_sources)
#monobin_platform_ldflags=-sectcreate __TEXT __info_plist $(top_srcdir)/mono/mini/Info.plist -framework CoreFoundation -framework Foundation
monobin_platform_ldflags=-framework CoreFoundation -framework Foundation
endif

if MONO_JEMALLOC_ENABLED
libmonoldflags += $(JEMALLOC_LDFLAGS)
endif

libmono_ee_interp_la_SOURCES = $(interp_sources)
libmono_ee_interp_la_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@ $(INTERP_CFLAGS)
if BITCODE
libmono_ee_interp_la_LDFLAGS = $(libmonoldflags)
if DISABLE_INTERPRETER
libmono_ee_interp_la_LIBADD = libmonosgen-2.0.la
endif
endif

if !WASM
extra_libmono_dbg_source = debugger-engine.c
endif

libmono_dbg_la_SOURCES = debugger-agent.c debugger-state-machine.c $(extra_libmono_dbg_source)
libmono_dbg_la_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@
if BITCODE
if DISABLE_DEBUGGER_AGENT
libmono_dbg_la_LIBADD = libmonosgen-2.0.la
endif
endif

dbg_libs = libmono-dbg.la

if DISABLE_DEBUGGER_AGENT
lib_LTLIBRARIES += $(dbg_libs)
endif

if !DISABLE_DEBUGGER_AGENT
dbg_libs_with_mini = $(dbg_libs)
noinst_LTLIBRARIES += $(dbg_libs)
endif

#
# This library is shared between mono and mono-sgen, since the code in mini/ doesn't contain
# compile time dependencies on boehm/sgen.
#
libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(arch_sources) $(os_sources)
libmini_la_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@

libmonoboehm_2_0_la_SOURCES =
libmonoboehm_2_0_la_CFLAGS = $(mono_boehm_CFLAGS) @CXX_ADD_CFLAGS@

libmonoboehm_2_0_la_LIBADD = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(boehm_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
libmonoboehm_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags) $(CCLDFLAGS)

libmonosgen_2_0_la_SOURCES =
libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS) @CXX_ADD_CFLAGS@

libmonosgen_2_0_la_LIBADD = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
libmonosgen_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags) $(CCLDFLAGS)
libmonosgen_2_0_la_LIBTOOLFLAGS = $(MONO_LIBTOOL_TAG)

noinst_LIBRARIES += libmaintest.a

libmaintest_a_SOURCES = interp/whitebox.c
libmaintest_a_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@

WHITEBOX_ASSEMBLY=interp/whitebox-snippets.exe
test_mono_interp_whitebox_SOURCES =
test_mono_interp_whitebox_CFLAGS = $(AM_CFLAGS) @CXX_REMOVE_CFLAGS@
test_mono_interp_whitebox_LDADD = interp/libmaintest_a-whitebox.$(OBJEXT) libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
test_mono_interp_whitebox_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags)
test_mono_interp_whitebox_DEPENDENCIES = $(WHITEBOX_ASSEMBLY)

check_PROGRAMS = test-mono-interp-whitebox

endif # !ENABLE_MSVC_ONLY

libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit

# These are public headers.
# They should not use glib.h, G_BEGIN_DECLS, guint, etc.
# They should be wrapped in MONO_BEGIN_DECLS / MONO_END_DECLS.
libmonoinclude_HEADERS = \
	jit.h		\
	mono-private-unstable.h

CSFLAGS = -unsafe -nowarn:0219,0169,0414,0649,0618

basic-simd.exe: basic-simd.cs TestDriver.dll
	$(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/Mono.Simd.dll

basic-vectors.exe: basic-vectors.cs TestDriver.dll
	$(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/System.Numerics.dll -r:$(CLASS)/System.Numerics.Vectors.dll

builtin-types.exe: builtin-types.cs TestDriver.dll
	$(MCS) -out:$@ $(CSFLAGS) -define:ARCH_$(shell echo $$((8 * $(SIZEOF_VOID_P)))) $< -r:TestDriver.dll

nacl.exe: nacl.cs TestDriver.dll
	$(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:$(CLASS)/Mono.Simd.dll

generics.exe: generics.cs TestDriver.dll generics-variant-types.dll
	$(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:generics-variant-types.dll -r:$(CLASS)/System.Core.dll

unaligned.exe: unaligned.cs TestDriver.dll MemoryIntrinsics.dll
	$(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:MemoryIntrinsics.dll

%.exe: %.cs TestDriver.dll
	$(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll

%.exe: %.il TestDriver.dll
	$(ILASM) -output=$@ $<

TestDriver.dll: $(srcdir)/TestDriver.cs $(srcdir)/TestHelpers.cs
	$(MCS) -out:$@ -target:library $^

generics-variant-types.dll: generics-variant-types.il
	$(ILASM) -dll -output=$@ $<

MemoryIntrinsics.dll: MemoryIntrinsics.il
	$(ILASM) -dll -output=$@ $<

GENMDESC_OPTS=

GENMDESC_PRG=$(PYTHON) $(srcdir)/genmdesc.py $(target_define) $(srcdir)

cpu-wasm.h: mini-ops.h cpu-wasm.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-wasm.h wasm_desc $(srcdir)/cpu-wasm.md

cpu-x86.h: mini-ops.h cpu-x86.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-x86.h x86_desc $(srcdir)/cpu-x86.md

cpu-amd64.h: mini-ops.h cpu-amd64.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-amd64.h amd64_desc $(srcdir)/cpu-amd64.md

cpu-ppc.h: mini-ops.h cpu-ppc.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-ppc.h ppcg4 $(srcdir)/cpu-ppc.md

cpu-ppc64.h: mini-ops.h cpu-ppc64.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-ppc64.h ppc64_cpu_desc $(srcdir)/cpu-ppc64.md

cpu-arm.h: mini-ops.h cpu-arm.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-arm.h arm_cpu_desc $(srcdir)/cpu-arm.md

cpu-arm64.h: mini-ops.h cpu-arm64.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-arm64.h arm64_cpu_desc $(srcdir)/cpu-arm64.md

cpu-sparc.h: mini-ops.h cpu-sparc.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-sparc.h sparc_desc $(srcdir)/cpu-sparc.md

cpu-s390x.h: mini-ops.h cpu-s390x.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-s390x.h s390x_cpu_desc $(srcdir)/cpu-s390x.md

cpu-mips.h: mini-ops.h cpu-mips.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-mips.h mips_desc $(srcdir)/cpu-mips.md

cpu-riscv32.h: cpu-riscv32.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-riscv32.h riscv32_cpu_desc $(srcdir)/cpu-riscv32.md

cpu-riscv64.h: cpu-riscv64.md $(srcdir)/genmdesc.py
	$(GENMDESC_PRG) cpu-riscv64.h riscv64_cpu_desc $(srcdir)/cpu-riscv64.md

testi: mono test.exe
	$(MINI_RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe

test-local: $(regtests)

test-bundle-local:
	mkdir -p $(TEST_BUNDLE_PATH)/tests/mini
	cp -L $(regtests) TestDriver.dll MemoryIntrinsics.dll generics-variant-types.dll $(TEST_BUNDLE_PATH)/tests/mini/
	cp -L mono-sgen $(TEST_BUNDLE_PATH)/
	chmod +x $(TEST_BUNDLE_PATH)/mono-sgen
if SUPPORT_BOEHM
	cp -L mono-boehm $(TEST_BUNDLE_PATH)/
	chmod +x $(TEST_BUNDLE_PATH)/mono-boehm
endif

# ensure the tests are actually correct
checktests: $(regtests)
	for i in $(regtests); do $(MINI_RUNTIME) $$i; done

rcheck-nunit: mono $(regtests)
	$(MINI_RUNTIME) --regression $(regtests) > regressiontests.out 2>&1; cat regressiontests.out; \
	if grep -q "100% pass" regressiontests.out; then successbool=True; failurescount=0; else successbool=False; failurescount=1; fi; \
	echo "<?xml version='1.0' encoding='utf-8'?>\
		<test-results failures='$$failurescount' total='1' not-run='0' name='regression-tests.dummy' date='$$(date +%F)' time='$$(date +%T)'>\
			<test-suite name='regression-tests.dummy' success='$$successbool' time='0'>\
				<results><test-case name='MonoTests.regressions.100percentsuccess' executed='True' success='$$successbool' time='0'>" > TestResult-regression.xml; \
					if [ "$$successbool" = "False" ]; then echo "<failure><message><![CDATA[$$(cat regressiontests.out)]]></message><stack-trace></stack-trace></failure>" >> TestResult-regression.xml; fi; \
				echo "</test-case></results>\
			</test-suite>\
		</test-results>" >> TestResult-regression.xml; exit $$failurescount

rcheck: mono $(regtests)
	$(MINI_RUNTIME) --regression $(regtests)

richeck: mono $(regtests)
	$(INTERP_RUNTIME) --regression $(regtests)

interp-whitebox: test-mono-interp-whitebox
	MONO_PATH=$(CLASS) ./$< $(WHITEBOX_ASSEMBLY)

mixedcheck: mono mixed.exe
	$(MINI_RUNTIME) --interp=jit=JitClass mixed.exe

check-seq-points:

# This test is fragile so disabled by default.
# single_imm_size support is incomplete.
# __declspec (thread) support breaks it.
# See https://github.com/mono/mono/pull/15599#issuecomment-509444313.
# See https://github.com/mono/mono/pull/15567.
# It was already previously disabled for ARM.
check-seq-points-force: mono $(regtests)
	rm -f TestResult-op_il_seq_point.xml
	for i in $(regtests); do $(srcdir)/test_op_il_seq_point.sh $(DEFAULT_PROFILE) $$i || ($(srcdir)/test_op_il_seq_point_headerfooter.sh; exit 1) || exit 1; done
	for i in $(regtests); do $(srcdir)/test_op_il_seq_point.sh $(DEFAULT_PROFILE) $$i --aot || ($(srcdir)/test_op_il_seq_point_headerfooter.sh; exit 1) || exit 1; done
	$(srcdir)/test_op_il_seq_point_headerfooter.sh

gctest: mono gc-test.exe
	MONO_DEBUG_OPTIONS=clear-nursery-at-gc $(MINI_RUNTIME) --regression gc-test.exe

LLVM_AOT_RUNTIME_OPTS=$(if $(LLVM),--llvm,)
LLVM_AOT_COMPILER_OPTS=mcpu=native
GSHAREDVT_RUNTIME_OPTS=$(if $(GSHAREDVT),-O=gsharedvt,)

aotcheck: mono $(regtests)
	rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM *.exe.dll
	$(MINI_RUNTIME) $(LLVM_AOT_RUNTIME_OPTS) --aot="$(LLVM_AOT_COMPILER_OPTS)" $(regtests) || exit 1
	for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
	rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM *.exe.dll

llvmaotcheck:
	$(MAKE) aotcheck LLVM=1

gsharedvtcheck:
	$(MAKE) fullaotcheck GSHAREDVT=1

hybridcheck:
	$(MAKE) fullaotcheck HYBRID=1

# FIXME: force preemptive suspend while interpreter doesn't support coop/hybird suspend
fullaotmixedcheck:
	$(MAKE) fullaotcheck MIXED=1 MONO_THREADS_SUSPEND=preemptive

fullaot_regtests = $(regtests)
fullaot_testing_deps = generics-variant-types.dll TestDriver.dll MemoryIntrinsics.dll
fullaot_testing_deps_commas = generics-variant-types.dll,TestDriver.dll,MemoryIntrinsics.dll

FULLAOT_LIBS_UNIVERSAL = \
	mscorlib.dll \
	System.Core.dll \
	System.dll \
	System.Xml.dll \
	System.Security.dll \
	Mono.Simd.dll \
	Mono.Security.dll \
	System.Numerics.dll \
	System.Numerics.Vectors.dll \
	Mono.Posix.dll \
	System.Configuration.dll

FULLAOT_LIBS_DISABLED =

# Skip aoting the tests that aren't compiled 
# on the full aot profiles because they're skipped
# on mobile profiles
if FULL_AOT_TESTS
FULLAOT_LIBS_DISABLED += \
	Mono.Posix.dll \
	System.Configuration.dll
else
if FULL_AOT_INTERP_TESTS
FULLAOT_LIBS_DISABLED += \
	Mono.Posix.dll \
	System.Configuration.dll
endif
endif

FULLAOT_LIBS = $(filter-out $(FULLAOT_LIBS_DISABLED),$(FULLAOT_LIBS_UNIVERSAL))

FULLAOT_TMP_DIR=$(top_builddir)/mono/mini/fullaot-tmp
if FULL_AOT_TESTS
# use the available testing profile
FULLAOT_MONO_PATH=$(CLASS)
else
FULLAOT_MONO_PATH=$(FULLAOT_TMP_DIR)
endif

FULLAOT_AOT_ARGS=$(if $(HYBRID),hybrid,full,interp),$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)
FULLAOT_ARGS=$(if $(HYBRID),--hybrid-aot,--full-aot)

# This currently only works on amd64/arm
fullaotcheck: $(mono) $(fullaot_regtests) $(fullaot_testing_deps)
	rm -rf $(FULLAOT_TMP_DIR)
	mkdir $(FULLAOT_TMP_DIR)
if !FULL_AOT_TESTS
	$(MAKE) fullaot-libs AOT_FLAGS="$(FULLAOT_AOT_ARGS)"
endif
	cp $(fullaot_regtests) $(fullaot_testing_deps) $(FULLAOT_TMP_DIR)/
	MONO_PATH=$(FULLAOT_MONO_PATH) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(LLVM_AOT_RUNTIME_OPTS) $(GSHAREDVT_RUNTIME_OPTS) --aot="$(FULLAOT_AOT_ARGS),$(LLVM_AOT_COMPILER_OPTS)" $(FULLAOT_TMP_DIR)/{$(fullaot_testing_deps_commas),*.exe} || exit 1
	ln -s $(if $(MONO_EXECUTABLE),$(MONO_EXECUTABLE),$$PWD/mono) $(FULLAOT_TMP_DIR)/
	for i in $(fullaot_regtests); do echo $$i; MONO_PATH=$(FULLAOT_MONO_PATH) $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(FULLAOT_ARGS) $(FULLAOT_TMP_DIR)/$$i --exclude '!FULLAOT' $(ARCH_FULLAOT_EXCLUDE) || exit 1; done
	if test x$(MIXED) == x1; then failed=0;i=0; while test $$i -lt 900; do i=`expr $$i + 1`; bash -c "echo -n '.'"; MONO_PATH=$(FULLAOT_MONO_PATH) MONO_DEBUG=aot-skip=$$i $(top_builddir)/runtime/mono-wrapper --full-aot-interp $(FULLAOT_TMP_DIR)/basic.exe > $(FULLAOT_TMP_DIR)/mixed.log || failed=1; if test $$failed -eq 1; then echo "Failed at $$i"; exit $$failed; fi; done; fi

# This can run in parallel
fullaot-libs: $(patsubst %,fullaot-tmp/%.dylib,$(FULLAOT_LIBS))

fullaot-tmp/%.dylib: $(CLASS)/%
	cp $(CLASS)/$* fullaot-tmp/
	mkdir fullaot-tmp/$*-tmp
	MONO_PATH="fullaot-tmp/$(PLATFORM_PATH_SEPARATOR)$(CLASS)" $(top_builddir)/runtime/mono-wrapper $(MOBILE_RUNTIME_ARG) $(LLVM_AOT_RUNTIME_OPTS) $(GSHAREDVT_RUNTIME_OPTS) --aot=$(AOT_FLAGS),temp-path=fullaot-tmp/$*-tmp fullaot-tmp/$*
	rm -rf fullaot-tmp/$*-tmp

llvmfullaotcheck:
	$(MAKE) fullaotcheck LLVM=1 GSHAREDVT=1

llvmonly_regtests = $(fullaot_regtests) gshared.exe

llvmonlycheck: mono $(llvmonly_regtests)
	rm -rf fullaot-tmp
	mkdir fullaot-tmp
	$(MAKE) fullaot-libs AOT_FLAGS="llvmonly,clangxx=clang++-6.0,$(MONO_FULLAOT_ADDITIONAL_ARGS)$(INVARIANT_AOT_OPTIONS)"
	cp $(llvmonly_regtests) $(fullaot_testing_deps) fullaot-tmp/
	MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper  $(MOBILE_RUNTIME_ARG) --aot=llvmonly,clangxx=clang++-6.0 fullaot-tmp/{$(fullaot_testing_deps_commas),*.exe} || exit 1
	ln -s $$PWD/mono fullaot-tmp/
	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

gccheck: gc-test.exe
	MONO_GC_PARAMS=stack-mark=precise MONO_GC_DEBUG=clear-at-gc ./mono-sgen gc-test.exe	

bench: mono test.exe
	time env $(MINI_RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe

mbench: test.exe
	time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe

stat1: mono bench.exe
	$(MINI_RUNTIME) --verbose --statfile stats.pl --regression bench.exe
	perl viewstat.pl stats.pl

stat2: mono basic.exe
	$(MINI_RUNTIME) --verbose --statfile stats.pl --regression basic.exe
	perl viewstat.pl -e stats.pl

stat3: mono bench.exe
	$(MINI_RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe 
	perl viewstat.pl stats.pl

docu: mini.sgm
	docbook2txt mini.sgm

# We need these because automake can't process normal make conditionals
check_local_targets = $(if $(EMIT_NUNIT), rcheck-nunit, rcheck)

check-local: $(check_local_targets)

clean-local:
	rm -f mono mono.exe monow.exe mono-sgen.exe a.out gmon.out *.o buildver-boehm.h buildver-sgen.h test.exe regressionexitcode.out TestResult-op_il_seq_point.xml*

pkgconfigdir = $(libdir)/pkgconfig

BUILT_SOURCES = version.h $(arch_built)

CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
EXTRA_DIST = TestDriver.cs \
	TestHelpers.cs \
	genmdesc.py				\
	$(test_sources) 			\
	$(wasm_sources) cpu-wasm.md 		\
	$(x86_sources) cpu-x86.md 		\
	$(amd64_sources) cpu-amd64.md 		\
	$(ppc_sources) cpu-ppc.md cpu-ppc64.md 	\
	$(arm_sources) cpu-arm.md 		\
	$(arm64_sources) cpu-arm64.md 		\
	$(mips_sources) cpu-mips.md 		\
	$(sparc_sources) cpu-sparc.md 		\
	$(s390x_sources) cpu-s390x.md 		\
	$(riscv_sources) cpu-riscv32.md cpu-riscv64.md \
	$(windows_sources)			\
	$(darwin_sources) Info.plist		\
	$(posix_sources)					\
	test_op_il_seq_point.sh			\
	test_op_il_seq_point_headerfooter.sh	\
	interp/whitebox-snippets.il		\
	Makefile.am.in

version.h: Makefile
	if test -e $(top_srcdir)/.git; then \
		(cd $(top_srcdir); \
			LANG=C; export LANG; \
			if test -z "$$ghprbPullId"; then \
				branch=`git branch | grep '^\*' | sed 's/.*detached .*/explicit/' | cut -d ' ' -f 2`; \
			else \
				branch="pull-request-$$ghprbPullId"; \
			fi; \
			version=`git log --no-color --first-parent -n1 --pretty=format:%h`; \
			echo "#define FULL_VERSION \"$$branch/$$version\""; \
		); \
	else \
		if test -z "$$MONO_BRANCH" -o -z "$$MONO_BUILD_REVISION"; then \
			echo "#define FULL_VERSION \"tarball\""; \
		else \
			echo "#define FULL_VERSION \"$$MONO_BRANCH/$$MONO_BUILD_REVISION\""; \
		fi \
	fi > version.h

# Utility target for patching libtool to speed up linking
patch-libtool:
	sed -e 's,if (for obj in $$oldobjs,if (for obj in "",g' < ../../libtool > 2; mv 2 ../../libtool
	chmod a+x ../../libtool

# Utility target for patching libtool to get rid of the 'ranlib: file <file> has no symbols" warnings
patch-osx-libtool:
	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
	chmod a+x ../../libtool

# Utility target to patch automake to generate the same format silent output as the old mono silent build did
patch-automake:
	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

tags:
	etags -o TAGS `find .. -name "*.h" -o -name "*.c"`

if ENABLE_LLVM
llvm_makefile_dep = $(mono_build_root)/llvm/llvm_config.mk
endif

if HAS_EXTENSION_MODULE
else
Makefile.am: Makefile.am.in
	echo "##################### Generated from Makefile.am.in, do not modify ##########################" > $@
	cat $< >> $@

endif

# Per-library because linking doesn't like -xc++, it treats libraries as C++.
CFLAGS := $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@)