Blame configure

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