Blame configure

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