Merge remote branch 'upstream/master'
[mono.git] / mono / mini / Makefile.am
index 1d56c033a9aea45902a914bc6d5f89815cbd5239..a1ee64f563eae3e96e1977dd77e8d2039aed44a9 100644 (file)
@@ -24,6 +24,14 @@ sgen_libs = \
        $(monodir)/mono/utils/libmonoutils.la \
        $(GLIB_LIBS)
 
+if MOONLIGHT
+moon_libs = \
+       $(monodir)/mono/metadata/libmonoruntimemoon.la  \
+       $(monodir)/mono/io-layer/libwapi.la     \
+       $(monodir)/mono/utils/libmonoutils.la \
+       $(GLIB_LIBS)
+endif
+
 static_libs=   \
        $(monodir)/mono/metadata/libmonoruntime-static.la       \
        $(monodir)/mono/io-layer/libwapi.la     \
@@ -95,11 +103,25 @@ endif
 
 noinst_PROGRAMS = genmdesc
 
-lib_LTLIBRARIES = libmono-2.0.la $(sgen_libraries)
+if SHARED_MONO
+shared_libraries = libmono-2.0.la $(sgen_libraries)
+endif
+
+lib_LTLIBRARIES = $(shared_libraries)
 noinst_LTLIBRARIES = libmono-static.la $(sgen_static_libraries)
 
 if MOONLIGHT
 noinst_LTLIBRARIES += libmono-moon.la
+moon-do-build: $(BUILT_SOURCES) mono libmono-moon.la
+moon-do-clean: maintainer-clean-generic
+       -test -z "mono$(EXEEXT)" || rm -f mono$(EXEEXT)
+       -test -z "libmono-moon.la" || rm -f libmono-moon.la
+endif
+
+if LOADED_LLVM
+lib_LTLIBRARIES += libmono-llvm.la
+libmono_llvm_la_SOURCES = mini-llvm.c mini-llvm-cpp.cpp
+libmono_llvm_la_LIBADD = $(top_builddir)/mono/mini/libmono-$(API_VER).la $(LLVM_LIBS) $(LLVM_LDFLAGS) $(libs)
 endif
 
 endif
@@ -118,7 +140,7 @@ buildver.h: libmono-static.la
        @echo "const char *build_date = \"`date`\";" > buildver.h
 
 mono-main.$(OBJEXT): buildver.h
-mono-sgen-main.$(OBJEXT): buildver.h
+mono_sgen-main.$(OBJEXT): buildver.h
 
 if DTRACE_G_REQUIRED
 LIBMONO_DTRACE_OBJECT = .libs/mono-dtrace.$(OBJEXT)
@@ -142,13 +164,18 @@ MONO_LIB=libmono-2.0.la
 MONO_SGEN_LIB=libmonosgen-2.0.la
 endif
 
+if LOADED_LLVM
+LLVMMONOF=
+else
+LLVMMONOF=$(LLVM_LIBS) $(LLVM_LDFLAGS)
+endif
+
 mono_LDADD = \
        $(MONO_LIB)             \
        $(GLIB_LIBS)            \
-       $(LLVM_LIBS)            \
+       $(LLVMMONOF)            \
        -lm                     \
-       $(MONO_DTRACE_OBJECT)   \
-       $(LLVM_LDFLAGS)
+       $(MONO_DTRACE_OBJECT)
 
 mono_LDFLAGS = \
        $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags)
@@ -156,10 +183,9 @@ mono_LDFLAGS = \
 mono_sgen_LDADD = \
        $(MONO_SGEN_LIB)        \
        $(GLIB_LIBS)            \
-       $(LLVM_LIBS)            \
+       $(LLVMMONOF)            \
        -lm                     \
-       $(MONO_DTRACE_OBJECT)   \
-       $(LLVM_LDFLAGS)
+       $(MONO_DTRACE_OBJECT)
 
 mono_sgen_LDFLAGS = $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags)
 
@@ -269,10 +295,14 @@ posix_sources = \
        mini-posix.c
 
 if ENABLE_LLVM
+if LOADED_LLVM
+llvm_sources =
+else
 llvm_sources = \
        mini-llvm.c             \
        mini-llvm-cpp.cpp
 endif
+endif
 
 common_sources = \
        mini.c                  \
@@ -333,7 +363,9 @@ common_sources = \
        debugger-agent.c        \
        debug-debugger.c        \
        debug-debugger.h        \
