Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mono / mini / Makefile.am
index 22d614a1ceb53940e97d67f889894dbf456c889a..f4e6a71804e9417ee4bd9015c00ece2a761d9c31 100644 (file)
@@ -5,8 +5,10 @@ monodir=$(top_builddir)
 # This is needed for automake dependency generation
 if INCLUDED_LIBGC
 libgc_libs=$(monodir)/libgc/libmonogc.la
+libgc_static_libs=$(monodir)/libgc/libmonogc-static.la
 else
 libgc_libs=$(LIBGC_LIBS)
+libgc_static_libs=$(LIBGC_STATIC_LIBS)
 endif
 
 libs=  \
@@ -30,6 +32,19 @@ moon_libs = \
        $(GLIB_LIBS) $(LIBICONV)
 endif
 
+static_libs=   \
+       $(monodir)/mono/metadata/libmonoruntime-static.la       \
+       $(monodir)/mono/io-layer/libwapi.la     \
+       $(monodir)/mono/utils/libmonoutils.la \
+       $(GLIB_LIBS) $(LIBICONV) \
+       $(libgc_static_libs)
+
+sgenstatic_libs = \
+       $(monodir)/mono/metadata/libmonoruntimesgen-static.la   \
+       $(monodir)/mono/io-layer/libwapi.la     \
+       $(monodir)/mono/utils/libmonoutils.la \
+       $(GLIB_LIBS) $(LIBICONV)
+
 CLASS=$(mcs_topdir)/class/lib/net_4_5
 
 RUNTIME_EXECUTABLE = $(if $(SGEN),$(top_builddir)/mono/mini/mono-sgen,$(top_builddir)/runtime/mono-wrapper)
@@ -77,27 +92,47 @@ if JIT_SUPPORTED
 if SUPPORT_SGEN
 sgen_binaries = mono-sgen
 sgen_libraries = libmonosgen-2.0.la
+sgen_static_libraries = libmini-static.la $(sgenstatic_libs)
 endif
 
 if SUPPORT_BOEHM
-boehm_binaries  = mono
 boehm_libraries = libmono-2.0.la
+boehm_static_libraries = libmini-static.la $(static_libs)
+boehm_binaries  = mono
 endif
 
+if DISABLE_EXECUTABLES
+else
 if HOST_WIN32
 bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) monow
 else
 bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries)
 endif
+endif
 
 noinst_PROGRAMS = genmdesc
 
+if DISABLE_EXECUTABLES
+shared_libraries = $(boehm_libraries) $(sgen_libraries)
+else
 if SHARED_MONO
 shared_libraries = $(boehm_libraries) $(sgen_libraries)
 endif
+endif
 
 lib_LTLIBRARIES = $(shared_libraries)
-noinst_LTLIBRARIES =
+
+if SHARED_MONO
+mini_common_lib = libmini.la
+else
+mini_common_lib = 
+endif
+
+if DISABLE_EXECUTABLES
+noinst_LTLIBRARIES = $(mini_common_lib)
+else
+noinst_LTLIBRARIES = $(mini_common_lib) libmini-static.la
+endif
 
 if MOONLIGHT
 noinst_LTLIBRARIES += libmono-moon.la
@@ -112,7 +147,7 @@ lib_LTLIBRARIES += libmono-llvm.la
 libmono_llvm_la_SOURCES = mini-llvm.c mini-llvm-cpp.cpp
 libmono_llvm_la_LIBADD = $(LLVM_LIBS) $(LLVM_LDFLAGS)
 if PLATFORM_DARWIN
-libmono_llvm_la_LDFLAGS=-undefined suppress
+libmono_llvm_la_LDFLAGS=-Wl,-undefined -Wl,suppress -Wl,-flat_namespace
 else
 libmono_llvm_la_LIBADD += $(top_builddir)/mono/mini/libmono-$(API_VER).la $(libs)
 endif
@@ -123,22 +158,22 @@ endif
 mono_SOURCES = \
        main.c
 
-mono_CFLAGS = $(AM_CFLAGS) $(BOEHM_DEFINES)
+mono_CFLAGS = $(AM_CFLAGS)
 
-INCLUDES = $(LIBGC_CPPFLAGS)
+AM_CPPFLAGS = $(LIBGC_CPPFLAGS)
 
 mono_sgen_SOURCES = $(mono_SOURCES)
-mono_sgen_CFLAGS = $(SGEN_DEFINES) $(AM_CFLAGS)
+mono_sgen_CFLAGS = $(AM_CFLAGS)
 
 # We build this after libmono was built so it contains the date when the final
 # link was done
 if SUPPORT_BOEHM
-buildver.h: libmono-2.0.la
+buildver.h: libmini-static.la
        @echo "const char *build_date = \"`date`\";" > buildver.h
 mono-main.$(OBJEXT): buildver.h
 endif
 
-buildver-sgen.h: libmonosgen-2.0.la
+buildver-sgen.h: libmini-static.la
        @echo "const char *build_date = \"`date`\";" > buildver-sgen.h
 mono_sgen-main.$(OBJEXT): buildver-sgen.h
 
