3 monodir=$(top_builddir)
5 # This is needed for automake dependency generation
6 libgc_libs=$(monodir)/libgc/libmonogc.la
7 libgc_static_libs=$(monodir)/libgc/libmonogc-static.la
10 $(monodir)/mono/metadata/libmonoruntime.la \
11 $(monodir)/mono/io-layer/libwapi.la \
12 $(monodir)/mono/utils/libmonoutils.la \
13 $(GLIB_LIBS) $(LIBICONV) \
17 $(monodir)/mono/metadata/libmonoruntimesgen.la \
18 $(monodir)/mono/sgen/libmonosgen.la \
19 $(monodir)/mono/io-layer/libwapi.la \
20 $(monodir)/mono/utils/libmonoutils.la \
21 $(GLIB_LIBS) $(LIBICONV)
24 $(monodir)/mono/metadata/libmonoruntime-static.la \
25 $(monodir)/mono/io-layer/libwapi.la \
26 $(monodir)/mono/utils/libmonoutils.la \
27 $(GLIB_LIBS) $(LIBICONV) \
31 $(monodir)/mono/metadata/libmonoruntimesgen-static.la \
32 $(monodir)/mono/sgen/libmonosgen-static.la \
33 $(monodir)/mono/io-layer/libwapi.la \
34 $(monodir)/mono/utils/libmonoutils.la \
35 $(GLIB_LIBS) $(LIBICONV)
37 -include $(mcs_topdir)/build/config.make
38 CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
40 RUNTIME_EXECUTABLE = $(if $(BOEHM),$(top_builddir)/mono/mini/mono-boehm,$(top_builddir)/runtime/mono-wrapper)
42 MINI_RUNTIME = MONO_PATH=$(CLASS) $(RUNTIME_EXECUTABLE)
43 RUNTIME_AOTCHECK = MONO_PATH=$(CLASS):. $(RUNTIME_EXECUTABLE)
45 MCS = $(MINI_RUNTIME) $(mcs_topdir)/class/lib/build/mcs.exe -unsafe -nowarn:0162
46 ILASM = $(MINI_RUNTIME) $(CLASS)/ilasm.exe
52 $(PLATFORM_CFLAGS) $(ARCH_CFLAGS) $(SHARED_CFLAGS)
54 AM_CXXFLAGS = $(LLVM_CXXFLAGS) $(GLIB_CFLAGS)
58 # The mingw math.h has "extern inline" functions that dont appear in libs, so
59 # optimisation is required to actually inline them
63 # hack for automake to have the same source file in a library and a bin
64 genmdesc_CFLAGS = $(AM_CFLAGS)
66 monoldflags=$(export_ldflags)
67 monobinldflags=$(export_ldflags) $(extra_runtime_ldflags)
70 libmonoldflags=-no-undefined -avoid-version -Wl,--kill-at $(monoldflags)
73 libmonoldflags= -avoid-version $(monoldflags)
75 libmonoldflags=$(monoldflags) -version-info 1:0:0
80 sgen_binaries = mono-sgen
81 sgen_libraries = libmonosgen-2.0.la
82 sgen_static_libraries = libmini-static.la $(sgenstatic_libs)
86 boehm_libraries = libmonoboehm-2.0.la
87 boehm_static_libraries = libmini-static.la $(static_libs)
88 boehm_binaries = mono-boehm
91 #The mono uses sgen, while libmono remains boehm
93 mono_bin_suffix = sgen
95 mono_bin_suffix = boehm
97 libmono_suffix = boehm
99 if DISABLE_EXECUTABLES
101 mono: mono-$(mono_bin_suffix)
104 mono.exe: mono-$(mono_bin_suffix).exe
108 (cd $(DESTDIR)$(bindir) && ln -sf mono-$(mono_bin_suffix) mono)
109 (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)
112 if DISABLE_EXECUTABLES
115 bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) monow
117 bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries)
121 if DISABLE_EXECUTABLES
122 noinst_PROGRAMS = genmdesc
124 noinst_PROGRAMS = genmdesc mono
127 if DISABLE_EXECUTABLES
128 shared_libraries = $(boehm_libraries) $(sgen_libraries)
131 shared_libraries = $(boehm_libraries) $(sgen_libraries)
135 lib_LTLIBRARIES = $(shared_libraries)
138 mini_common_lib = libmini.la
143 if DISABLE_EXECUTABLES
144 noinst_LTLIBRARIES = $(mini_common_lib)
146 noinst_LTLIBRARIES = $(mini_common_lib) libmini-static.la
150 lib_LTLIBRARIES += libmono-llvm.la
151 libmono_llvm_la_SOURCES = mini-llvm.c mini-llvm-cpp.cpp
152 libmono_llvm_la_LIBADD = $(GLIB_LIBS) $(LLVM_LIBS) $(LLVM_LDFLAGS)
154 libmono_llvm_la_LDFLAGS=-Wl,-undefined -Wl,suppress -Wl,-flat_namespace
156 libmono_llvm_la_LIBADD += $(top_builddir)/mono/mini/libmonoboehm-$(API_VER).la $(libs)
160 mono_boehm_SOURCES = \
163 mono_CFLAGS = $(AM_CFLAGS)
165 mono_boehm_CFLAGS = $(AM_CFLAGS)
167 AM_CPPFLAGS = $(LIBGC_CPPFLAGS)
169 mono_sgen_SOURCES = \
175 mono_sgen_CFLAGS = $(AM_CFLAGS)
177 # We build this after libmono was built so it contains the date when the final
180 if DISABLE_EXECUTABLES
181 buildver-boehm.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntime.la
183 buildver-boehm.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntime-static.la
185 @echo "const char *build_date = \"`date`\";" > buildver-boehm.h
186 mono_boehm-main.$(OBJEXT): buildver-boehm.h
189 if DISABLE_EXECUTABLES
190 buildver-sgen.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimesgen.la $(monodir)/mono/sgen/libmonosgen.la
192 buildver-sgen.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimesgen-static.la $(monodir)/mono/sgen/libmonosgen-static.la
194 @echo "const char *build_date = \"`date`\";" > buildver-sgen.h
195 mono_sgen-main-sgen.$(OBJEXT): buildver-sgen.h
196 main-sgen.$(OBJEXT): buildver-sgen.h
199 LIBMONO_DTRACE_OBJECT = .libs/mono-dtrace.$(OBJEXT)
201 MONO_DTRACE_OBJECT = mono-dtrace.$(OBJEXT)
207 LIBMONO_DTRACE_OBJECT =
211 # Link libmono into mono statically
212 # This leads to higher performance, especially with TLS
213 MONO_LIB=$(boehm_static_libraries)
214 MONO_SGEN_LIB=$(sgen_static_libraries)
216 MONO_LIB=libmonoboehm-2.0.la
217 MONO_SGEN_LIB=libmonosgen-2.0.la
223 LLVMMONOF=$(LLVM_LIBS) $(LLVM_LDFLAGS)
232 $(MONO_DTRACE_OBJECT)
234 mono_boehm_LDFLAGS = \
235 $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags)
243 $(MONO_DTRACE_OBJECT)
245 mono_sgen_LDFLAGS = $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags)
249 # mono_LDADD = $(mono_sgen_LDADD)
250 # mono_LDFLAGS = $(mono_sgen_LDFLAGS)
257 mono-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d mini.lo $(monodir)/mono/metadata/libmonoruntime-static.la
258 DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
259 $@ $(top_srcdir)/data/mono.d $(monodir)/mono/metadata/libmonoruntime-static.la mini.lo
261 .libs/mono-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d mini.lo $(monodir)/mono/metadata/libmonoruntime.la
262 DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
263 --pic $@ $(top_srcdir)/data/mono.d $(monodir)/mono/metadata/libmonoruntime.la mini.lo
267 # Create monow.exe, linked for the 'windows' subsystem
270 monow_LDADD = $(mono_boehm_LDADD)
271 monow_LDFLAGS = $(mono_boehm_LDFLAGS) -mwindows
272 monow_SOURCES = $(mono_boehm_SOURCES)
274 monow_LDADD = $(mono_sgen_LDADD)
275 monow_LDFLAGS = $(mono_sgen_LDFLAGS) -mwindows
276 monow_SOURCES = $(mono_sgen_SOURCES)
285 ../metadata/opcodes.c
287 # Don't link this against libmonoruntime to speed up rebuilds
289 $(monodir)/mono/utils/libmonoutils.la -lm \
397 local-propagation.c \
408 mini-generic-sharing.c \
413 mini-native-types.c \
439 devirtualization.cs \
443 generics-variant-types.il\
449 regtests=basic.exe basic-float.exe basic-long.exe basic-calls.exe objects.exe arrays.exe basic-math.exe exceptions.exe iltests.exe devirtualization.exe generics.exe basic-simd.exe
451 test_sources += nacl.cs
456 arch_sources = $(x86_sources)
462 arch_sources = $(amd64_sources)
463 arch_built=cpu-amd64.h
464 arch_define=__x86_64__
465 ARCH_FULLAOT_EXCLUDE=--exclude DYNCALL --exclude GSHAREDVT
469 arch_sources = $(ppc_sources)
475 arch_sources = $(ppc_sources)
476 arch_built=cpu-ppc64.h
477 arch_define=__ppc64__
481 arch_sources = $(mips_sources)
482 arch_built=cpu-mips.h
487 # pick up arm_dpimacros.h
488 ARCH_CFLAGS = -I../arch/arm
489 arch_sources = $(arm_sources)
495 arch_sources = $(arm64_sources)
496 arch_built=cpu-arm64.h
497 arch_define=__aarch64__
501 arch_sources = $(sparc_sources)
502 arch_built=cpu-sparc.h
503 arch_define=__sparc__
507 arch_sources = $(sparc_sources)
508 arch_built=cpu-sparc.h
509 arch_define=__sparc__
513 arch_sources = $(s390x_sources)
514 arch_built=cpu-s390x.h
519 arch_sources = $(ia64_sources)
520 arch_built = cpu-ia64.h
525 os_sources = $(windows_sources)
526 monobin_platform_ldflags=
530 os_sources = $(posix_sources)
531 monobin_platform_ldflags=
535 os_sources = $(darwin_sources) $(posix_sources)
536 #monobin_platform_ldflags=-sectcreate __TEXT __info_plist $(top_srcdir)/mono/mini/Info.plist -framework CoreFoundation -framework Foundation
537 monobin_platform_ldflags=-framework CoreFoundation -framework Foundation
540 libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(arch_sources) $(os_sources)
541 libmini_la_CFLAGS = $(mono_CFLAGS)
543 libmonoboehm_2_0_la_SOURCES =
544 libmonoboehm_2_0_la_CFLAGS = $(mono_boehm_CFLAGS)
545 libmonoboehm_2_0_la_LIBADD = libmini.la $(libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
546 libmonoboehm_2_0_la_LDFLAGS = $(libmonoldflags)
548 libmonosgen_2_0_la_SOURCES =
549 libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS)
550 libmonosgen_2_0_la_LIBADD = libmini.la $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
551 libmonosgen_2_0_la_LDFLAGS = $(libmonoldflags)
554 # This library is shared between mono and mono-sgen, since the code in mini/ doesn't contain
555 # compile time dependencies on boehm/sgen.
557 libmini_static_la_SOURCES = $(libmini_la_SOURCES)
558 libmini_static_la_CFLAGS = $(AM_CFLAGS)
559 libmini_static_la_LDFLAGS = -static
560 libmini_static_la_LIBADD = $(MONO_DTRACE_OBJECT)
562 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
564 libmonoinclude_HEADERS = jit.h
566 CSFLAGS = -unsafe -nowarn:0219,0169,0414,0649
568 basic-simd.exe: basic-simd.cs TestDriver.dll
569 $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:Mono.Simd.dll
571 nacl.exe: nacl.cs TestDriver.dll
572 $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:Mono.Simd.dll
574 generics.exe: generics.cs TestDriver.dll generics-variant-types.dll
575 $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll -r:generics-variant-types.dll
577 %.exe: %.cs TestDriver.dll
578 $(MCS) -out:$@ $(CSFLAGS) $< -r:TestDriver.dll
580 iltests.il: iltests.il.in Makefile.am
581 echo '// DO NOT EDIT: This file has been generated from iltests.il.in' > iltests.il
582 cpp -Darch=$(arch_define) < $(srcdir)/iltests.il.in | sed 's/^#.*//' >> iltests.il
585 $(ILASM) -output=$@ $<
587 TestDriver.dll: $(srcdir)/TestDriver.cs
588 $(MCS) -out:$@ -target:library $<
590 generics-variant-types.dll: generics-variant-types.il
591 $(ILASM) -dll -output=$@ $<
599 # we don't always use the perl impl because it's an additional
600 # build dependency for the poor windows users
601 # $(arch_define) is the preprocessor symbol that enables all the opcodes
602 # for the specific platform in mini-ops.h
604 GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
605 else !CROSS_COMPILING
607 GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
609 GENMDESC_PRG=./genmdesc $(GENMDESC_OPTS)
611 endif !CROSS_COMPILING
613 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
614 $(GENMDESC_PRG) cpu-x86.h x86_desc $(srcdir)/cpu-x86.md
616 cpu-amd64.h: cpu-amd64.md genmdesc$(EXEEXT)
617 $(GENMDESC_PRG) cpu-amd64.h amd64_desc $(srcdir)/cpu-amd64.md
619 cpu-ppc.h: cpu-ppc.md genmdesc$(EXEEXT)
620 $(GENMDESC_PRG) cpu-ppc.h ppcg4 $(srcdir)/cpu-ppc.md
622 cpu-ppc64.h: cpu-ppc64.md genmdesc$(EXEEXT)
623 $(GENMDESC_PRG) cpu-ppc64.h ppc64_cpu_desc $(srcdir)/cpu-ppc64.md
625 cpu-arm.h: cpu-arm.md genmdesc$(EXEEXT)
626 $(GENMDESC_PRG) cpu-arm.h arm_cpu_desc $(srcdir)/cpu-arm.md
628 cpu-arm64.h: cpu-arm64.md genmdesc$(EXEEXT)
629 $(GENMDESC_PRG) cpu-arm64.h arm64_cpu_desc $(srcdir)/cpu-arm64.md
631 cpu-sparc.h: cpu-sparc.md genmdesc$(EXEEXT)
632 $(GENMDESC_PRG) cpu-sparc.h sparc_desc $(srcdir)/cpu-sparc.md
634 cpu-s390x.h: cpu-s390x.md genmdesc$(EXEEXT)
635 $(GENMDESC_PRG) cpu-s390x.h s390x_cpu_desc $(srcdir)/cpu-s390x.md
637 cpu-ia64.h: cpu-ia64.md genmdesc$(EXEEXT)
638 $(GENMDESC_PRG) cpu-ia64.h ia64_desc $(srcdir)/cpu-ia64.md
640 cpu-mips.h: cpu-mips.md genmdesc$(EXEEXT)
641 $(GENMDESC_PRG) cpu-mips.h mips_desc $(srcdir)/cpu-mips.md
644 $(MINI_RUNTIME) -v -v --ncompile 1 --compile Test:$(mtest) test.exe
646 # ensure the tests are actually correct
647 checktests: $(regtests)
648 for i in $(regtests); do $(MINI_RUNTIME) $$i; done
650 rcheck: mono $(regtests)
652 for i in $(regtests); do echo "running test $$i"; $(MINI_RUNTIME) $$i --exclude 'NaClDisable' || exit 1; done
654 -($(MINI_RUNTIME) --regression $(regtests); echo $$? > regressionexitcode.out) | $(srcdir)/emitnunit.pl
655 exit $$(cat regressionexitcode.out)
658 rcheck2: mono $(regtests)
659 $(MINI_RUNTIME) --regression $(regtests)
661 check-seq-points: mono $(regtests)
662 rm -f TestResults_op_il_seq_point.xml
663 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
664 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
665 $(srcdir)/test_op_il_seq_point_headerfooter.sh
667 gctest: mono gc-test.exe
668 MONO_DEBUG_OPTIONS=clear-nursery-at-gc $(MINI_RUNTIME) --regression gc-test.exe
670 LLVM_AOT_RUNTIME_OPTS=$(if $(LLVM),--llvm,)
671 GSHAREDVT_RUNTIME_OPTS=$(if $(GSHAREDVT),-O=gsharedvt,)
673 aotcheck: mono $(regtests)
674 rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
675 $(MINI_RUNTIME) $(LLVM_AOT_RUNTIME_OPTS) --aot $(regtests) || exit 1
676 for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
677 rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
680 $(MAKE) aotcheck LLVM=1
683 $(MAKE) fullaotcheck GSHAREDVT=1
685 fullaot_regtests = $(regtests) aot-tests.exe $(if $(GSHAREDVT),gshared.exe)
687 # This currently only works on amd64/arm
688 fullaotcheck: mono $(fullaot_regtests)
691 cp $(CLASS)/mscorlib.dll $(CLASS)/System.Core.dll $(CLASS)/System.dll $(CLASS)/Mono.Posix.dll $(CLASS)/System.Configuration.dll $(CLASS)/System.Security.dll $(CLASS)/System.Xml.dll $(CLASS)/Mono.Security.dll $(CLASS)/Mono.Simd.dll $(regtests) generics-variant-types.dll TestDriver.dll fullaot-tmp/
692 cp $(fullaot_regtests) fullaot-tmp/
693 MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper $(LLVM_AOT_RUNTIME_OPTS) $(GSHAREDVT_RUNTIME_OPTS) --aot=full fullaot-tmp/* || exit 1
694 ln -s $$PWD/mono fullaot-tmp/
695 for i in $(fullaot_regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --full-aot fullaot-tmp/$$i --exclude '!FULLAOT' $(ARCH_FULLAOT_EXCLUDE) || exit 1; done
698 $(MAKE) fullaotcheck LLVM=1
701 MONO_GC_PARAMS=stack-mark=precise MONO_GC_DEBUG=clear-at-gc ./mono-sgen gc-test.exe
704 time env $(MINI_RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
707 time $(monodir)/mono/jit/mono --ncompile $(count) --compile Test:$(mtest) test.exe
709 stat1: mono bench.exe
710 $(MINI_RUNTIME) --verbose --statfile stats.pl --regression bench.exe
711 perl viewstat.pl stats.pl
713 stat2: mono basic.exe
714 $(MINI_RUNTIME) --verbose --statfile stats.pl --regression basic.exe
715 perl viewstat.pl -e stats.pl
717 stat3: mono bench.exe
718 $(MINI_RUNTIME) --statfile stats.pl --ncompile 1000 --compile Tests:test_0_many_nested_loops bench.exe
719 perl viewstat.pl stats.pl
724 check-local: rcheck check-seq-points
727 rm -f mono a.out gmon.out *.o buildver-boehm.h buildver-sgen.h test.exe regressionexitcode.out TestResults_op_il_seq_point.xml*
729 pkgconfigdir = $(libdir)/pkgconfig
731 BUILT_SOURCES = version.h $(arch_built)
733 CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
734 EXTRA_DIST = TestDriver.cs \
738 $(x86_sources) cpu-x86.md \
739 $(amd64_sources) cpu-amd64.md \
740 $(ppc_sources) cpu-ppc.md cpu-ppc64.md \
741 $(arm_sources) cpu-arm.md \
742 $(arm64_sources) cpu-arm64.md \
743 $(mips_sources) cpu-mips.md \
744 $(sparc_sources) cpu-sparc.md \
745 $(s390x_sources) cpu-s390x.md \
746 $(ia64_sources) cpu-ia64.md \
748 $(darwin_sources) Info.plist \
750 test_op_il_seq_point.sh \
751 test_op_il_seq_point_headerfooter.sh \
755 if test -d $(top_srcdir)/.git; then \
757 LANG=C; export LANG; \
758 branch=`git branch | grep '^\*' | sed 's/(detached from .*/explicit/' | cut -d ' ' -f 2`; \
759 version=`git log --no-color --first-parent -n1 --pretty=format:%h`; \
760 echo "#define FULL_VERSION \"$$branch/$$version\""; \
763 echo "#define FULL_VERSION \"tarball\""; \
766 # Utility target for patching libtool to speed up linking
768 sed -e 's,if (for obj in $$oldobjs,if (for obj in "",g' < ../../libtool > 2; mv 2 ../../libtool
769 chmod a+x ../../libtool
771 # Utility target for patching libtool to get rid of the 'ranlib: file <file> has no symbols" warnings
773 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
774 chmod a+x ../../libtool
776 # Utility target to patch automake to generate the same format silent output as the old mono silent build did
778 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
781 etags -o TAGS `find .. -name "*.h" -o -name "*.c"`
783 if HAS_EXTENSION_MODULE
785 Makefile.am: Makefile.am.in