-       xdebug.c
+       xdebug.c                        \
+       mini-llvm.h                     \
+       mini-llvm-cpp.h
 
 test_sources =                         \
        basic-calls.cs          \
@@ -355,18 +387,26 @@ test_sources =                    \
 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
 
 if X86
+if MONO_DEBUGGER_SUPPORTED
 if PLATFORM_DARWIN
 mdb_x86 = mdb-debug-info32-darwin.s
 else
 mdb_x86 = mdb-debug-info32.s
 endif
+else
+mdb_x86 = 
+endif
 arch_sources = $(x86_sources) $(mdb_x86)
 arch_built=cpu-x86.h
 arch_define=__i386__
 endif
 
 if AMD64
+if MONO_DEBUGGER_SUPPORTED
 arch_sources = $(amd64_sources) mdb-debug-info64.s
+else
+arch_sources = $(amd64_sources)
+endif
 arch_built=cpu-amd64.h
 arch_define=__x86_64__
 endif
@@ -457,28 +497,36 @@ monobin_platform_ldflags=-framework CoreFoundation
 endif
 
 libmono_2_0_la_SOURCES = $(common_sources) $(llvm_sources) $(arch_sources) $(os_sources)
-libmono_2_0_la_CFLAGS = $(AM_CFLAGS) $(BOEHM_DEFINES) $(LIBGC_CFLAGS)
+libmono_2_0_la_CFLAGS = $(mono_CFLAGS)
+libmono_2_0_la_LIBADD = $(libs) $(LIBMONO_DTRACE_OBJECT)
 
 libmonosgen_2_0_la_SOURCES = $(libmono_2_0_la_SOURCES)
-libmonosgen_2_0_la_CFLAGS = $(AM_CFLAGS) $(SGEN_DEFINES)
+libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS)
+libmonosgen_2_0_la_LIBADD = $(sgen_libs) $(LIBMONO_DTRACE_OBJECT)
 
 if MOONLIGHT
 libmono_moon_la_SOURCES = $(libmono_2_0_la_SOURCES)
-libmono_moon_la_CFLAGS = $(AM_CFLAGS) $(BOEHM_DEFINES) $(LIBGC_CFLAGS)
+if MOONLIGHT_BOEHM
+libmono_moon_la_CFLAGS = $(mono_CFLAGS) $(MOONLIGHT_DEFINES)
+libmono_moon_la_LIBADD = $(moon_libs) $(libgc_libs) $(LIBMONO_DTRACE_OBJECT)
+else
+libmono_moon_la_CFLAGS = $(mono_sgen_CFLAGS) $(MOONLIGHT_DEFINES)
+libmono_moon_la_LIBADD = $(moon_libs) $(LIBMONO_DTRACE_OBJECT)
+endif
 endif
 
 libmono_static_la_SOURCES = $(libmono_2_0_la_SOURCES)
-libmono_static_la_CFLAGS = $(AM_CFLAGS) $(BOEHM_DEFINES) $(LIBGC_CFLAGS)
+libmono_static_la_CFLAGS = $(mono_CFLAGS)
 libmono_static_la_LDFLAGS = -static
 libmono_static_la_LIBADD = $(static_libs) $(MONO_DTRACE_OBJECT)
 
 libmonosgen_static_la_SOURCES = $(libmono_2_0_la_SOURCES)
-libmonosgen_static_la_CFLAGS = $(AM_CFLAGS) $(SGEN_DEFINES)
+libmonosgen_static_la_CFLAGS = $(mono_sgen_CFLAGS)
 libmonosgen_static_la_LDFLAGS = -static
 libmonosgen_static_la_LIBADD = $(sgenstatic_libs) $(MONO_DTRACE_OBJECT)
 
 nodist_libmono_static_la_SOURCES = $(nodist_libmono_la_SOURCES)
-nodist_libmono_static_la_CFLAGS = $(AM_CFLAGS) $(BOEHM_DEFINES) $(LIBGC_CFLAGS)
+nodist_libmono_static_la_CFLAGS = $(mono_CFLAGS)
 
 BURGSRC= $(common_BURGSRC) $(arch_BURGSRC)
 
@@ -486,19 +534,12 @@ libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
 
 libmonoinclude_HEADERS = jit.h
 
-libmono_2_0_la_LIBADD = \
-       $(libs) $(LIBMONO_DTRACE_OBJECT)
-
-libmonosgen_2_0_la_LIBADD = \
-       $(sgen_libs) $(LIBMONO_DTRACE_OBJECT)
-
-if MOONLIGHT
-libmono_moon_la_LIBADD = $(libmono_2_0_la_LIBADD)
-endif
-
 basic-simd.exe: basic-simd.cs
        $(MCS) -out:$@ $< -r:TestDriver.dll -r:Mono.Simd.dll
 
