Blame configure

092ccd
#!/bin/sh
092ccd
092ccd
# project-agnostic ./configure script, written by hand.
092ccd
# this file is covered by COPYING.SOFORT.
092ccd
092ccd
set -eu
092ccd
092ccd
trap config_failure 1 2 EXIT
092ccd
092ccd
# before we begin...
092ccd
mb_path="$PATH"
092ccd
mb_script="$0"
092ccd
mb_success=no
092ccd
092ccd
usage()
092ccd
{
092ccd
	cat "$mb_project_dir"/config.usage
092ccd
092ccd
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
092ccd
		printf '\n\n%s%s\n' \
092ccd
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
092ccd
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
092ccd
092ccd
		printf '%s%s\n' \
092ccd
			"| Listed above are configure's common switches " \
092ccd
			"and environment variables.     |"
092ccd
092ccd
		printf '%s%s\n' \
092ccd
			"| Found below are project-specific variables " \
092ccd
			"and other customization options. |"
092ccd
092ccd
		printf '%s%s\n\n\n' \
092ccd
			" ___________________________________________" \
092ccd
			"__________________________________"
092ccd
092ccd
		cat "$mb_project_dir"/project/config/cfgdefs.usage
092ccd
	fi
092ccd
092ccd
	exit 0
092ccd
}
092ccd
092ccd
error_msg()
092ccd
{
092ccd
	printf '%s\n' "$@" >&2
092ccd
}
092ccd
092ccd
warning_msg()
092ccd
{
092ccd
	printf '%s\n' "$@" >&2
092ccd
}
092ccd
092ccd
output_step_prolog()
092ccd
{
092ccd
	mb_line_dots='.................................'
092ccd
	mb_line_dots="${mb_line_dots}.${mb_line_dots}"
fb5e78
	mb_step_desc="${mb_package} : ${1##*/} : ${2}  "
092ccd
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
092ccd
fb5e78
	printf "configure step: ${2}\n" >&3
092ccd
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s  " "${mb_step_desc}" "${mb_line_dots}"
092ccd
}
092ccd
092ccd
output_step_epilog()
092ccd
{
092ccd
	printf 'OK.\n'
092ccd
}
092ccd
092ccd
output_script_status()
092ccd
{
092ccd
	mb_step_name="${1##*/} : ${2}"
092ccd
	mb_step_desc="${mb_package} : ${mb_step_name}"
092ccd
092ccd
	printf "configure info: ${2}\n" >&3
092ccd
	printf "%s\n" "${mb_step_desc}"
092ccd
}
092ccd
092ccd
output_section_break()
092ccd
{
092ccd
	printf ' ..\n'
092ccd
}
092ccd
092ccd
verify_safe_path()
092ccd
{
092ccd
	case "$mb_safe_path_name" in
092ccd
		-*)
092ccd
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
092ccd
			exit 2
092ccd
			;;
092ccd
092ccd
		*\ *)
092ccd
			error_msg "$mb_safe_path_desc may not contain spaces."
092ccd
			exit 2
092ccd
			;;
092ccd
	esac
