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