Blame configure

66a30d
#!/bin/sh
66a30d
147ce1
set -eu
147ce1
090216
trap config_failure 1 2 EXIT
090216
b4ba5b
# before we begin...
b4ba5b
mb_path="$PATH"
835f23
mb_script="$0"
835f23
mb_success=no
b4ba5b
66a30d
usage()
66a30d
{
66a30d
	cat "$mb_project_dir"/config.usage
ebbba6
6dc107
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
ebbba6
		printf '\n\n%s%s\n' \
ebbba6
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
ebbba6
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
ebbba6
ebbba6
		printf '%s%s\n' \
ebbba6
			"| Listed above are configure's common switches " \
ebbba6
			"and environment variables.     |"
ebbba6
ebbba6
		printf '%s%s\n' \
ebbba6
			"| Found below are project-specific variables " \
ebbba6
			"and other customization options. |"
ebbba6
ebbba6
		printf '%s%s\n\n\n' \
ebbba6
			" ___________________________________________" \
ebbba6
			"__________________________________"
ebbba6
ebbba6
		cat "$mb_project_dir"/project/config/cfgdefs.usage
ebbba6
	fi
ebbba6
ebbba6
	exit 0
66a30d
}
66a30d
66a30d
error_msg()
66a30d
{
66a30d
	echo "$@" >&2
66a30d
}
66a30d
66a30d
warning_msg()
66a30d
{
66a30d
	echo "$@" >&2
66a30d
}
66a30d
66a30d
66a30d
init_vars()
66a30d
{
7b203e
	mb_project_dir=$(cd "$(dirname "$mb_script")" ; pwd -P)
7b203e
	mb_pwd=$(pwd -P)
66a30d
c4ed3b
	mb_custom_cfgdefs_args=''
c4ed3b
	mb_custom_cfgdefs_space=''
c4ed3b
cd2145
	sfrt_impl_dir=$mb_project_dir/sofort
cd2145
	sfrt_config_dir=$sfrt_impl_dir/config
cd2145
	sfrt_core_dir=$sfrt_impl_dir/core
cd2145
	sfrt_config_vars=$sfrt_config_dir/config.vars
cd2145
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
cd2145
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
cd2145
cd2145
	mb_make_vars=$(cat $sfrt_config_vars \
553940
		| grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
11c7b5
cd2145
	mb_impl_vars=$(cat $sfrt_config_vars \
553940
		| grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
553940
cd2145
	mb_proj_vars=$(cat $sfrt_config_vars \
553940
		| grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
553940
cd2145
	mb_flag_vars=$(cat $sfrt_flag_vars \
553940
		| grep -v -e '^#' -e '^$')
553940
553940
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
553940
22f410
	for mb_var in $(printf "$mb_vars") ; do
11c7b5
		mb_expr=$mb_var='${'$mb_var':-}'
11c7b5
		eval "$mb_expr"
11c7b5
	done
11c7b5
7e34aa
	# ccenv
7e34aa
	. $mb_project_dir/sofort/ccenv/ccenv.sh
7e34aa
cba45e
	if ! [ -L ./ccenv ]; then
7e34aa
		if [ -d ./ccenv ]; then
7e34aa
			rm -f ./ccenv/host.mk
7e34aa
			rm -f ./ccenv/native.mk
7e34aa
			rmdir ./ccenv
7e34aa
		fi
7e34aa
	fi
7e34aa
7e34aa
	# config.project
66a30d
	if [ -z "$mb_config" ]; then
b988f8
		. $mb_project_dir/config.project
66a30d
	else
b988f8
		. "$mb_config"
66a30d
	fi
66a30d
aa4d91
	# project-specific config definitions
6dc107
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
cd2145
		cat $sfrt_cfgdefs_in > cfgdefs.mk
8d9cb1
	else
8d9cb1
		printf '%s %s\n\n' \
8d9cb1
				'# this project does not include' \
8d9cb1
				'a custom config step.'           \
8d9cb1
			> cfgdefs.mk
cd2145
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
ba0bcd
ba0bcd
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
ba0bcd
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
ba0bcd
		fi
aa4d91
	fi
aa4d91
aa4d91
	# user build-time overrides
8d9cb1
	touch usrdefs.mk
aa4d91
66a30d
	# project
66a30d
	mb_nickname=$NICKNAME
66a30d
	mb_source_dir=$SOURCE_DIR
66a30d
66a30d
	# dirs
66a30d
	mb_prefix=$PREFIX
66a30d
	mb_exec_prefix=$EXEC_PREFIX
66a30d
	mb_bindir=$BINDIR
66a30d
	mb_sbindir=$SBINDIR
66a30d
	mb_libdir=$LIBDIR
66a30d
	mb_includedir=$INCLUDEDIR
66a30d
	mb_oldincludedir=$OLDINCLUDEDIR
66a30d
	mb_mandir=$MANDIR
66a30d
	mb_docdir=$DOCDIR
66a30d
	mb_libexecdir=$LIBEXECDIR
66a30d
66a30d
	mb_sysconfdir=$SYSCONFDIR
66a30d
	mb_sharedstatedir=$SHAREDSTATEDIR
66a30d
	mb_localstatedir=$LOCALSTATEDIR
66a30d
	mb_runstatedir=$RUNSTATEDIR
66a30d
	mb_datarootdir=$DATAROOTDIR
66a30d
	mb_datadir=$DATADIR
66a30d
	mb_infodir=$INFODIR
66a30d
	mb_localedir=$LOCALEDIR
66a30d
	mb_htmldir=$HTMLDIR
66a30d
	mb_dvidir=$DVIDIR
66a30d
	mb_pdfdir=$PDFDIR
66a30d
	mb_psdir=$PSDIR
66a30d
66a30d
66a30d
	# build
66a30d
	mb_build=$BUILD
66a30d
	mb_cchost=$CCHOST
f6645d
	mb_cfghost=$CFGHOST
66a30d
	mb_arch=$ARCH
66a30d
	mb_compiler=$COMPILER
66a30d
	mb_toolchain=$TOOLCHAIN
66a30d
	mb_sysroot=$SYSROOT
66a30d
	mb_cross_compile=$CROSS_COMPILE
66a30d
	mb_shell=$SHELL
66a30d
66a30d
	# switches
66a30d
	mb_cflags=$CFLAGS
66a30d
	mb_cflags_debug=$CFLAGS_DEBUG
66a30d
	mb_cflags_common=$CFLAGS_COMMON
66a30d
	mb_cflags_cmdline=$CFLAGS_CMDLINE
66a30d
	mb_cflags_config=$CFLAGS_CONFIG
66a30d
	mb_cflags_sysroot=$CFLAGS_SYSROOT
66a30d
	mb_cflags_os=$CFLAGS_OS
66a30d
	mb_cflags_site=$CFLAGS_SITE
66a30d
	mb_cflags_path=$CFLAGS_PATH
66a30d
	mb_cflags_strict=$CFLAGS_STRICT
66a30d
	mb_cflags_util=$CFLAGS_UTIL
66a30d
	mb_cflags_last=$CFLAGS_LAST
66a30d
	mb_cflags_once=$CFLAGS_ONCE
66a30d
66a30d
	mb_ldflags=$LDFLAGS
66a30d
	mb_ldflags_debug=$LDFLAGS_DEBUG
66a30d
	mb_ldflags_common=$LDFLAGS_COMMON
66a30d
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
66a30d
	mb_ldflags_config=$LDFLAGS_CONFIG
66a30d
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
66a30d
	mb_ldflags_path=$LDFLAGS_PATH
66a30d
	mb_ldflags_strict=$LDFLAGS_STRICT
66a30d
	mb_ldflags_util=$LDFLAGS_UTIL
66a30d
	mb_ldflags_last=$LDFLAGS_LAST
66a30d
	mb_ldflags_once=$LDFLAGS_ONCE
66a30d
66a30d
	mb_pe_subsystem=$PE_SUBSYSTEM
66a30d
	mb_pe_image_base=$PE_IMAGE_BASE
66a30d
66a30d
	# overrides
66a30d
	mb_user_cc=$CC
66a30d
	mb_user_cpp=$CPP
66a30d
	mb_user_cxx=$CXX
7e34aa
7e34aa
	mb_native_cc=$NATIVE_CC
7e34aa
	mb_native_cpp=$NATIVE_CPP
7e34aa
	mb_native_cxx=$NATIVE_CXX
7e34aa
7e34aa
	mb_native_host=$NATIVE_HOST
7e34aa
	mb_native_cfghost=$NATIVE_CFGHOST
7e34aa
	mb_native_cflags=$NATIVE_CFLAGS
7e34aa
	mb_native_ldflags=$NATIVE_LDFLAGS
b39a10
b39a10
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
b39a10
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
66a30d
}
66a30d
66a30d
66a30d
verify_build_directory()
66a30d
{
66a30d
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
6dc107
		if [ _$mb_require_out_of_tree = _yes ]; then
66a30d
			error_msg "$mb_package: out-of-tree builds are required."
66a30d
			error_msg "please invoke configure again from a clean build directory."
b988f8
			exit 1
66a30d
		else
66a30d
			mb_project_dir='.'
66a30d
		fi
66a30d
	fi
090216
090216
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
66a30d
}
66a30d
66a30d
66a30d
verify_source_directory()
66a30d
{
66a30d
	if [ -z "$mb_source_dir" ]; then
6dc107
		if [ _$mb_require_source_dir = _yes ]; then
66a30d
			error_msg "$mb_package: specifying an external source directory is required."
66a30d
			error_msg "you can set the source directory either via --source-dir=<path>,"
66a30d
			error_msg "or by setting the SOURCE_DIR variable."
b988f8
			exit 1
66a30d
		fi
66a30d
	fi
66a30d
}
66a30d
66a30d
66a30d
common_defaults()
66a30d
{
66a30d
	# git
66a30d
	if [ -n "$mb_source_dir" ]; then
66a30d
		if [ -d "$mb_source_dir/.git" ]; then
66a30d
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
66a30d
		fi
66a30d
	elif [ -d "$mb_project_dir/.git" ]; then
66a30d
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
66a30d
	fi
66a30d
66a30d
	# project
c4c457
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
c4c457
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
c4c457
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
66a30d
66a30d
	# pkgconfig
c4c457
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
c4c457
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
c4c457
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
c4c457
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
c4c457
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
c4c457
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
c4c457
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
c4c457
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
66a30d
66a30d
	# dirs
c4c457
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
c4c457
					|| mb_prefix='/usr/local'
c4c457
c4c457
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
c4c457
					|| mb_exec_prefix=$mb_prefix
c4c457
c4c457
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
c4c457
					|| [ -n "$mb_bindir_basename" ] \
c4c457
					|| mb_bindir=$mb_exec_prefix/bin
c4c457
c4c457
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
c4c457
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
c4c457
c4c457
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
c4c457
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
c4c457
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
c4c457
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
c4c457
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
c4c457
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
c4c457
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc
c4c457
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
c4c457
c4c457
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
c4c457
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
c4c457
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
c4c457
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
c4c457
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
c4c457
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
c4c457
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
c4c457
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
c4c457
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
c4c457
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
c4c457
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
c4c457
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
66a30d
66a30d
	# switches
c4c457
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
c4c457
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
c4c457
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
c4c457
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
c4c457
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
c4c457
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
c4c457
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
c4c457
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
c4c457
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
c4c457
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
c4c457
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
c4c457
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
c4c457
c4c457
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
c4c457
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
c4c457
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
c4c457
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
c4c457
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
c4c457
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
c4c457
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
c4c457
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
c4c457
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
c4c457
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
66a30d
4b14d5
	# native switches
c4c457
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
c4c457
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
4b14d5
66a30d
	# config
c4c457
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
c4c457
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
c4c457
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
c4c457
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
c4c457
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
66a30d
66a30d
	# host/target
c4c457
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
c4c457
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
66a30d
66a30d
	# sysroot
66a30d
	if [ -n "$mb_sysroot" ]; then
66a30d
		if [ -z "$mb_cflags_sysroot" ]; then
66a30d
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
66a30d
		fi
66a30d
66a30d
		if [ -z "$mb_ldflags_sysroot" ]; then
66a30d
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
66a30d
		fi
66a30d
	fi
66a30d
66a30d
	# debug
6dc107
	if [ _$mb_debug = _yes ]; then
66a30d
		if [ -z "$mb_cflags_debug" ]; then
66a30d
			mb_cflags_debug='-g3 -O0'
66a30d
		fi
66a30d
	fi
69bae7
0c76e6
	# shell
0c76e6
	if [ -z "$mb_shell" ]; then
0c76e6
		mb_shell='/bin/sh'
0c76e6
	fi
0c76e6
69bae7
	# inherited cflags & ldflags
69bae7
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
69bae7
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
66a30d
}
66a30d
66a30d
66a30d
config_flags()
66a30d
{
66a30d
	mb_ldflags_tmp=" $mb_ldflags "
6aecf4
	mb_ldflags_libs=$(echo "$mb_ldflags_tmp" | sed 's/ -static / /g')
66a30d
66a30d
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
66a30d
		mb_ldflags="$mb_ldflags_libs"
66a30d
		mb_ldflags_util="$mb_ldflags_util -static"
66a30d
	fi
66a30d
66a30d
	# ccstrict
6dc107
	if [ _$mb_ccstrict = _yes ]; then
66a30d
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
66a30d
	fi
66a30d
66a30d
	# ldstrict
6dc107
	if [ _$mb_ldstrict = _yes ]; then
66a30d
		mb_ldflags_strict='-Wl,--no-undefined'
66a30d
	fi
66a30d
}
66a30d
66a30d
66a30d
config_copy()
66a30d
{
cd2145
	mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \
553940
			| grep -v '^#')
553940
553940
	mb_sed_substs=" \
22f410
		$(for __var in $(printf %s "$mb_vars"); do   \
553940
			printf '%s"$%s"%s' "-e 's^@$__var@^'" \
553940
				"mb_$__var" "'^g' ";           \
553940
		done)"
553940
553940
	eval sed $mb_sed_substs \
553940
		$mb_project_dir/Makefile.in    \
aa2edb
			| sed -e 's/[[:blank:]]*$//g' \
553940
			> $mb_pwd/Makefile.tmp
7e34aa
}
66a30d
127aed
7e34aa
config_ccenv()
7e34aa
{
7e34aa
	mkdir -p ./ccenv
7e34aa
	touch ./ccenv/host.mk
7e34aa
	touch ./ccenv/native.mk
ebbba6
7e34aa
	ccenv_set_host_variables
7e34aa
	ccenv_set_native_variables
3a3fb5
3a3fb5
	config_copy
7e34aa
}
ebbba6
ebbba6
config_custom()
ebbba6
{
6dc107
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
c4ed3b
		eval . $mb_project_dir/project/config/cfgdefs.sh \
c4ed3b
			"$mb_custom_cfgdefs_args"
ebbba6
		config_copy
ebbba6
	fi
66a30d
6dc107
	if [ _$mb_use_custom_usrdefs = _yes ]; then
ebbba6
		. $mb_project_dir/project/usrdefs.sh
ebbba6
	fi
ebbba6
}
ebbba6
ebbba6
ebbba6
config_cfghost()
ebbba6
{
f6645d
	if [ -z "$mb_cfghost" ]; then
f6645d
		mb_cfghost=$mb_cchost
f6645d
	fi
f6645d
f6645d
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
f6645d
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
b988f8
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
66a30d
b988f8
	rm  $mb_pwd/Makefile.tmp
b988f8
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile
66a30d
}
66a30d
66a30d
66a30d
config_host()
66a30d
{
66a30d
	make -s host.tag && return 0
66a30d
66a30d
	error_msg "configure was able to generate a Makefile for the selected host,"
66a30d
	error_msg "however the host-targeting compiler was found to be missing"
66a30d
	error_msg "at least one of the required headers or features."
66a30d
	exit 2
66a30d
}
66a30d
66a30d
66a30d
config_status()
66a30d
{
66a30d
	printf "\n\n"
66a30d
	make .display
66a30d
	printf "\nconfiguration completed successfully.\n\n"
66a30d
}
66a30d
090216
090216
config_failure()
090216
{
789b0e
	if [ _$mb_success = _yes ]; then
789b0e
		return 0
789b0e
	fi
789b0e
090216
	if [ -f Makefile ]; then
090216
		mb_error='failed to use the generated Makefile.'
090216
		printf '\n%s: error: %s\n' "${0}" "$mb_error" >&2
090216
		mv Makefile Makefile.failed
090216
	fi
090216
090216
	exit 2
090216
}
090216
090216
090216
config_success()
090216
{
090216
	trap '' EXIT
789b0e
	mb_success=yes
090216
	exit 0
090216
}
090216
090216
66a30d
# one: init
66a30d
init_vars
66a30d
verify_build_directory
66a30d
66a30d
66a30d
# two: args
66a30d
for arg ; do
66a30d
	case "$arg" in
7e34aa
		--help)
7e34aa
			usage
7e34aa
			;;
7e34aa
		--help=ccenv)