092ccd
}
092ccd
092ccd
init_log()
092ccd
{
092ccd
	exec 3> config.log
092ccd
092ccd
	printf "This is config.log, generated by sofort's configure script.\n\n" >&3
092ccd
	printf '$ %s' "$mb_script" >&3
092ccd
}
092ccd
092ccd
init_vars()
092ccd
{
092ccd
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
092ccd
	mb_pwd=$(pwd -P)
092ccd
092ccd
	mb_safe_path_desc='project directory'
092ccd
	mb_safe_path_name="$mb_project_dir"
092ccd
	verify_safe_path
092ccd
092ccd
	mb_safe_path_desc='working directory'
092ccd
	mb_safe_path_name="$mb_pwd"
092ccd
	verify_safe_path
092ccd
092ccd
	mb_custom_cfgdefs_args=''
092ccd
	mb_custom_cfgdefs_space=''
092ccd
092ccd
	mb_srcinfo='$(PROJECT_DIR)/project/srcdist/srcinfo.in'
092ccd
	mb_srcsite='localhost'
092ccd
092ccd
	mb_pgprkey='!!VARIABLE_NOT_SET!!'
092ccd
	mb_pgpskey='!!VARIABLE_NOT_SET!!'
092ccd
092ccd
	sfrt_impl_dir=$mb_project_dir/sofort
092ccd
	sfrt_config_dir=$sfrt_impl_dir/config
092ccd
	sfrt_core_dir=$sfrt_impl_dir/core
092ccd
	sfrt_config_vars=$sfrt_config_dir/config.vars
092ccd
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
092ccd
	sfrt_opt_vars=$sfrt_config_dir/opt.vars
092ccd
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
092ccd
092ccd
	mb_make_vars=$(< "$sfrt_config_vars" \
092ccd
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
092ccd
092ccd
	mb_impl_vars=$(< "$sfrt_config_vars" \
092ccd
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
092ccd
092ccd
	mb_proj_vars=$(< "$sfrt_config_vars" \
092ccd
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
092ccd
092ccd
	mb_flag_vars=$(< "$sfrt_flag_vars" \
092ccd
		grep -v -e '^#' -e '^$')
092ccd
092ccd
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
092ccd
092ccd
	for mb_var in $(printf '%s' "$mb_vars") ; do
092ccd
		mb_expr=$mb_var='${'$mb_var':-}'
092ccd
		eval "$mb_expr"
092ccd
	done
092ccd
b414e3
	# cfgtest
b414e3
	. $mb_project_dir/sofort/cfgtest/cfgtest.sh
b414e3
092ccd
	# ccenv
092ccd
	. $mb_project_dir/sofort/ccenv/ccenv.sh
092ccd
092ccd
	if ! [ -L ./ccenv ]; then
092ccd
		if [ -d ./ccenv ]; then
092ccd
			rm -f ./ccenv/host.mk
092ccd
			rm -f ./ccenv/native.mk
092ccd
			rmdir ./ccenv
092ccd
		fi
092ccd
	fi
092ccd
092ccd
	# config.project
092ccd
	if [ -z "$mb_config" ]; then
092ccd
		mb_config="$mb_project_dir/config.project"
092ccd
	fi
092ccd
092ccd
	. "$mb_config"
092ccd
092ccd
	# config.project make preferences
092ccd
	if [ -z "${MAKE}" ]; then
092ccd
		MAKE="$mb_make"
092ccd
	fi
092ccd
092ccd
	if [ -z "${MAKEMODE}" ]; then
092ccd
		MAKEMODE="$mb_makemode"
092ccd
	fi
092ccd
a341a9
a341a9
	if [ -z "$mb_makefile" ]; then
a341a9
		mb_makefile='Makefile'
a341a9
	fi
a341a9
9944d7
	# pkgconf (host)
9944d7
	if [ -z "${PKGCONF}" ]; then
9944d7
		PKGCONF="$mb_pkgconf"
9944d7
	fi
9944d7
9944d7
	if [ -z "${PKGCONF}" ]; then
9944d7
		PKGCONF="${PKGCONFIG}"
9944d7
	fi
9944d7
9944d7
	# pkgconf (native)
9944d7
	if [ -z "${NATIVE_PKGCONF}" ]; then
9944d7
		NATIVE_PKGCONF="$mb_native_pkgconf"
9944d7
	fi
9944d7
9944d7
	if [ -z "${NATIVE_PKGCONF}" ]; then
9944d7
		NATIVE_PKGCONF="${NATIVE_PKGCONFIG}"
9944d7
	fi
9944d7
092ccd
	# project-specific initialization
092ccd
	if [ _$mb_use_custom_cfginit = _yes ]; then
092ccd
		. "$mb_project_dir/project/config/cfginit.sh"
092ccd
	fi
092ccd
092ccd
	# package
092ccd
	if [ -z "$mb_package" ]; then
092ccd
		error_msg "$mb_script: incomplete information in $mb_config."
092ccd
		error_msg "$mb_script: \$mb_package not set."
092ccd
		exit 1
092ccd
	fi
092ccd
092ccd
	if [ -z "${NICKNAME}" ]; then
092ccd
		NICKNAME="$mb_nickname"
092ccd
	fi
092ccd
092ccd
	# srcinfo
092ccd
	if [ -n "$SOURCE_DIR" ]; then
092ccd
		mb_source_dir_set=yes
092ccd
	fi
092ccd
d4aea0
	# cchost
d4aea0
	if [ -n "$CCHOST" ]; then
d4aea0
		mb_cchost_set=yes
d4aea0
	fi
d4aea0
092ccd
	# step prolog
092ccd
	output_step_prolog ${mb_script} 'init_vars'
092ccd
092ccd
	# project
092ccd
	mb_nickname=$NICKNAME
092ccd
	mb_source_dir=$SOURCE_DIR
092ccd
092ccd
	# dirs
092ccd
	mb_prefix=$PREFIX
092ccd
	mb_exec_prefix=$EXEC_PREFIX
092ccd
	mb_bindir=$BINDIR
092ccd
	mb_sbindir=$SBINDIR
092ccd
	mb_libdir=$LIBDIR
092ccd
	mb_includedir=$INCLUDEDIR
092ccd
	mb_oldincludedir=$OLDINCLUDEDIR
092ccd
	mb_mandir=$MANDIR
092ccd
	mb_docdir=$DOCDIR
092ccd
	mb_libexecdir=$LIBEXECDIR
092ccd
092ccd
	mb_sysconfdir=$SYSCONFDIR
092ccd
	mb_sharedstatedir=$SHAREDSTATEDIR
092ccd
	mb_localstatedir=$LOCALSTATEDIR
092ccd
	mb_runstatedir=$RUNSTATEDIR
092ccd
	mb_datarootdir=$DATAROOTDIR
092ccd
	mb_datadir=$DATADIR
092ccd
	mb_infodir=$INFODIR
092ccd
	mb_localedir=$LOCALEDIR
092ccd
	mb_htmldir=$HTMLDIR
092ccd
	mb_dvidir=$DVIDIR
092ccd
	mb_pdfdir=$PDFDIR
092ccd
	mb_psdir=$PSDIR
092ccd
092ccd
	# make
092ccd
	mb_make=$MAKE
092ccd
	mb_makemode=$MAKEMODE
092ccd
092ccd
	# build
092ccd
	mb_build=$BUILD
092ccd
	mb_cchost=$CCHOST
092ccd
	mb_cfghost=$CFGHOST
092ccd
	mb_arch=$ARCH
092ccd
	mb_compiler=$COMPILER
092ccd
	mb_toolchain=$TOOLCHAIN
092ccd
	mb_sysroot=$SYSROOT
092ccd
	mb_cross_compile=$CROSS_COMPILE
092ccd
	mb_shell=$SHELL
092ccd
9944d7
	# pkgconf
9944d7
	mb_pkgconf=$PKGCONF
9944d7
092ccd
	# switches
092ccd
	mb_cflags=$CFLAGS
092ccd
	mb_cflags_debug=$CFLAGS_DEBUG
092ccd
	mb_cflags_common=$CFLAGS_COMMON
092ccd
	mb_cflags_cmdline=$CFLAGS_CMDLINE
092ccd
	mb_cflags_config=$CFLAGS_CONFIG
092ccd
	mb_cflags_sysroot=$CFLAGS_SYSROOT
092ccd
	mb_cflags_os=$CFLAGS_OS
092ccd
	mb_cflags_site=$CFLAGS_SITE
092ccd
	mb_cflags_path=$CFLAGS_PATH
092ccd
	mb_cflags_strict=$CFLAGS_STRICT
092ccd
	mb_cflags_util=$CFLAGS_UTIL
092ccd
	mb_cflags_last=$CFLAGS_LAST
092ccd
	mb_cflags_once=$CFLAGS_ONCE
092ccd
092ccd
	mb_ldflags=$LDFLAGS
092ccd
	mb_ldflags_debug=$LDFLAGS_DEBUG
092ccd
	mb_ldflags_common=$LDFLAGS_COMMON
092ccd
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
092ccd
	mb_ldflags_config=$LDFLAGS_CONFIG
092ccd
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
092ccd
	mb_ldflags_path=$LDFLAGS_PATH
092ccd
	mb_ldflags_strict=$LDFLAGS_STRICT
092ccd
	mb_ldflags_util=$LDFLAGS_UTIL
092ccd
	mb_ldflags_last=$LDFLAGS_LAST
092ccd
	mb_ldflags_once=$LDFLAGS_ONCE
092ccd
092ccd
	mb_pe_subsystem=$PE_SUBSYSTEM
092ccd
	mb_pe_image_base=$PE_IMAGE_BASE
092ccd
092ccd
	# overrides
092ccd
	mb_user_cc=$CC
092ccd
	mb_user_cpp=$CPP
092ccd
	mb_user_cxx=$CXX
092ccd
092ccd
	mb_native_cc=$NATIVE_CC
092ccd
	mb_native_cpp=$NATIVE_CPP
092ccd
	mb_native_cxx=$NATIVE_CXX
092ccd
092ccd
	mb_native_host=$NATIVE_HOST
092ccd
	mb_native_cfghost=$NATIVE_CFGHOST
092ccd
	mb_native_cflags=$NATIVE_CFLAGS
092ccd
	mb_native_ldflags=$NATIVE_LDFLAGS
092ccd
9944d7
	mb_native_pkgconf=$NATIVE_PKGCONF
9944d7
092ccd
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
092ccd
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
092ccd
092ccd
	# step epilog
092ccd
	output_step_epilog
092ccd
}
092ccd
092ccd
092ccd
verify_build_directory()
092ccd
{
092ccd
	output_step_prolog ${mb_script} 'verify_build_directory'
092ccd
092ccd
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
092ccd
		if [ _$mb_require_out_of_tree = _yes ]; then
092ccd
			error_msg "$mb_package: out-of-tree builds are required."
092ccd
			error_msg "please invoke configure again from a clean build directory."
092ccd
			exit 1
092ccd
		else
092ccd
			mb_project_dir='.'
092ccd
		fi
092ccd
	fi
092ccd
d167c1
	if [ -f "$mb_pwd/Makefile.common" ]; then
d167c1
		error_msg
d167c1
		error_msg "$mb_package: the file-name Makefile.common is reserved for bootstrapping projects."
d167c1
		error_msg "$mb_package: please remove or rename the file manually and then re-run configure."
d167c1
		exit 1
d167c1
	fi
d167c1
a341a9
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed $mb_makefile
092ccd
092ccd
	output_step_epilog
092ccd
}
092ccd
092ccd
092ccd
verify_source_directory()
092ccd
{
092ccd
	output_step_prolog ${mb_script} 'verify_source_directory'
092ccd
092ccd
	if [ _"$mb_source_dir" != _${mb_source_dir##* } ]; then
092ccd
		error_msg "source directory path contains spaces, aborting."
092ccd
		exit 1
092ccd
	fi
092ccd
092ccd
	eval mb_source_dir=$(printf '%s' "$mb_source_dir")
092ccd
092ccd
	if [ -z "$mb_source_dir" ]; then
092ccd
		if [ _$mb_require_source_dir = _yes ]; then
092ccd
			error_msg "$mb_package: specifying an external source directory is required."
092ccd
			error_msg "you can set the source directory either via --source-dir=<path>,"
092ccd
			error_msg "or by setting the SOURCE_DIR variable."
092ccd
			exit 1
092ccd
		fi
092ccd
	fi
092ccd
092ccd
	output_step_epilog
092ccd
}
092ccd
092ccd
092ccd
verify_source_info()
092ccd
{
092ccd
	output_step_prolog ${mb_script} 'verify_source_info'
092ccd
092ccd
	if [ "${mb_source_dir_set:-}" = yes ]; then
092ccd
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ] || [ -n "$mb_srcball" ]; then
092ccd
			error_msg "$mb_package: conflicting arguments: --rawball/--modball/--srcball arguments"
092ccd
			error_msg "may not be used together with an explicit source-dir argument or variable."
092ccd
			exit 1
092ccd
		fi
092ccd
	fi
092ccd
092ccd
	if [ -n "$mb_srcball" ]; then
092ccd
		eval mb_srcball=$(printf '%s' "$mb_srcball")
092ccd
092ccd
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ]; then
092ccd
			error_msg "$mb_package: conflicting arguments: --rawball and/or --modball arguments"
092ccd
			error_msg "may not be used together with an explicitly --srcball argument."
092ccd
			exit 1
092ccd
		fi
092ccd
092ccd
		if [ -z "$mb_srcball_sha256" ]; then
092ccd
			error_msg "$mb_package: --srcball-sha256 must be provided"
092ccd
			error_msg "in conjunction with --srcball."
092ccd
			exit 1
092ccd
		fi
092ccd
092ccd
		mb_srcball_sha256_test=$(sha256sum "$mb_srcball")
092ccd
		mb_srcball_sha256_test="${mb_srcball_sha256_test%% *}"
092ccd
092ccd
		if [ "$mb_srcball_sha256_test" != "$mb_srcball_sha256" ]; then
092ccd
			error_msg "$mb_package: sha256 signature of srcball $mb_srcball does not match!"
092ccd
			exit 1
092ccd
		fi
092ccd
092ccd
		mb_srcball_topdir=$(xz -c -d "$mb_srcball" | pax | sed -n '1,1p')
092ccd
		mb_source_dir="./srctree/$mb_package/${mb_srcball_topdir%/}"
092ccd
092ccd
		mb_srcball_dirname=$(cd -- "${mb_srcball%/*}" ; pwd -P)
092ccd
		mb_srcball_basename=${mb_srcball##*/}
092ccd
		mb_srcball="$mb_srcball_dirname/$mb_srcball_basename"
092ccd
092ccd
		mkdir -p "./srctree/$mb_package"
092ccd
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_srcball" | pax -r)
092ccd
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
092ccd
	fi
092ccd
092ccd
	if [ -z "$mb_rawball" ] && [ -n "$mb_modball" ]; then
092ccd
		error_msg "$mb_package: conflicting arguments: --modball argument may only be used"
092ccd
		error_msg "together with an explicit --rawball argument."
092ccd
		exit 1
092ccd
	fi
092ccd
092ccd
	if [ -n "$mb_modball" ]; then
092ccd
		eval mb_modball=$(printf '%s' "$mb_modball")
092ccd
092ccd
		if [ -z "$mb_modball_sha256" ]; then
092ccd
			error_msg "$mb_package: --modball-sha256 must be provided"
092ccd
			error_msg "in conjunction with --modball."
092ccd
			exit 1
092ccd
		fi
092ccd
092ccd
		mb_modball_sha256_test=$(sha256sum "$mb_modball")
092ccd
		mb_modball_sha256_test="${mb_modball_sha256_test%% *}"
092ccd
092ccd
		if [ "$mb_modball_sha256_test" != "$mb_modball_sha256" ]; then
092ccd
			error_msg "$mb_package: sha256 signature of modball $mb_modball does not match!"
092ccd
			exit 1
092ccd
		fi
092ccd
	fi
092ccd
092ccd
	if [ -n "$mb_rawball" ]; then
092ccd
		eval mb_rawball=$(printf '%s' "$mb_rawball")
092ccd
092ccd
		if [ -z "$mb_rawball_sha256" ]; then
092ccd
			error_msg "$mb_package: --rawball-sha256 must be provided."
092ccd
			error_msg "in conjunction with --rawball."
092ccd
			exit 1
092ccd
		fi
092ccd
092ccd
		mb_rawball_sha256_test=$(sha256sum "$mb_rawball")
092ccd
		mb_rawball_sha256_test="${mb_rawball_sha256_test%% *}"
092ccd
092ccd
		if [ "$mb_rawball_sha256_test" != "$mb_rawball_sha256" ]; then
092ccd
			error_msg "$mb_package: sha256 signature of rawball $mb_rawball does not match!"
092ccd
			exit 1
092ccd
		fi
092ccd
092ccd
		mb_rawball_topdir=$(xz -c -d "$mb_rawball" | pax | sed -n '1,1p')
092ccd
		mb_source_dir="./srctree/$mb_package/${mb_rawball_topdir%/}"
092ccd
092ccd
		mb_rawball_dirname=$(cd -- "${mb_rawball%/*}" ; pwd -P)
092ccd
		mb_rawball_basename=${mb_rawball##*/}
092ccd
		mb_rawball="$mb_rawball_dirname/$mb_rawball_basename"
092ccd
092ccd
		mkdir -p "./srctree/$mb_package"
092ccd
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_rawball" | pax -r)
092ccd
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
092ccd
	fi
092ccd
092ccd
	if [ -n "$mb_modball" ]; then
092ccd
		mb_modball_dirname=$(cd -- "${mb_modball%/*}" ; pwd -P)
092ccd
		mb_modball_basename=${mb_modball##*/}
092ccd
		mb_modball="$mb_modball_dirname/$mb_modball_basename"
092ccd
092ccd
		mb_modball_topdir="./modtree/$mb_package/$mb_modball_sha256"
092ccd
		mkdir -p "$mb_modball_topdir"
092ccd
		mb_modball_topdir=$(cd -- $mb_modball_topdir; pwd -P)
092ccd
		mb_dummy=$(cd -- "$mb_modball_topdir"; xz -c -d "$mb_modball" | pax -r)
092ccd
092ccd
		if [ -d "$mb_modball_topdir/overlay" ]; then
092ccd
			mb_dummy=$(cd -- "$mb_modball_topdir/overlay"; \
092ccd
				cp -p -P -R . "$mb_source_dir")
092ccd
		fi
092ccd
092ccd
		if [ -d "$mb_modball_topdir/patches" ]; then
092ccd
			mb_dummy=$(cd -- "$mb_source_dir";                        \
092ccd
				for p in $mb_modball_topdir/patches/*.patch; do  \
092ccd
					patch -p1 < $p;                         \
092ccd
				done);
092ccd
		fi
092ccd
	fi
092ccd
092ccd
	output_step_epilog
092ccd
}
092ccd
092ccd
092ccd
common_defaults()
092ccd
{
092ccd
	# step prolog
092ccd
	output_step_prolog ${mb_script} 'common_defaults'
092ccd
092ccd
	# project-specific config definitions
092ccd
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
092ccd
		cat $sfrt_cfgdefs_in > cfgdefs.mk
092ccd
	else
092ccd
		printf '%s %s\n\n' \
092ccd
				'# this project does not include' \
092ccd
				'a custom config step.'           \
092ccd
			> cfgdefs.mk
092ccd
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
092ccd
092ccd
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
092ccd
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
092ccd
		fi
092ccd
	fi
092ccd
092ccd
	# user build-time overrides
092ccd
	touch usrdefs.mk
092ccd
092ccd
	# git
092ccd
	if [ -n "$mb_source_dir" ]; then
092ccd
		if [ -d "$mb_source_dir/.git" ]; then
092ccd
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
092ccd
		fi
092ccd
	elif [ -d "$mb_project_dir/.git" ]; then
092ccd
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
092ccd
	fi
092ccd
092ccd
	# project
092ccd
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
092ccd
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
092ccd
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
092ccd
092ccd
	# pkgconfig
092ccd
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
092ccd
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
092ccd
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
092ccd
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
092ccd
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
092ccd
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
092ccd
	[ -n "$mb_pkgbugs" ]		|| mb_pkgbugs="$mb_default_pkgbugs"
092ccd
	[ -n "$mb_pkghome" ]		|| mb_pkghome="$mb_default_pkghome"
092ccd
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
092ccd
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
092ccd
092ccd
	# srcinfo
092ccd
	[ -n "$mb_rawball" ]		|| mb_rawball="$mb_default_rawball"
092ccd
	[ -n "$mb_rawball_url" ]	|| mb_rawball_url="$mb_default_rawball_url"
092ccd
	[ -n "$mb_rawball_sha256" ]	|| mb_rawball_sha256="$mb_default_rawball_sha256"
092ccd
	[ -n "$mb_modball" ]		|| mb_modball="$mb_default_modball"
092ccd
	[ -n "$mb_modball_url" ]	|| mb_modball_url="$mb_default_modball_url"
092ccd
	[ -n "$mb_modball_sha256" ]	|| mb_modball_sha256="$mb_default_modball_sha256"
092ccd
	[ -n "$mb_srcball" ]		|| mb_srcball="$mb_default_srcball"
092ccd
	[ -n "$mb_srcball_url" ]	|| mb_srcball_url="$mb_default_srcball_url"
092ccd
	[ -n "$mb_srcball_sha256" ]	|| mb_srcball_sha256="$mb_default_srcball_sha256"
092ccd
092ccd
	# dirs
092ccd
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
092ccd
					|| mb_prefix='/usr/local'
092ccd
092ccd
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
092ccd
					|| mb_exec_prefix=$mb_prefix
092ccd
092ccd
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
092ccd
					|| [ -n "$mb_bindir_basename" ] \
092ccd
					|| mb_bindir=$mb_exec_prefix/bin
092ccd
092ccd
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
092ccd
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
092ccd
092ccd
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
092ccd
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
092ccd
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
092ccd
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
092ccd
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
092ccd
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
092ccd
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc/'$(PACKAGE)'
092ccd
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
092ccd
092ccd
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
092ccd
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
092ccd
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
092ccd
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
092ccd
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
092ccd
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
092ccd
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
092ccd
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
092ccd
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
092ccd
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
092ccd
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
092ccd
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
092ccd
092ccd
	# switches
092ccd
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
092ccd
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
092ccd
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
092ccd
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
092ccd
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
092ccd
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
092ccd
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
092ccd
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
092ccd
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
092ccd
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
092ccd
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
092ccd
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
092ccd
092ccd
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
092ccd
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
092ccd
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
092ccd
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
092ccd
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
092ccd
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
092ccd
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
092ccd
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
092ccd
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
092ccd
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
092ccd
092ccd
	# native switches
092ccd
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
092ccd
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
092ccd
092ccd
	# config
092ccd
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
092ccd
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
092ccd
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
092ccd
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
092ccd
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
092ccd
092ccd
	# host/target
092ccd
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
092ccd
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
092ccd
092ccd
	# sysroot
092ccd
	if [ -n "$mb_sysroot" ]; then
092ccd
		if [ -z "$mb_cflags_sysroot" ]; then
bab309
			mb_cflags_sysroot='$(_CFLAGS_SYSROOT)'
092ccd
		fi
092ccd
092ccd
		if [ -z "$mb_ldflags_sysroot" ]; then
bab309
			mb_ldflags_sysroot='$(_LDFLAGS_SYSROOT)'
092ccd
		fi
092ccd
	fi
092ccd
092ccd
	# debug
092ccd
	if [ _$mb_debug = _yes ]; then
092ccd
		if [ -z "$mb_cflags_debug" ]; then
d6dc93
			mb_cflags_debug='$(_CFLAGS_g3) $(_CFLAGS_O0)'
092ccd
		fi
092ccd
	fi
092ccd
092ccd
	# make
092ccd
	if [ -z "$mb_make" ]; then
092ccd
		mb_make='make'
092ccd
	fi
092ccd
092ccd
	if [ -z "$mb_makemode" ]; then
092ccd
		mb_makemode='posix'
092ccd
092ccd
		printf '%s\n%s\n%s\n\n%s\n\n'        \
092ccd
				'ifeq (a,b)'          \
092ccd
				'VAR = val'            \
092ccd
				'endif'                 \
092ccd
				'all:'                   \
092ccd
			| ${mb_make} -s -f - 2>/dev/null  \
092ccd
		&& mb_makemode='modern'
092ccd
092ccd
	fi
092ccd
092ccd
	# shell
092ccd
	if [ -z "$mb_shell" ]; then
092ccd
		mb_shell='/bin/sh'
092ccd
	fi
092ccd
092ccd
	# inherited cflags & ldflags
092ccd
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
092ccd
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
092ccd
092ccd
	# step epilog
092ccd
	output_step_epilog
092ccd
}
092ccd
092ccd
092ccd
config_flags()
092ccd
{
092ccd
	# step prolog
092ccd
	output_step_prolog ${mb_script} 'config_flags'
092ccd
092ccd
	mb_ldflags_tmp=" $mb_ldflags "
092ccd
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
092ccd
092ccd
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
092ccd
		mb_ldflags="$mb_ldflags_libs"
092ccd
		mb_ldflags_util="$mb_ldflags_util -static"
092ccd
	fi
092ccd
092ccd
	# ccstrict
092ccd
	if [ _$mb_ccstrict = _yes ]; then
a0f3a5
		mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef)'
092ccd
	fi
092ccd
092ccd
	# ldstrict
092ccd
	if [ _$mb_ldstrict = _yes ]; then
a0f3a5
		mb_ldflags_strict='$(_CFLAGS_Wl___no_undefined)'
092ccd
	fi
092ccd
092ccd
	# step epilog
092ccd
	output_step_epilog
092ccd
}
092ccd
092ccd
092ccd
config_opts()
092ccd
{
092ccd
	if [ "$mb_avoid_version" = 'yes' ]; then
092ccd
		mb_version_opt='none'
092ccd
	else
092ccd
		mb_version_opt='used'
092ccd
	fi
092ccd
092ccd
	if [ "$mb_custom_install_headers" = 'yes' ]; then
092ccd
		mb_install_headers_opt='custom'
092ccd
	else
092ccd
		mb_install_headers_opt='default'
092ccd
	fi
092ccd
092ccd
	if [ "$mb_disable_static" = 'yes' ]; then
092ccd
		mb_static_library_opt='disabled'
092ccd
	else
092ccd
		mb_static_library_opt='enabled'
092ccd
	fi
092ccd
092ccd
	if [ "$mb_disable_shared" = 'yes' ]; then
092ccd
		mb_shared_library_opt='disabled'
092ccd
	else
092ccd
		mb_shared_library_opt='enabled'
092ccd
	fi
092ccd
092ccd
	if [ "$mb_disable_frontend" = 'yes' ]; then
092ccd
		mb_app_frontend_opt='disabled'
092ccd
	else
092ccd
		mb_app_frontend_opt='enabled'
092ccd
	fi
092ccd
092ccd
	if [ "$mb_all_static" = 'yes' ]; then
092ccd
		mb_app_linking_opt='all_static'
092ccd
092ccd
	elif [ "$mb_all_shared" = 'yes' ]; then
092ccd
		mb_app_linking_opt='all_shared'
092ccd
092ccd
	else
092ccd
		mb_app_linking_opt='default'
092ccd
	fi
092ccd
}
092ccd
092ccd
config_copy()
092ccd
{
092ccd
	output_step_prolog ${mb_script} 'config_copy'
092ccd
092ccd
	mb_var_defs=
092ccd
	mb_sed_substs=
21ff6d
	mb_template="${1:-$mb_project_dir/Makefile.in}"
092ccd
092ccd
	mb_vars=$(cut -d'=' -f1 "$sfrt_config_vars" "$sfrt_opt_vars" \
092ccd
		| grep -v '^#');
092ccd
092ccd
	for __var in $(printf '%s' "$mb_vars"); do
092ccd
		mb_sed_subst=$(printf '%s %s%s%s'  \
092ccd
				'-e' "'s^@$__var@"  \
092ccd
				"^___${__var}___"    \
092ccd
				"^g'")
092ccd
092ccd
		mb_sed_substs="$mb_sed_substs $mb_sed_subst"
092ccd
092ccd
		mb_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "mb_${__var}")
092ccd
		eval mb_var_defs='"$mb_var_defs "$mb_var_def'
092ccd
	done
092ccd
21ff6d
	eval sed $mb_sed_substs $mb_template         \
21ff6d
			| eval m4 $mb_var_defs -      \
21ff6d
			| sed -e 's/[[:blank:]]*$//g'  \
092ccd
		> $mb_pwd/Makefile.tmp
092ccd
092ccd
	output_step_epilog
092ccd
}
092ccd
092ccd
092ccd
config_ccenv()
092ccd
{
092ccd
	mkdir -p ./ccenv
092ccd
	touch ./ccenv/host.mk
092ccd
	touch ./ccenv/native.mk
092ccd
092ccd
	output_section_break
092ccd
	ccenv_set_host_variables
092ccd
092ccd
	output_section_break
092ccd
	ccenv_set_native_variables
092ccd
7a1535
	# implicit --sysroot for use with pkgconf and friends
7a1535
	if [ -z "$mb_sysroot" ]; then
7a1535
		mb_sysroot="$ccenv_host_sysroot"
7a1535
	fi
7a1535
a77299
	# require --sysroot when cross-compiling
7a1535
	if [ "$mb_cchost" != "$mb_native_cchost" ]                   \
7a1535
			&& [ "$ccenv_host_cc" != "$ccenv_native_cc" ] \
7a1535
			&& [ -z "$mb_sysroot" ]; then
8908c6
		mb_pretty=$(printf "%-${#mb_package}s" '')
8908c6
8908c6
		error_msg ' !!'
8908c6
		error_msg "$mb_package: host machine:    $mb_cchost"
8908c6
		error_msg "$mb_package: host compiler:   $ccenv_host_cc"
8908c6
8908c6
		error_msg ' !!'
8908c6
		error_msg "$mb_package: native machine:  $mb_native_cchost"
8908c6
		error_msg "$mb_package: native compiler: $ccenv_native_cc"
8908c6
8908c6
		error_msg ' !!'
8908c6
		error_msg "$mb_package: detected host machine and native machine differ, assuming cross-compilation."
8908c6
8908c6
		error_msg ' !!'
8908c6
		error_msg "$mb_package: native compilation mode can be forced via --cchost=$mb_native_cchost"
8908c6
		error_msg "${mb_pretty}  or otherwise by setting the NATIVE_CC environment variable to '$ccenv_host_cc',"
8908c6
		error_msg "${mb_pretty}  however that should almost never be necessary; then again,"
8908c6
		error_msg "${mb_pretty}  forcing native mode when cross-building is strictly prohibited."
8908c6
a77299
		error_msg ' !!'
8908c6
		error_msg "$mb_package: error: --sysroot is required when cross-compiling."
a77299
		exit 2
a77299
	fi
a77299
5f1bda
	# add the library directory to the linker library path
5f1bda
	if [ "$mb_cchost" = "$mb_native_cchost" ]; then
5f1bda
		mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
5f1bda
	else
5f1bda
		case "$mb_libdir" in
5f1bda
			/*)
5f1bda
				mb_ldflags_last="$mb_ldflags_last -L$mb_sysroot/.$mb_libdir"
5f1bda
				;;
5f1bda
			*)
5f1bda
				mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
5f1bda
		esac
5f1bda
	fi
5f1bda
a77299
	# re-generate Makefile.tmp
092ccd
	output_section_break
092ccd
	config_copy
a77299
092ccd
}
092ccd
092ccd
config_custom_cfgdefs()
092ccd
{
092ccd
	. $mb_project_dir/project/config/cfgdefs.sh
092ccd
}
092ccd
092ccd
config_custom()
092ccd
{
092ccd
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
092ccd
		output_section_break
092ccd
		output_script_status ${mb_script} \
092ccd
			'invoking project-specific cfgdefs.sh'
092ccd
092ccd
		eval config_custom_cfgdefs "$mb_custom_cfgdefs_args"
092ccd
092ccd
		output_section_break
22d12b
22d12b
		if [ -f "$mb_project_dir/project/config/Makefile.in" ]; then
22d12b
			config_copy "$mb_project_dir/project/config/Makefile.in"
22d12b
			mv $mb_pwd/Makefile.tmp Makefile
22d12b
		fi
22d12b
092ccd
		config_copy
092ccd
	fi
092ccd
092ccd
	if [ _$mb_use_custom_usrdefs = _yes ]; then
092ccd
		output_section_break
092ccd
		output_script_status ${mb_scirpt} \
092ccd
			'invoking project-specific usrdefs.sh'
092ccd
092ccd
		. $mb_project_dir/project/usrdefs.sh
092ccd
		output_section_break
092ccd
	fi
092ccd
}
092ccd
092ccd
092ccd
config_cfghost()
092ccd
{
092ccd
	output_step_prolog ${mb_script} 'config_cfghost'
092ccd
092ccd
	if [ -z "$mb_cfghost" ]; then
092ccd
		mb_cfghost=$mb_cchost
092ccd
	fi
092ccd
092ccd
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
092ccd
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
092ccd
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
092ccd
092ccd
	rm  $mb_pwd/Makefile.tmp
a341a9
	mv  $mb_pwd/Makefile.host $mb_pwd/$mb_makefile
092ccd
092ccd
	output_step_epilog
092ccd
}
092ccd
092ccd
092ccd
config_host()
092ccd
{
daf24e
	# init
092ccd
	output_step_prolog ${mb_script} 'config_host'
092ccd
daf24e
	mb_cfghost_cc="$ccenv_host_cc"
daf24e
	mb_cfghost_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
daf24e
daf24e
	mb_cfghost_cflags=$(${mb_make} -n -f "$mb_makefile" \
daf24e
		.cflags-host)
daf24e
daf24e
	mb_cfghost_cflags="${mb_cfghost_cflags#*: }"
daf24e
a9a824
	if [ "$mb_cc_environment" = 'freestanding' ]; then
4a8b83
		if [ -z "mb_cc_underscore" ]; then
4a8b83
			mb_cfghost_start_fn='_start'
4a8b83
		else
4a8b83
			mb_cfghost_start_fn='start'
4a8b83
		fi
4a8b83
4a8b83
		printf 'int %s(void){return 0;}' "$mb_cfghost_start_fn" \
4a8b83
			> "$mb_cfghost_tmpname"
4a8b83
4a8b83
		mb_cfghost_cflags="$mb_cfghost_cflags -ffreestanding"
4a8b83
		mb_cfghost_cflags="$mb_cfghost_cflags -nostdlib"
4a8b83
	else
4a8b83
		printf 'int main(void){return 0;}' \
4a8b83
			> "$mb_cfghost_tmpname"
4a8b83
	fi
daf24e
daf24e
	# log
daf24e
	printf '\n' >&3
daf24e
daf24e
	printf '%s\n'                                         \
daf24e
		'#'                                           \
daf24e
		'# verify that that following combination of' \
daf24e
		'# host compiler and host cflags is working.' \
daf24e
		'#'                                           \
daf24e
		>&3
daf24e
daf24e
	printf '\n%s' "$mb_cfghost_cc $ccenv_tmpname -o a.out" >&3
daf24e
eb2049
	for mb_cfghost_cflag in $(printf '%s' "$mb_cfghost_cflags"); do
daf24e
		printf ' \\\n\t%s' "$mb_cfghost_cflag" >&3
daf24e
	done
daf24e
daf24e
	printf '\n\n' >&3
daf24e
daf24e
	# execute
daf24e
	if eval $mb_cfghost_cc "$ccenv_tmpname" -o a.out    \
daf24e
			$(printf '%s' "$mb_cfghost_cflags") \
daf24e
			2>&3; then
daf24e
		rm a.out
daf24e
		rm $mb_cfghost_tmpname
daf24e
		mb_cfghost_ret=0
daf24e
	else
daf24e
		mb_cfghost_ret=1
daf24e
	fi
daf24e
daf24e
	if [ $mb_cfghost_ret = 0 ]; then
daf24e
		output_step_epilog
daf24e
		return 0
daf24e
	fi
092ccd
a341a9
	# should never happen
daf24e
	error_msg
092ccd
	error_msg "configure was able to generate a Makefile for the selected host,"
092ccd
	error_msg "however the host-targeting compiler was found to be missing"
092ccd
	error_msg "at least one of the required headers or features."
092ccd
	exit 2
092ccd
}
092ccd
092ccd
092ccd
config_fini()
092ccd
{
092ccd
	# project-specific post-configuration steps
092ccd
	if [ _$mb_use_custom_cfgfini = _yes ]; then
092ccd
		. "$mb_project_dir/project/config/cfgfini.sh"
092ccd
	fi
092ccd
}
092ccd
092ccd
092ccd
config_status()
092ccd
{
092ccd
	output_script_status ${mb_script} \
092ccd
		'configuration completed successfully.'
092ccd
	printf '\n'
092ccd
}
092ccd
092ccd
092ccd
config_failure()
092ccd
{
092ccd
	if [ _$mb_success = _yes ]; then
092ccd
		return 0
092ccd
	fi
092ccd
092ccd
	printf 'configure info: exiting due to an error.\n' >&3
092ccd
092ccd
	exit 2
092ccd
}
092ccd
092ccd
092ccd
config_success()
092ccd
{
092ccd
	trap '' EXIT
092ccd
	mb_success=yes
092ccd
	exit 0
092ccd
}
092ccd
092ccd
092ccd
# one: init
092ccd
mb_args_defs=
092ccd
mb_args_text=
092ccd
mb_args_idx=0
092ccd
092ccd
init_log
092ccd
092ccd
for arg ; do
092ccd
	mb_args_idx=$((mb_args_idx+1))
092ccd
092ccd
	mb_arg_def=$(printf '%s%s="${%s}"' "-D_" "${mb_args_idx}" "${mb_args_idx}")
092ccd
	eval mb_args_defs='"$mb_args_defs "$mb_arg_def'
092ccd
092ccd
	mb_args_text="$mb_args_text '_$((mb_args_idx))'"
092ccd
done
092ccd
092ccd
printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
092ccd
092ccd
if [ $mb_args_idx -gt 1 ]; then
092ccd
	printf '$ %s' "$mb_script" >&3
092ccd
092ccd
	mb_args_idx=0
092ccd
	mb_args_text=
092ccd
092ccd
	for arg; do
092ccd
		mb_args_idx=$((mb_args_idx+1))
092ccd
		mb_args_text="$mb_args_text"$(printf ' \\\\\n\t%s_%d%s' "'" "$mb_args_idx" "'")
092ccd
	done
092ccd
092ccd
	printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
092ccd
fi
092ccd
092ccd
init_vars
092ccd
verify_build_directory
092ccd
092ccd
092ccd
# two: args
092ccd
for arg ; do
092ccd
	case "$arg" in
092ccd
		--help)
092ccd
			usage
092ccd
			;;
092ccd
		--help=ccenv)
092ccd
			ccenv_usage
092ccd
			;;
092ccd
092ccd
		# ccenv
092ccd
		--cross-compile=*)
092ccd
			mb_cross_compile=${arg#*=}
092ccd
			;;
092ccd
		--compiler=*)
092ccd
			mb_compiler=${arg#*=}
092ccd
			;;
092ccd
		--toolchain=*)
092ccd
			mb_toolchain=${arg#*=}
092ccd
			;;
092ccd
		--zealous)
092ccd
			mb_agnostic=yes
092ccd
			mb_zealous=
092ccd
			;;
092ccd
		--zealous=*)
092ccd
			mb_zealous=${arg#*=}
092ccd
			;;
092ccd
		--ccenv=*)
092ccd
			mb_ccenv=${arg#*=}
092ccd
			;;
092ccd
092ccd
		# dirs
092ccd
		--prefix=*)
092ccd
			mb_prefix_set=yes
092ccd
			mb_prefix=${arg#*=}
092ccd
			;;
092ccd
		--exec-prefix=*)
092ccd
			mb_exec_prefix_set=yes
092ccd
			mb_exec_prefix=${arg#*=}
092ccd
			;;
092ccd
		--bindir=*)
092ccd
			mb_bindir_set=yes
092ccd
			mb_bindir=${arg#*=}
092ccd
			;;
092ccd
		--sbindir=*)
092ccd
			mb_sbindir=${arg#*=}
092ccd
			;;
092ccd
		--libdir=*)
092ccd
			mb_libdir=${arg#*=}
092ccd
			;;
092ccd
		--includedir=*)
092ccd
			mb_includedir=${arg#*=}
092ccd
			;;
092ccd
		--oldincludedir=*)
092ccd
			mb_oldincludedir=${arg#*=}
092ccd
			;;
092ccd
		--mandir=*)
092ccd
			mb_mandir=${arg#*=}
092ccd
			;;
092ccd
		--libexecdir=*)
092ccd
			mb_libexecdir=${arg#*=}
092ccd
			;;
092ccd
092ccd
092ccd
		--sysconfdir=*)
092ccd
			mb_sysconfdir=${arg#*=}
092ccd
			;;
092ccd
		--sharedstatedir=*)
092ccd
			mb_sharedstatedir=${arg#*=}
092ccd
			;;
092ccd
		--localstatedir=*)
092ccd
			mb_localstatedir=${arg#*=}
092ccd
			;;
092ccd
		--runstatedir=*)
092ccd
			mb_runstatedir=${arg#*=}
092ccd
			;;
092ccd
		--datarootdir=*)
092ccd
			mb_datarootdir=${arg#*=}
092ccd
			;;
092ccd
		--datadir=*)
092ccd
			mb_datadir=${arg#*=}
092ccd
			;;
092ccd
		--infodir=*)
092ccd
			mb_infodir=${arg#*=}
092ccd
			;;
092ccd
		--localedir=*)
092ccd
			mb_localedir=${arg#*=}
092ccd
			;;
092ccd
		--htmldir=*)
092ccd
			mb_htmldir=${arg#*=}
092ccd
			;;
092ccd
		--dvidir=*)
092ccd
			mb_dvidir=${arg#*=}
092ccd
			;;
092ccd
		--pdfdir=*)
092ccd
			mb_pdfdir=${arg#*=}
092ccd
			;;
092ccd
		--psdir=*)
092ccd
			mb_psdir=${arg#*=}
092ccd
			;;
092ccd
092ccd
		#make
092ccd
		--make=*)
092ccd
			mb_make=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--makemode=*)
092ccd
			mb_makemode=${arg#*=}
092ccd
			;;
092ccd
9944d7
		#pkgconf[ig]
9944d7
		--pkgconf=*)
9944d7
			mb_pkgconf=${arg#*=}
9944d7
			;;
9944d7
9944d7
		--pkgconfig=*)
9944d7
			mb_pkgconf=${arg#*=}
9944d7
			;;
9944d7
092ccd
		# build
092ccd
		--build=*)
092ccd
			mb_build=${arg#*=}
092ccd
			;;
092ccd
		--host=*)
092ccd
			mb_host=${arg#*=}
092ccd
			;;
092ccd
		--cchost=*)
092ccd
			mb_cchost=${arg#*=}
d4aea0
			mb_cchost_set=yes
092ccd
			;;
092ccd
		--cfghost=*)
092ccd
			mb_cfghost=${arg#*=}
092ccd
			;;
092ccd
		--target=*)
092ccd
			mb_target=${arg#*=}
092ccd
			;;
092ccd
		--arch=*)
092ccd
			mb_arch=${arg#*=}
092ccd
			;;
092ccd
		--sysroot=*)
092ccd
			mb_sysroot=${arg#*=}
092ccd
			;;
092ccd
		--shell=*)
092ccd
			mb_shell=${arg#*=}
092ccd
			;;
092ccd
		--debug)
092ccd
			mb_debug=yes
092ccd
			;;
092ccd
092ccd
		# config
092ccd
		--all-static)
092ccd
			mb_all_static=yes
092ccd
			mb_all_shared=no
092ccd
			;;
092ccd
		--all-shared)
092ccd
			mb_all_shared=yes
092ccd
			mb_all_static=no
092ccd
			;;
092ccd
		--disable-frontend)
092ccd
			mb_disable_frontend=yes
092ccd
			;;
092ccd
		--disable-app)
092ccd
			mb_disable_frontend=yes
092ccd
			;;
092ccd
		--enable-frontend)
092ccd
			mb_disable_frontend='no'
092ccd
			;;
092ccd
		--enable-app)
092ccd
			mb_disable_frontend='no'
092ccd
			;;
092ccd
		--disable-static)
092ccd
			mb_disable_static=yes
092ccd
			;;
092ccd
		--disable-shared)
092ccd
			mb_disable_shared=yes
092ccd
			;;
092ccd
		--enable-static)
092ccd
			mb_disable_static='no'
092ccd
			;;
092ccd
		--enable-shared)
092ccd
			mb_disable_shared='no'
092ccd
			;;
092ccd
092ccd
		# convenience
092ccd
		--strict)
092ccd
			mb_ccstrict=yes
092ccd
			mb_ldstrict=yes
092ccd
			;;
092ccd
		--ccstrict)
092ccd
			mb_ccstrict=yes
092ccd
			;;
092ccd
		--ldstrict)
092ccd
			mb_ldstrict=yes
092ccd
			;;
092ccd
092ccd
		# project
092ccd
		--nickname=*)
092ccd
			mb_nickname=${arg#*=}
092ccd
			;;
092ccd
		--program-prefix=*)
092ccd
			mb_program_prefix=${arg#*=}
092ccd
			;;
092ccd
		--avoid-version)
092ccd
			mb_avoid_version=yes
092ccd
			;;
092ccd
		--source-dir=*)
092ccd
			mb_source_dir=${arg#*=}
092ccd
			mb_source_dir_set=yes
092ccd
			;;
092ccd
		--srcdir=*)
092ccd
			mb_source_dir=${arg#*=}
092ccd
			mb_source_dir_set=yes
092ccd
			;;
092ccd
092ccd
		# pkgconfig
092ccd
		--pkgname=*)
092ccd
			mb_pkgname=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkgdesc=*)
092ccd
			mb_pkgdesc=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkgusrc=*)
092ccd
			mb_pkgusrc=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkgrepo=*)
092ccd
			mb_pkgrepo=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkgpsrc=*)
092ccd
			mb_pkgpsrc=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkgdurl=*)
092ccd
			mb_pkgdurl=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkgbugs=*)
092ccd
			mb_pkgbugs=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkghome=*)
092ccd
			mb_pkghome=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkgdefs=*)
092ccd
			mb_pkgdefs=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pkglibs=*)
092ccd
			mb_pkglibs=${arg#*=}
092ccd
			;;
092ccd
092ccd
		# srcinfo
092ccd
		--srcinfo=*)
092ccd
			mb_srcinfo=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--srcsite=*)
092ccd
			mb_srcsite=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pgprkey=*)
092ccd
			mb_pgprkey=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--pgpskey=*)
092ccd
			mb_pgpskey=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--rawball=*)
092ccd
			mb_rawball=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--rawball-url=*)
092ccd
			mb_rawball_url=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--rawball-sha256=*)
092ccd
			mb_rawball_sha256=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--modball=*)
092ccd
			mb_modball=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--modball-url=*)
092ccd
			mb_modball_url=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--modball-sha256=*)
092ccd
			mb_modball_sha256=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--srcball=*)
092ccd
			mb_srcball=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--srcball-url=*)
092ccd
			mb_srcball_url=${arg#*=}
092ccd
			;;
092ccd
092ccd
		--srcball-sha256=*)
092ccd
			mb_srcball_sha256=${arg#*=}
092ccd
			;;
092ccd
092ccd
		# compatibility
092ccd
		--enable-dependency-tracking)
092ccd
			;;
092ccd
		--disable-dependency-tracking)
092ccd
			;;
092ccd
092ccd
		*)
092ccd
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
092ccd
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
092ccd
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
092ccd
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
092ccd
				mb_custom_cfgdefs_space=' '
092ccd
			else
092ccd
				error_msg ${arg#}: "unsupported config argument."
092ccd
				exit 2
092ccd
			fi
092ccd
			;;
092ccd
	esac
092ccd
092ccd
	mb_safe_path_desc='source directory'
092ccd
	mb_safe_path_name="$mb_source_dir"
092ccd
	verify_safe_path
092ccd
done
092ccd
092ccd
092ccd
092ccd
# three: validation
092ccd
verify_source_directory
092ccd
verify_source_info
092ccd
092ccd
if ! [ -z "$mb_program_prefix" ]; then
092ccd
	error_msg "--program-prefix is not yet fully support (must be null)."
092ccd
fi
092ccd
092ccd
092ccd
092ccd
# four: defaults
092ccd
common_defaults
092ccd
092ccd
092ccd
# five: config
092ccd
config_flags
092ccd
config_opts
092ccd
config_copy
092ccd
config_ccenv
092ccd
config_custom
092ccd
config_cfghost
092ccd
config_host
092ccd
config_fini
092ccd
config_status
092ccd
092ccd
092ccd
# all done
092ccd
config_success