+nacl.exe: nacl.cs
+       $(MCS) -out:$@ $< -r:TestDriver.dll -r:Mono.Simd.dll
+
 generics.exe: generics.cs TestDriver.dll generics-variant-types.dll
        $(MCS) -out:$@ $< -r:TestDriver.dll -r:generics-variant-types.dll
 
@@ -518,14 +559,20 @@ TestDriver.dll: $(srcdir)/TestDriver.cs
 generics-variant-types.dll: generics-variant-types.il
        $(ILASM) -dll -output=$@ $<
 
+if NACL_CODEGEN
+GENMDESC_OPTS=--nacl
+else !NACL_CODEGEN
+GENMDESC_OPTS=
+endif !NACL_CODEGEN
+
 # we don't always use the perl impl because it's an additional
 # build dependency for the poor windows users
 # $(arch_define) is the preprocessor symbol that enables all the opcodes
 # for the specific platform in mini-ops.h
 if CROSS_COMPILING
-GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir)
+GENMDESC_PRG=perl $(srcdir)/genmdesc.pl $(arch_define) $(srcdir) $(GENMDESC_OPTS)
 else !CROSS_COMPILING
-GENMDESC_PRG=./genmdesc
+GENMDESC_PRG=./genmdesc $(GENMDESC_OPTS)
 endif !CROSS_COMPILING
 
 cpu-x86.h: cpu-x86.md genmdesc$(EXEEXT)
@@ -574,21 +621,29 @@ checktests: $(regtests)
 rcheck: mono $(regtests)
        $(RUNTIME) --regression $(regtests)
 
+LLVM_AOT_RUNTIME_OPTS=$(if $(LLVM),--llvm,)
+
 aotcheck: mono $(regtests)
        rm -f *.exe.so
-       $(RUNTIME) --aot $(regtests) || exit 1
+       $(RUNTIME) $(LLVM_AOT_RUNTIME_OPTS) --aot $(regtests) || exit 1
        for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
        rm -f *.exe.so
 
+llvmaotcheck:
+       $(MAKE) aotcheck LLVM=1
+
 # This currently only works on amd64/arm
 fullaotcheck: mono $(regtests)
        rm -rf fullaot-tmp
        mkdir fullaot-tmp
        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/
        cp $(regtests) fullaot-tmp/
-       MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --aot=full fullaot-tmp/* || exit 1
+       MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper $(LLVM_AOT_RUNTIME_OPTS) --aot=full fullaot-tmp/* || exit 1
        for i in $(regtests); do echo $$i; MONO_PATH=fullaot-tmp $(top_builddir)/runtime/mono-wrapper --full-aot fullaot-tmp/$$i --exclude '!FULLAOT' || exit 1; done
 
+llvmfullaotcheck:
+       $(MAKE) fullaotcheck LLVM=1
+
 bench: mono test.exe
        time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
 
@@ -643,14 +698,12 @@ EXTRA_DIST = $(common_BURGSRC) TestDriver.cs ldscript ldscript.mono \
        $(posix_sources)
 
 version.h: Makefile
-       if test -d $(top_srcdir)/.git; then svn_info="git log --no-color --first-parent -n1 --grep=git-svn-id: --pretty=format:%b | sed -n -e 's,git-svn-id: \(.*\)@\(.*\) .*,URL: \1 Revision: \2,p'"; fi; \
-       if test -d $(srcdir)/.svn; then svn_info='svn info'; fi; \
-       if test -n "$$svn_info"; then \
+       if test -d $(top_srcdir)/.git; then \
                (cd $(top_srcdir); \
                        LANG=C; export LANG; \
-                       branch=`eval $$svn_info | sed -n -e '/URL/ s,.*source/\(.*\)/mono.*,/\1/mono,p'`; \
-                       version=`eval $$svn_info | sed -n -e '/Revision/ s/.*: //p'`; \
-                       echo "#define FULL_VERSION \"$$branch r$$version\""; \
+                       branch=`git branch | grep '^\*' | cut -d ' ' -f 2`; \
+                       version=`git log --no-color --first-parent -n1 --pretty=format:%h`; \
+                       echo "#define FULL_VERSION \"$$branch/$$version\""; \
                ); \
        else \
                echo "#define FULL_VERSION \"tarball\""; \