7e34aa
			ccenv_usage
7e34aa
			;;
7e34aa
7e34aa
		# ccenv
7e34aa
		--cross-compile=*)
7e34aa
			mb_cross_compile=${arg#*=}
7e34aa
			;;
7e34aa
		--compiler=*)
7e34aa
			mb_compiler=${arg#*=}
7e34aa
			;;
7e34aa
		--toolchain=*)
7e34aa
			mb_toolchain=${arg#*=}
7e34aa
			;;
7e34aa
		--zealous)
7e34aa
			mb_agnostic=yes
7e34aa
			mb_zealous=
7e34aa
			;;
7e34aa
		--zealous=*)
7e34aa
			mb_zealous=${arg#*=}
7e34aa
			;;
7e34aa
		--ccenv=*)
7e34aa
			mb_ccenv=${arg#*=}
66a30d
			;;
66a30d
66a30d
		# dirs
66a30d
		--prefix=*)
66a30d
			mb_prefix_set=yes
66a30d
			mb_prefix=${arg#*=}
66a30d
			;;
66a30d
		--exec-prefix=*)
66a30d
			mb_exec_prefix_set=yes
66a30d
			mb_exec_prefix=${arg#*=}
66a30d
			;;
66a30d
		--bindir=*)
66a30d
			mb_bindir_set=yes
