Blame configure

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