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