66a30d
			mb_bindir=${arg#*=}
66a30d
			;;
66a30d
		--sbindir=*)
66a30d
			mb_sbindir=${arg#*=}
66a30d
			;;
66a30d
		--libdir=*)
66a30d
			mb_libdir=${arg#*=}
66a30d
			;;
66a30d
		--includedir=*)
66a30d
			mb_includedir=${arg#*=}
66a30d
			;;
66a30d
		--oldincludedir=*)
66a30d
			mb_oldincludedir=${arg#*=}
66a30d
			;;
66a30d
		--mandir=*)
66a30d
			mb_mandir=${arg#*=}
66a30d
			;;
66a30d
		--libexecdir=*)
66a30d
			mb_libexecdir=${arg#*=}
66a30d
			;;
66a30d
66a30d
66a30d
		--sysconfdir=*)
66a30d
			mb_sysconfdir=${arg#*=}
66a30d
			;;
66a30d
		--sharedstatedir=*)
66a30d
			mb_sharedstatedir=${arg#*=}
66a30d
			;;
66a30d
		--localstatedir=*)
66a30d
			mb_localstatedir=${arg#*=}
66a30d
			;;
66a30d
		--runstatedir=*)
66a30d
			mb_runstatedir=${arg#*=}
66a30d
			;;
66a30d
		--datarootdir=*)
