+#----------------------------------------
+# Prepare automake
+
+AM_INIT_AUTOMAKE([foreign subdir-objects])
+
+# 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])])
+
+#----------------------------------------
+# 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_}])
+
+AC_ARG_ENABLE(
+ [utils],
+ [AS_HELP_STRING(
+ [--disable-utils],
+ [install utilities to manage .config files (default=yes)])])
+AC_SUBST([enable_utils], [${enable_utils:-yes}])
+
+AC_ARG_ENABLE(
+ [L10n],
+ [AS_HELP_STRING(
+ [--disable-L10n],
+ [enable localisation (L10n) (default=auto)])])
+AC_SUBST([enable_L10n], [${enable_L10n:-yes}])
+
+#----------------------------------------
+# Options to selectively enable/disable frontends
+# All are selected by default
+AC_ARG_ENABLE(
+ [kconfig],
+ [AS_HELP_STRING(
+ [--disable-kconfig],
+ [kconfig, the meta-frontend to all kconfig tools (default=yes)])])
+AC_SUBST([enable_kconfig], [${enable_kconfig:-yes}])
+
+AC_ARG_ENABLE(
+ [conf],
+ [AS_HELP_STRING(
+ [--disable-conf],
+ [conf, the stdin-based frontend (default=auto)])])
+AC_SUBST([enable_conf], [${enable_conf:-auto}])
+AC_ARG_ENABLE(
+ [mconf],
+ [AS_HELP_STRING(
+ [--disable-mconf],
+ [mconf, the traditional ncurses-based frontend (default=auto)])])
+AC_SUBST([enable_mconf], [${enable_mconf:-auto}])
+AC_ARG_ENABLE(
+ [nconf],
+ [AS_HELP_STRING(
+ [--disable-nconf],
+ [nconf, the modern ncurses-based frontend (default=auto)])])
+AC_SUBST([enable_nconf], [${enable_nconf:-auto}])
+AC_ARG_ENABLE(
+ [gconf],
+ [AS_HELP_STRING(
+ [--disable-gconf],
+ [gconf, the GTK-based frontend (default=auto)])])
+AC_SUBST([enable_gconf], [${enable_gconf:-auto}])
+AC_ARG_ENABLE(
+ [qconf],
+ [AS_HELP_STRING(
+ [--disable-qconf],
+ [qconf, the QT-based frontend (default=auto)])])
+AC_SUBST([enable_qconf], [${enable_qconf:-auto}])