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