66a30d
			mb_datarootdir=${arg#*=}
66a30d
			;;
66a30d
		--datadir=*)
66a30d
			mb_datadir=${arg#*=}
66a30d
			;;
66a30d
		--infodir=*)
66a30d
			mb_infodir=${arg#*=}
66a30d
			;;
66a30d
		--localedir=*)
66a30d
			mb_localedir=${arg#*=}
66a30d
			;;
66a30d
		--htmldir=*)
66a30d
			mb_htmldir=${arg#*=}
66a30d
			;;
66a30d
		--dvidir=*)
66a30d
			mb_dvidir=${arg#*=}
66a30d
			;;
66a30d
		--pdfdir=*)
66a30d
			mb_pdfdir=${arg#*=}
66a30d
			;;
66a30d
		--psdir=*)
66a30d
			mb_psdir=${arg#*=}
66a30d
			;;
66a30d
66a30d
66a30d
		# build
66a30d
		--build=*)
66a30d
			mb_build=${arg#*=}
66a30d
			;;
66a30d
		--host=*)
66a30d
			mb_host=${arg#*=}
66a30d
			;;
66a30d
		--cchost=*)
66a30d
			mb_cchost=${arg#*=}
66a30d
			;;
f6645d
		--cfghost=*)
f6645d
			mb_cfghost=${arg#*=}
f6645d
			;;
66a30d
		--target=*)
