+csc_compiler=default
+endian=unknown
+AC_C_BIGENDIAN([endian=big],[endian=little],[endian=unknown])
+AC_MSG_CHECKING([CSharp compiler to use])
+AC_ARG_WITH(csc, [ --with-csc=mcs,roslyn,default Configures the CSharp compiler to use],[
+ if test x$withval = xmcs; then
+ csc_compiler=mcs
+ elif test x$withval = xroslyn; then
+ csc_compiler=roslyn
+ elif test x$withval = xdefault; then
+ :
+ else
+ AC_MSG_ERROR([You must supply one of "mcs", "roslyn" or "default" to the --with-csc option])
+ fi
+],[csc_compiler=default])
+
+if test $csc_compiler = default; then
+ if test $endian = big; then
+ csc_compiler=mcs
+ elif test $endian = little; then
+ csc_compiler=roslyn
+ else
+ csc_compiler=mcs
+ fi
+fi
+AC_MSG_RESULT($csc_compiler)
+
+#
+# Set the build profiles and options before things which use them
+#
+
+AC_ARG_WITH(profile4_x, [ --with-profile4_x=yes,no If you want to install the 4.x FX (defaults to yes)], [], [with_profile4_x=default])
+AC_ARG_WITH(monodroid, [ --with-monodroid=yes,no If you want to build the MonoDroid assemblies (defaults to no)], [], [with_monodroid=default])
+AC_ARG_WITH(monotouch, [ --with-monotouch=yes,no If you want to build the Xamarin.iOS assemblies (defaults to no)], [], [with_monotouch=default])
+AC_ARG_WITH(monotouch_watch, [ --with-monotouch_watch=yes,no If you want to build the Xamarin.WatchOS assemblies (defaults to no)],[], [with_monotouch_watch=default])
+AC_ARG_WITH(monotouch_tv, [ --with-monotouch_tv=yes,no If you want to build the Xamarin.TVOS assemblies (defaults to no)], [], [with_monotouch_tv=default])
+AC_ARG_WITH(bitcode, [ --with-bitcode=yes,no If bitcode is enabled (defaults to no)], [], [with_bitcode=default])
+AC_ARG_WITH(xammac, [ --with-xammac=yes,no If you want to build the Xamarin.Mac assemblies (defaults to no)], [], [with_xammac=default])
+AC_ARG_WITH(aot_hybrid, [ --with-aot_hybrid=yes,no If you want to build the aot_hybrid assemblies (defaults to no)], [], [with_aot_hybrid=default])
+AC_ARG_WITH(aot_only, [ --with-aot_only=yes,no If you want to build the aot_only assemblies (defaults to no)], [], [with_aot_only=default])
+
+AC_ARG_WITH(runtime_preset, [ --with-runtime_preset=net_4_x,all,aot,hybridaot,fullaot,bitcode Which default profile to build (defaults to net_4_x)], [], [with_runtime_preset=net_4_x])
+
+dnl
+dnl Profile defaults
+dnl
+TEST_PROFILE=default
+enable_llvm_default=no
+
+with_profile4_x_default=no
+with_monodroid_default=no
+with_monotouch_default=no
+with_monotouch_watch_default=no
+with_monotouch_tv_default=no
+with_xammac_default=no
+with_aot_hybrid_default=no
+with_aot_only_default=no
+
+with_bitcode_default=no
+with_cooperative_gc_default=no
+
+INVARIANT_AOT_OPTIONS=nimt-trampolines=2000,ntrampolines=8000,nrgctx-fetch-trampolines=256,ngsharedvt-trampolines=4000
+
+if test x$cross_compiling = xyes -o x$enable_mcs_build = xno; then
+ DISABLE_MCS_DOCS_default=yes
+elif test x$with_runtime_preset = xnet_4_x; then
+ with_profile4_x_default=yes
+elif test x$with_runtime_preset = xall; then
+ with_profile4_x_default=yes
+ with_monodroid_default=yes
+ with_monotouch_default=yes
+ with_monotouch_watch_default=yes
+ with_monotouch_tv_default=yes
+ with_xammac_default=yes
+elif test x$with_runtime_preset = xfullaot; then
+ DISABLE_MCS_DOCS_default=yes
+ with_aot_only_default=yes
+ TEST_PROFILE=aot_only
+
+ mono_feature_disable_com='yes'
+ mono_feature_disable_remoting='yes'
+ mono_feature_disable_reflection_emit_save='yes'
+ mono_feature_disable_reflection_emit='yes'
+ mono_feature_disable_appdomains='yes'
+
+ AOT_BUILD_FLAGS="-O=gsharedvt --aot=full,$INVARIANT_AOT_OPTIONS"
+ AOT_RUN_FLAGS="--full-aot"
+elif test x$with_runtime_preset = xbitcode; then
+ DISABLE_MCS_DOCS_default=yes
+ with_aot_only_default=yes
+ with_bitcode_default=yes
+ with_cooperative_gc_default=yes
+ TEST_PROFILE=aot_only
+ enable_llvm_default=yes
+
+ mono_feature_disable_com='yes'
+ mono_feature_disable_remoting='yes'
+ mono_feature_disable_reflection_emit_save='yes'
+ mono_feature_disable_reflection_emit='yes'
+ mono_feature_disable_appdomains='yes'
+
+ AOT_BUILD_FLAGS="--aot=llvmonly,$INVARIANT_AOT_OPTIONS"
+ AOT_RUN_FLAGS="--llvmonly"
+elif test x$with_runtime_preset = xhybridaot; then
+ DISABLE_MCS_DOCS_default=yes
+ with_aot_hybrid_default=yes
+ TEST_PROFILE=aot_hybrid
+
+ mono_feature_disable_com='yes'
+ mono_feature_disable_remoting='yes'
+ mono_feature_disable_appdomains='yes'
+
+ AOT_BUILD_FLAGS="--aot=hybrid,$INVARIANT_AOT_OPTIONS"
+ AOT_RUN_FLAGS="--hybrid-aot"
+elif test x$with_runtime_preset = xaot; then
+ with_profile4_x_default=yes
+
+ AOT_BUILD_FLAGS="--aot=$INVARIANT_AOT_OPTIONS"
+ AOT_RUN_FLAGS=""
+
+ DISABLE_MCS_DOCS_default=yes
+else
+ with_profile4_x_default=yes
+fi
+
+if test "x$AOT_BUILD_FLAGS" != "x"; then :
+ AC_SUBST(AOT_BUILD_FLAGS)
+ AC_SUBST(AOT_RUN_FLAGS)
+ # For llvmonlycheck + fullaotcheck
+ AC_SUBST(INVARIANT_AOT_OPTIONS)
+fi
+
+AC_SUBST(TEST_PROFILE)
+
+if test "x$with_profile4_x" = "xdefault"; then
+ with_profile4_x=$with_profile4_x_default
+fi
+if test "x$with_monodroid" = "xdefault"; then
+ with_monodroid=$with_monodroid_default
+fi
+if test "x$with_monotouch" = "xdefault"; then
+ with_monotouch=$with_monotouch_default
+fi
+if test "x$with_monotouch_watch" = "xdefault"; then
+ with_monotouch_watch=$with_monotouch_watch_default
+fi
+if test "x$with_monotouch_tv" = "xdefault"; then
+ with_monotouch_tv=$with_monotouch_tv_default
+fi
+if test "x$with_bitcode" = "xdefault"; then
+ with_bitcode=$with_bitcode_default
+fi
+if test "x$with_xammac" = "xdefault"; then
+ with_xammac=$with_xammac_default
+fi
+if test "x$with_aot_hybrid" = "xdefault"; then
+ with_aot_hybrid=$with_aot_hybrid_default
+fi
+if test "x$with_aot_only" = "xdefault"; then
+ with_aot_only=$with_aot_only_default
+fi
+
+AM_CONDITIONAL(INSTALL_4_x, [test "x$with_profile4_x" = "xyes"])
+AM_CONDITIONAL(INSTALL_MONODROID, [test "x$with_monodroid" != "xno"])
+AM_CONDITIONAL(INSTALL_MONOTOUCH, [test "x$with_monotouch" != "xno"])
+AM_CONDITIONAL(INSTALL_MONOTOUCH_WATCH, [test "x$with_monotouch_watch" != "xno"])
+AM_CONDITIONAL(INSTALL_MONOTOUCH_TV, [test "x$with_monotouch_tv" != "xno"])
+AM_CONDITIONAL(BITCODE, test "x$with_bitcode" = "xyes")
+AM_CONDITIONAL(INSTALL_XAMMAC, [test "x$with_xammac" != "xno"])
+AM_CONDITIONAL(INSTALL_AOT_HYBRID, [test "x$with_aot_hybrid" != "xno"])
+AM_CONDITIONAL(INSTALL_AOT_ONLY, [test "x$with_aot_only" != "xno"])
+
+AC_SUBST(INSTALL_AOT_HYBRID)
+AC_SUBST(INSTALL_AOT_ONLY)
+
+default_profile=net_4_x
+if test -z "$INSTALL_MONODROID_TRUE"; then :
+ default_profile=monodroid
+fi
+if test -z "$INSTALL_MONOTOUCH_TRUE"; then :
+ default_profile=monotouch
+fi
+if test -z "$INSTALL_XAMMAC_TRUE"; then :
+ default_profile=xammac
+fi
+if test -z "$INSTALL_AOT_HYBRID_TRUE"; then :
+ default_profile=aot_hybrid
+fi
+if test -z "$INSTALL_AOT_ONLY_TRUE"; then :
+ default_profile=aot_only
+fi
+if test -z "$INSTALL_4_x_TRUE"; then :
+ default_profile=net_4_x
+fi
+DEFAULT_PROFILE=$default_profile
+AC_SUBST(DEFAULT_PROFILE)
+
+#
+# End build profile configuration
+#
+
+if test x$USE_NLS = xprofile_default; then
+
+if test x$host_darwin = xyes; then
+# We make the default value for USE_NLS
+# "no" on OSX because it isn't available on most
+# default OSX installs. The most common configurations will
+# all disable it, so this saves us typing.
+ USE_NLS=no
+ AC_SUBST([USE_NLS])
+ AC_MSG_RESULT([$USE_NLS])
+else
+ USE_NLS=yes
+ AC_SUBST([USE_NLS])
+ AC_MSG_RESULT([$USE_NLS])
+fi
+
+fi