Blame configure

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