+#----------------------------------------
+# Prepare automake
+
+# We want to allow the user to override our default program-prefix,
+# so we must set-it now, before automake has a chance to interpret
+# it, but after the options are parsed, so as not to overwrite the
+# value (if any) set by the user
+AS_IF(
+ [test "$program_prefix" = NONE],
+ [program_prefix=kconfig-])
+
+AM_INIT_AUTOMAKE([foreign])
+
+# For releases, enable silent rules, unless the user explicitly
+# disables them.
+# For the devel tree, do build with verbose output, unless user
+# explicitly enables silent rules
+AS_IF(
+ [test "$(${srcdir}/scripts/version.sh --internal)" = "git"],
+ [AM_SILENT_RULES],
+ [AM_SILENT_RULES([yes])])
+
+AS_IF(
+ [test $AM_DEFAULT_VERBOSITY -eq 0],
+ [SILENT_MAKEFLAGS="--no-print-directory -s"],
+ [SILENT_MAKEFLAGS=""])
+AC_SUBST([SILENT_MAKEFLAGS])
+
+#----------------------------------------
+# Prepare libtool
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) dnl Automake, we have a problem...
+LT_PREREQ([2.2.6])
+LT_INIT([disable-static])
+
+#---------------------------------------------------------------------------
+# Set misc options
+
+# By default, do build with -Wall, unless the user asks not to
+[wall_CFLAGS=-Wall]
+AC_ARG_ENABLE(
+ [wall],
+ [AS_HELP_STRING(
+ [--disable-wall],
+ [build with -Wall (default=yes)])],
+ [AS_CASE(
+ ["$enableval"],
+ [yes], [wall_CFLAGS=-Wall],
+ [*], [wall_CFLAGS=""])])
+AC_SUBST([wall_CFLAGS],[${wall_CFLAGS}])
+
+# For releases, do not build with -Werror, unless the user explicitly
+# requests to build with -Werror.
+# For the devel tree, do build with -Werror by default, unless user
+# explicitly disables -Werror
+AS_IF(
+ [test "$(${srcdir}/scripts/version.sh --internal)" = "git"],
+ [werror_CFLAGS=-Werror])
+AC_ARG_ENABLE(
+ [werror],
+ [AS_HELP_STRING(
+ [--enable-werror],
+ [build with -Werror (default=no)])],
+ [AS_CASE(
+ ["$enableval"],
+ [yes], [werror_CFLAGS=-Werror],
+ [*], [werror_CFLAGS=""])])
+AC_SUBST([werror_CFLAGS],[${werror_CFLAGS}])
+
+# Although there is a default (="linux") in the code, we do provide
+# a default here, to get a consistent autostuff behavior
+AC_ARG_ENABLE(
+ [root-menu-prompt],
+ [AS_HELP_STRING(
+ [--enable-root-menu-prompt=PROMPT],
+ [set the root-menu prompt (default=Configuration)])],
+ [AS_CASE(
+ ["$enableval"],
+ [yes], [root_menu=Configuration],
+ [no], [root_menu=],
+ [# Escape the $ signs, otherwise they would get munged by make
+ root_menu="$( echo "$enableval" |sed -e 's/\$/\\$$/g;' )"])])
+AC_SUBST([root_menu], [${root_menu=Configuration}])
+
+AC_ARG_ENABLE(
+ [config-prefix],
+ [AS_HELP_STRING(
+ [--enable-config-prefix=PREFIX],
+ [the prefix to the config option (default=CONFIG_)])],
+ [AS_CASE(
+ ["$enableval"],
+ [*" "*],[AC_MSG_ERROR([config prefix can not contain spaces: '$enableval'])],
+ [yes], [config_prefix=CONFIG_],
+ [no], [config_prefix=],
+ [config_prefix=$enableval])])
+AC_SUBST([config_prefix], [${config_prefix-CONFIG_}])