Blame configure

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