66a30d
			mb_target=${arg#*=}
66a30d
			;;
66a30d
		--arch=*)
66a30d
			mb_arch=${arg#*=}
66a30d
			;;
66a30d
		--sysroot=*)
66a30d
			mb_sysroot=${arg#*=}
66a30d
			;;
66a30d
		--shell=*)
66a30d
			mb_shell=${arg#*=}
66a30d
			;;
66a30d
		--debug)
6dc107
			mb_debug=yes
66a30d
			;;
66a30d
66a30d
		# config
66a30d
		--all-static)
6dc107
			mb_all_static=yes
afd788
			mb_all_shared=no
66a30d
			;;
66a30d
		--all-shared)
6dc107
			mb_all_shared=yes
afd788
			mb_all_static=no
66a30d
			;;
66a30d
		--disable-frontend)
6dc107
			mb_disable_frontend=yes
66a30d
			;;
66a30d
		--disable-app)
6dc107
			mb_disable_frontend=yes
66a30d
			;;
66a30d
		--enable-frontend)
66a30d
			mb_disable_frontend='no'
66a30d
			;;
66a30d
		--enable-app)
66a30d
			mb_disable_frontend='no'
66a30d
			;;
66a30d
		--disable-static)
6dc107
			mb_disable_static=yes
66a30d
			;;