@@ -157,11 +192,12 @@ endif
 if STATIC_MONO
 # Link libmono into mono statically
 # This leads to higher performance, especially with TLS
-static_flags=-static
-endif
-
+MONO_LIB=$(boehm_static_libraries)
+MONO_SGEN_LIB=$(sgen_static_libraries)
+else 
 MONO_LIB=libmono-2.0.la
 MONO_SGEN_LIB=libmonosgen-2.0.la
+endif
 
 if LOADED_LLVM
 LLVMMONOF=
@@ -385,7 +421,8 @@ test_sources =                      \
        generics.cs             \
        generics-variant-types.il\
        basic-simd.cs \
-       aot-tests.cs
+       aot-tests.cs \
+       gc-test.cs
 
 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
 
@@ -499,16 +536,23 @@ os_sources = $(darwin_sources) $(posix_sources)
 monobin_platform_ldflags=-framework CoreFoundation
 endif
 
-libmono_2_0_la_SOURCES = $(common_sources) $(llvm_sources) $(arch_sources) $(os_sources)
+libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(arch_sources) $(os_sources)
+libmini_la_CFLAGS = $(mono_CFLAGS)
+
+libmono_2_0_la_SOURCES =
 libmono_2_0_la_CFLAGS = $(mono_CFLAGS)
-libmono_2_0_la_LIBADD = $(libs) $(LIBMONO_DTRACE_OBJECT)
+libmono_2_0_la_LIBADD = libmini.la $(libs) $(LIBMONO_DTRACE_OBJECT)
 
-libmonosgen_2_0_la_SOURCES = $(libmono_2_0_la_SOURCES)
+libmonosgen_2_0_la_SOURCES =
 libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS)
-libmonosgen_2_0_la_LIBADD = $(sgen_libs) $(LIBMONO_DTRACE_OBJECT)
+libmonosgen_2_0_la_LIBADD = libmini.la $(sgen_libs) $(LIBMONO_DTRACE_OBJECT)
+
+if PLATFORM_ANDROID
+libmonosgen_2_0_la_LDFLAGS = -avoid-version
+endif
 
 if MOONLIGHT
-libmono_moon_la_SOURCES = $(libmono_2_0_la_SOURCES)
+libmono_moon_la_SOURCES = $(libmini_la_SOURCES)
 if MOONLIGHT_BOEHM
 libmono_moon_la_CFLAGS = $(mono_CFLAGS) $(MOONLIGHT_DEFINES)
 libmono_moon_la_LIBADD = $(moon_libs) $(libgc_libs) $(LIBMONO_DTRACE_OBJECT)
@@ -518,6 +562,15 @@ libmono_moon_la_LIBADD = $(moon_libs) $(LIBMONO_DTRACE_OBJECT)
 endif
 endif
 
+#
+# This library is shared between mono and mono-sgen, since the code in mini/ doesn't contain
+# compile time dependencies on boehm/sgen.
+#
+libmini_static_la_SOURCES = $(libmini_la_SOURCES)
+libmini_static_la_CFLAGS = $(AM_CFLAGS)
+libmini_static_la_LDFLAGS = -static
+libmini_static_la_LIBADD = $(MONO_DTRACE_OBJECT)
+
 libmonoincludedir = $(includedir)/mono-$(API_VER)/mono/jit
 
 libmonoinclude_HEADERS = jit.h
@@ -611,13 +664,16 @@ checktests: $(regtests)
 rcheck: mono $(regtests)
        $(RUNTIME) --regression $(regtests)
 
+gctest: mono gc-test.exe
+       MONO_DEBUG_OPTIONS=clear-nursery-at-gc $(RUNTIME) --regression gc-test.exe
+
 LLVM_AOT_RUNTIME_OPTS=$(if $(LLVM),--llvm,)
 
 aotcheck: mono $(regtests)
-       rm -f *.exe.so
+       rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
        $(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
+       rm -rf *.exe.so *.exe.dylib *.exe.dylib.dSYM
 
 llvmaotcheck:
        $(MAKE) aotcheck LLVM=1
@@ -637,6 +693,9 @@ fullaotcheck: mono $(fullaot_regtests)
 llvmfullaotcheck:
        $(MAKE) fullaotcheck LLVM=1
 
+gccheck: gc-test.exe
+       MONO_GC_PARAMS=stack-mark=precise MONO_GC_DEBUG=clear-at-gc ./mono-sgen gc-test.exe     
+
 bench: mono test.exe
        time env $(RUNTIME) --ncompile $(count) --compile Test:$(mtest) test.exe
 
@@ -707,5 +766,9 @@ patch-libtool:
        sed -e 's,if (for obj in $$oldobjs,if (for obj in "",g' < ../../libtool > 2; mv 2 ../../libtool
        chmod a+x ../../libtool
 
+# Utility target to patch automake to generate the same format silent output as the old mono silent build did
+patch-automake:
+       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
+
 tags:
        etags -o TAGS `find .. -name "*.h" -o -name "*.c"`