Blame configure

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