66a30d
		--disable-shared)
6dc107
			mb_disable_shared=yes
66a30d
			;;
66a30d
		--enable-static)
66a30d
			mb_disable_static='no'
66a30d
			;;
66a30d
		--enable-shared)
66a30d
			mb_disable_shared='no'
66a30d
			;;
66a30d
66a30d
		# convenience
66a30d
		--strict)
6dc107
			mb_ccstrict=yes
6dc107
			mb_ldstrict=yes
66a30d
			;;
66a30d
		--ccstrict)
6dc107
			mb_ccstrict=yes
66a30d
			;;
66a30d
		--ldstrict)
6dc107
			mb_ldstrict=yes
66a30d
			;;
66a30d
66a30d
		# project
66a30d
		--nickname=*)
66a30d
			mb_nickname=${arg#*=}
66a30d
			;;
66a30d
		--program-prefix=*)
66a30d
			mb_program_prefix=${arg#*=}
66a30d
			;;
66a30d
		--avoid-version)
6dc107
			mb_avoid_version=yes
66a30d
			;;
66a30d
		--source-dir=*)
66a30d
			mb_source_dir=${arg#*=}
66a30d
			;;
66a30d
66a30d
		# pkgconfig
66a30d
		--pkgname=*)
66a30d
			mb_pkgname=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgdesc=*)
66a30d
			mb_pkgdesc=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgusrc=*)
66a30d
			mb_pkgusrc=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgrepo=*)
66a30d
			mb_pkgrepo=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgpsrc=*)
66a30d
			mb_pkgpsrc=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgdurl=*)
66a30d
			mb_pkgdurl=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgdefs=*)
66a30d
			mb_pkgdefs=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkglibs=*)
66a30d
			mb_pkglibs=${arg#*=}
66a30d
			;;
66a30d
66a30d
		# compatibility
66a30d
		--enable-dependency-tracking)
66a30d
			;;
66a30d
		--disable-dependency-tracking)
66a30d
			;;
66a30d
66a30d
		*)
6dc107
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
c4ed3b
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
c4ed3b
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
c4ed3b
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
c4ed3b
				mb_custom_cfgdefs_space=' '
ebbba6
			else
ebbba6
				error_msg ${arg#}: "unsupported config argument."
ebbba6
				exit 2
ebbba6
			fi
66a30d
			;;
66a30d
	esac
66a30d
done
66a30d
66a30d
66a30d
66a30d
# three: validation
66a30d
verify_source_directory
66a30d
66a30d
if ! [ -z "$mb_program_prefix" ]; then
66a30d
	error_msg "--program-prefix is not yet fully support (must be null)."
66a30d
fi
66a30d
66a30d
66a30d
66a30d
# four: defaults
66a30d
common_defaults
66a30d
66a30d
66a30d
# five: config
66a30d
config_flags
66a30d
config_copy
7e34aa
config_ccenv
ebbba6
config_custom
ebbba6
config_cfghost
66a30d
config_host
66a30d
config_status
66a30d
66a30d
66a30d
# all done
090216
config_success