Blame configure

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