Blame configure

52d60d
#!/bin/sh
52d60d
d0e2c6
# project-agnostic ./configure script, written by hand.
d0e2c6
# this file is covered by COPYING.SOFORT.
d0e2c6
0bcce4
set -eu
0bcce4
1a8cc6
trap config_failure 1 2 EXIT
1a8cc6
df59ab
# before we begin...
df59ab
mb_path="$PATH"
a0f28b
mb_script="$0"
a0f28b
mb_success=no
df59ab
52d60d
usage()
52d60d
{
98322c
	cat "$mb_project_dir"/config.usage
c9d763
e60976
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
c9d763
		printf '\n\n%s%s\n' \
c9d763
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
c9d763
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
c9d763
c9d763
		printf '%s%s\n' \
c9d763
			"| Listed above are configure's common switches " \
c9d763
			"and environment variables.     |"
c9d763
c9d763
		printf '%s%s\n' \
c9d763
			"| Found below are project-specific variables " \
c9d763
			"and other customization options. |"
c9d763
c9d763
		printf '%s%s\n\n\n' \
c9d763
			" ___________________________________________" \
c9d763
			"__________________________________"
c9d763
c9d763
		cat "$mb_project_dir"/project/config/cfgdefs.usage
c9d763
	fi
c9d763
c9d763
	exit 0
52d60d
}
52d60d
52d60d
error_msg()
52d60d
{
dd4afc
	printf '%s\n' "$@" >&2
52d60d
}
52d60d
1f0e35
warning_msg()
1f0e35
{
dd4afc
	printf '%s\n' "$@" >&2
1f0e35
}
1f0e35
b5f5b5
output_step_prolog()
b5f5b5
{
ae54fb
	mb_line_dots='.................................'
ae54fb
	mb_line_dots="${mb_line_dots}.${mb_line_dots}"
ae54fb
	mb_step_desc="${mb_package} : ${1##*/} : ${2}()  "
b5f5b5
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
e119f1
e119f1
	printf "configure step: ${2}()\n" >&3
ae54fb
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s  " "${mb_step_desc}" "${mb_line_dots}"
b5f5b5
}
b5f5b5
b5f5b5
output_step_epilog()
b5f5b5
{
b5f5b5
	printf 'OK.\n'
b5f5b5
}
b5f5b5
b5f5b5
output_script_status()
b5f5b5
{
b5f5b5
	mb_step_name="${1##*/} : ${2}"
b5f5b5
	mb_step_desc="${mb_package} : ${mb_step_name}"
e119f1
e119f1
	printf "configure info: ${2}\n" >&3
b5f5b5
	printf "%s\n" "${mb_step_desc}"
b5f5b5
}
b5f5b5
b5f5b5
output_section_break()
b5f5b5
{
06b7a4
	printf ' ..\n'
b5f5b5
}
b5f5b5
39bc3b
verify_safe_path()
39bc3b
{
39bc3b
	case "$mb_safe_path_name" in
39bc3b
		-*)
39bc3b
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
39bc3b
			exit 2
39bc3b
			;;
39bc3b
39bc3b
		*\ *)
39bc3b
			error_msg "$mb_safe_path_desc may not contain spaces."
39bc3b
			exit 2
39bc3b
			;;
39bc3b
	esac
39bc3b
}
52d60d
e119f1
init_log()
e119f1
{
e119f1
	exec 3> config.log
e119f1
e119f1
	printf "This is config.log, generated by sofort's configure script.\n\n" >&3
e119f1
	printf '$ %s' "$mb_script" >&3
e119f1
}
e119f1
52d60d
init_vars()
52d60d
{
5f9ced
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
7cd8f2
	mb_pwd=$(pwd -P)
52d60d
39bc3b
	mb_safe_path_desc='project directory'
39bc3b
	mb_safe_path_name="$mb_project_dir"
39bc3b
	verify_safe_path
39bc3b
39bc3b
	mb_safe_path_desc='working directory'
39bc3b
	mb_safe_path_name="$mb_pwd"
39bc3b
	verify_safe_path
39bc3b
f4662b
	mb_custom_cfgdefs_args=''
f4662b
	mb_custom_cfgdefs_space=''
f4662b
0feda5
	mb_srcinfo='$(PROJECT_DIR)/project/srcdist/srcinfo.in'
0feda5
	mb_srcsite='localhost'
0feda5
0feda5
	mb_pgprkey='!!VARIABLE_NOT_SET!!'
0feda5
	mb_pgpskey='!!VARIABLE_NOT_SET!!'
0feda5
d0476e
	sfrt_impl_dir=$mb_project_dir/sofort
d0476e
	sfrt_config_dir=$sfrt_impl_dir/config
d0476e
	sfrt_core_dir=$sfrt_impl_dir/core
d0476e
	sfrt_config_vars=$sfrt_config_dir/config.vars
d0476e
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
fc6f51
	sfrt_opt_vars=$sfrt_config_dir/opt.vars
d0476e
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
d0476e
151b2b
	mb_make_vars=$(< "$sfrt_config_vars" \
151b2b
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
2490ea
151b2b
	mb_impl_vars=$(< "$sfrt_config_vars" \
151b2b
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
c3272a
151b2b
	mb_proj_vars=$(< "$sfrt_config_vars" \
151b2b
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
c3272a
151b2b
	mb_flag_vars=$(< "$sfrt_flag_vars" \
151b2b
		grep -v -e '^#' -e '^$')
c3272a
c3272a
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
c3272a
cd0e7f
	for mb_var in $(printf '%s' "$mb_vars") ; do
2490ea
		mb_expr=$mb_var='${'$mb_var':-}'
2490ea
		eval "$mb_expr"
2490ea
	done
2490ea
937cce
	# cfgtest
937cce
	. $mb_project_dir/sofort/cfgtest/cfgtest.sh
937cce
1a1e15
	# ccenv
1a1e15
	. $mb_project_dir/sofort/ccenv/ccenv.sh
1a1e15
19dcd9
	if ! [ -L ./ccenv ]; then
1a1e15
		if [ -d ./ccenv ]; then
1a1e15
			rm -f ./ccenv/host.mk
1a1e15
			rm -f ./ccenv/native.mk
1a1e15
			rmdir ./ccenv
1a1e15
		fi
1a1e15
	fi
1a1e15
1a1e15
	# config.project
011344
	if [ -z "$mb_config" ]; then
656d4f
		mb_config="$mb_project_dir/config.project"
656d4f
	fi
656d4f
656d4f
	. "$mb_config"
656d4f
e55a71
	# config.project make preferences
e55a71
	if [ -z "${MAKE}" ]; then
e55a71
		MAKE="$mb_make"
e55a71
	fi
e55a71
e55a71
	if [ -z "${MAKEMODE}" ]; then
e55a71
		MAKEMODE="$mb_makemode"
e55a71
	fi
e55a71
4b6573
4b6573
	if [ -z "$mb_makefile" ]; then
4b6573
		mb_makefile='Makefile'
4b6573
	fi
4b6573
e50c3b
	# pkgconf (host)
e50c3b
	if [ -z "${PKGCONF}" ]; then
e50c3b
		PKGCONF="$mb_pkgconf"
e50c3b
	fi
e50c3b
e50c3b
	if [ -z "${PKGCONF}" ]; then
e50c3b
		PKGCONF="${PKGCONFIG}"
e50c3b
	fi
e50c3b
e50c3b
	# pkgconf (native)
e50c3b
	if [ -z "${NATIVE_PKGCONF}" ]; then
e50c3b
		NATIVE_PKGCONF="$mb_native_pkgconf"
e50c3b
	fi
e50c3b
e50c3b
	if [ -z "${NATIVE_PKGCONF}" ]; then
e50c3b
		NATIVE_PKGCONF="${NATIVE_PKGCONFIG}"
e50c3b
	fi
e50c3b
1434c9
	# project-specific initialization
1434c9
	if [ _$mb_use_custom_cfginit = _yes ]; then
1434c9
		. "$mb_project_dir/project/config/cfginit.sh"
1434c9
	fi
1434c9
656d4f
	# package
656d4f
	if [ -z "$mb_package" ]; then
656d4f
		error_msg "$mb_script: incomplete information in $mb_config."
656d4f
		error_msg "$mb_script: \$mb_package not set."
656d4f
		exit 1
52d60d
	fi
52d60d
08ac50
	if [ -z "${NICKNAME}" ]; then
08ac50
		NICKNAME="$mb_nickname"
08ac50
	fi
08ac50
22ff07
	# srcinfo
22ff07
	if [ -n "$SOURCE_DIR" ]; then
22ff07
		mb_source_dir_set=yes
22ff07
	fi
22ff07
e2a544
	# cchost
e2a544
	if [ -n "$CCHOST" ]; then
e2a544
		mb_cchost_set=yes
e2a544
	fi
e2a544
b5f5b5
	# step prolog
b5f5b5
	output_step_prolog ${mb_script} 'init_vars'
b5f5b5
5b49a6
	# project
5b49a6
	mb_nickname=$NICKNAME
7b4710
	mb_source_dir=$SOURCE_DIR
5b49a6
52d60d
	# dirs
52d60d
	mb_prefix=$PREFIX
452aa8
	mb_exec_prefix=$EXEC_PREFIX
52d60d
	mb_bindir=$BINDIR
7ef888
	mb_sbindir=$SBINDIR
52d60d
	mb_libdir=$LIBDIR
52d60d
	mb_includedir=$INCLUDEDIR
00d77f
	mb_oldincludedir=$OLDINCLUDEDIR
52d60d
	mb_mandir=$MANDIR
52d60d
	mb_docdir=$DOCDIR
52d60d
	mb_libexecdir=$LIBEXECDIR
52d60d
00d77f
	mb_sysconfdir=$SYSCONFDIR
00d77f
	mb_sharedstatedir=$SHAREDSTATEDIR
00d77f
	mb_localstatedir=$LOCALSTATEDIR
00d77f
	mb_runstatedir=$RUNSTATEDIR
00d77f
	mb_datarootdir=$DATAROOTDIR
00d77f
	mb_datadir=$DATADIR
00d77f
	mb_infodir=$INFODIR
00d77f
	mb_localedir=$LOCALEDIR
00d77f
	mb_htmldir=$HTMLDIR
00d77f
	mb_dvidir=$DVIDIR
00d77f
	mb_pdfdir=$PDFDIR
00d77f
	mb_psdir=$PSDIR
00d77f
7ab7c8
	# make
7ab7c8
	mb_make=$MAKE
2fc574
	mb_makemode=$MAKEMODE
52d60d
52d60d
	# build
52d60d
	mb_build=$BUILD
927e2d
	mb_cchost=$CCHOST
1b579f
	mb_cfghost=$CFGHOST
52d60d
	mb_arch=$ARCH
220bb3
	mb_compiler=$COMPILER
2c5c40
	mb_toolchain=$TOOLCHAIN
52d60d
	mb_sysroot=$SYSROOT
52d60d
	mb_cross_compile=$CROSS_COMPILE
52d60d
	mb_shell=$SHELL
52d60d
e50c3b
	# pkgconf
e50c3b
	mb_pkgconf=$PKGCONF
e50c3b
52d60d
	# switches
52d60d
	mb_cflags=$CFLAGS
52d60d
	mb_cflags_debug=$CFLAGS_DEBUG
52d60d
	mb_cflags_common=$CFLAGS_COMMON
52d60d
	mb_cflags_cmdline=$CFLAGS_CMDLINE
52d60d
	mb_cflags_config=$CFLAGS_CONFIG
52d60d
	mb_cflags_sysroot=$CFLAGS_SYSROOT
5b49a6
	mb_cflags_os=$CFLAGS_OS
5b49a6
	mb_cflags_site=$CFLAGS_SITE
52d60d
	mb_cflags_path=$CFLAGS_PATH
5b49a6
	mb_cflags_strict=$CFLAGS_STRICT
5b49a6
	mb_cflags_util=$CFLAGS_UTIL
4c529e
	mb_cflags_last=$CFLAGS_LAST
4c529e
	mb_cflags_once=$CFLAGS_ONCE
52d60d
52d60d
	mb_ldflags=$LDFLAGS
52d60d
	mb_ldflags_debug=$LDFLAGS_DEBUG
52d60d
	mb_ldflags_common=$LDFLAGS_COMMON
52d60d
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
52d60d
	mb_ldflags_config=$LDFLAGS_CONFIG
52d60d
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
52d60d
	mb_ldflags_path=$LDFLAGS_PATH
5b49a6
	mb_ldflags_strict=$LDFLAGS_STRICT
5b49a6
	mb_ldflags_util=$LDFLAGS_UTIL
4c529e
	mb_ldflags_last=$LDFLAGS_LAST
4c529e
	mb_ldflags_once=$LDFLAGS_ONCE
52d60d
52d60d
	mb_pe_subsystem=$PE_SUBSYSTEM
52d60d
	mb_pe_image_base=$PE_IMAGE_BASE
52d60d
52d60d
	# overrides
52d60d
	mb_user_cc=$CC
52d60d
	mb_user_cpp=$CPP
52d60d
	mb_user_cxx=$CXX
1a1e15
1a1e15
	mb_native_cc=$NATIVE_CC
1a1e15
	mb_native_cpp=$NATIVE_CPP
1a1e15
	mb_native_cxx=$NATIVE_CXX
1a1e15
1a1e15
	mb_native_host=$NATIVE_HOST
1a1e15
	mb_native_cfghost=$NATIVE_CFGHOST
1a1e15
	mb_native_cflags=$NATIVE_CFLAGS
1a1e15
	mb_native_ldflags=$NATIVE_LDFLAGS
75f1da
e50c3b
	mb_native_pkgconf=$NATIVE_PKGCONF
e50c3b
75f1da
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
75f1da
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
b5f5b5
b5f5b5
	# step epilog
b5f5b5
	output_step_epilog
52d60d
}
52d60d
52d60d
52d60d
verify_build_directory()
52d60d
{
b5f5b5
	output_step_prolog ${mb_script} 'verify_build_directory'
b5f5b5
011344
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
e60976
		if [ _$mb_require_out_of_tree = _yes ]; then
52d60d
			error_msg "$mb_package: out-of-tree builds are required."
52d60d
			error_msg "please invoke configure again from a clean build directory."
1ab9f8
			exit 1
52d60d
		else
52d60d
			mb_project_dir='.'
52d60d
		fi
52d60d
	fi
1a8cc6
e6281a
	if [ -f "$mb_pwd/Makefile.common" ]; then
e6281a
		error_msg
e6281a
		error_msg "$mb_package: the file-name Makefile.common is reserved for bootstrapping projects."
e6281a
		error_msg "$mb_package: please remove or rename the file manually and then re-run configure."
e6281a
		exit 1
e6281a
	fi
e6281a
4b6573
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed $mb_makefile
b5f5b5
b5f5b5
	output_step_epilog
52d60d
}
52d60d
52d60d
7b4710
verify_source_directory()
7b4710
{
b5f5b5
	output_step_prolog ${mb_script} 'verify_source_directory'
b5f5b5
5e256a
	if [ _"$mb_source_dir" != _${mb_source_dir##* } ]; then
5e256a
		error_msg "source directory path contains spaces, aborting."
5e256a
		exit 1
5e256a
	fi
5e256a
5e256a
	eval mb_source_dir=$(printf '%s' "$mb_source_dir")
5e256a
7b4710
	if [ -z "$mb_source_dir" ]; then
e60976
		if [ _$mb_require_source_dir = _yes ]; then
7b4710
			error_msg "$mb_package: specifying an external source directory is required."
7b4710
			error_msg "you can set the source directory either via --source-dir=<path>,"
7b4710
			error_msg "or by setting the SOURCE_DIR variable."
1ab9f8
			exit 1
7b4710
		fi
7b4710
	fi
b5f5b5
b5f5b5
	output_step_epilog
7b4710
}
7b4710
7b4710
22ff07
verify_source_info()
22ff07
{
22ff07
	output_step_prolog ${mb_script} 'verify_source_info'
22ff07
22ff07
	if [ "${mb_source_dir_set:-}" = yes ]; then
22ff07
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ] || [ -n "$mb_srcball" ]; then
22ff07
			error_msg "$mb_package: conflicting arguments: --rawball/--modball/--srcball arguments"
22ff07
			error_msg "may not be used together with an explicit source-dir argument or variable."
22ff07
			exit 1
22ff07
		fi
22ff07
	fi
22ff07
22ff07
	if [ -n "$mb_srcball" ]; then
22ff07
		eval mb_srcball=$(printf '%s' "$mb_srcball")
22ff07
22ff07
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ]; then
22ff07
			error_msg "$mb_package: conflicting arguments: --rawball and/or --modball arguments"
22ff07
			error_msg "may not be used together with an explicitly --srcball argument."
22ff07
			exit 1
22ff07
		fi
22ff07
22ff07
		if [ -z "$mb_srcball_sha256" ]; then
22ff07
			error_msg "$mb_package: --srcball-sha256 must be provided"
22ff07
			error_msg "in conjunction with --srcball."
22ff07
			exit 1
22ff07
		fi
22ff07
22ff07
		mb_srcball_sha256_test=$(sha256sum "$mb_srcball")
22ff07
		mb_srcball_sha256_test="${mb_srcball_sha256_test%% *}"
22ff07
22ff07
		if [ "$mb_srcball_sha256_test" != "$mb_srcball_sha256" ]; then
22ff07
			error_msg "$mb_package: sha256 signature of srcball $mb_srcball does not match!"
22ff07
			exit 1
22ff07
		fi
22ff07
22ff07
		mb_srcball_topdir=$(xz -c -d "$mb_srcball" | pax | sed -n '1,1p')
22ff07
		mb_source_dir="./srctree/$mb_package/${mb_srcball_topdir%/}"
22ff07
22ff07
		mb_srcball_dirname=$(cd -- "${mb_srcball%/*}" ; pwd -P)
22ff07
		mb_srcball_basename=${mb_srcball##*/}
22ff07
		mb_srcball="$mb_srcball_dirname/$mb_srcball_basename"
22ff07
22ff07
		mkdir -p "./srctree/$mb_package"
22ff07
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_srcball" | pax -r)
22ff07
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
22ff07
	fi
22ff07
22ff07
	if [ -z "$mb_rawball" ] && [ -n "$mb_modball" ]; then
22ff07
		error_msg "$mb_package: conflicting arguments: --modball argument may only be used"
22ff07
		error_msg "together with an explicit --rawball argument."
22ff07
		exit 1
22ff07
	fi
22ff07
22ff07
	if [ -n "$mb_modball" ]; then
22ff07
		eval mb_modball=$(printf '%s' "$mb_modball")
22ff07
22ff07
		if [ -z "$mb_modball_sha256" ]; then
22ff07
			error_msg "$mb_package: --modball-sha256 must be provided"
22ff07
			error_msg "in conjunction with --modball."
22ff07
			exit 1
22ff07
		fi
22ff07
22ff07
		mb_modball_sha256_test=$(sha256sum "$mb_modball")
22ff07
		mb_modball_sha256_test="${mb_modball_sha256_test%% *}"
22ff07
22ff07
		if [ "$mb_modball_sha256_test" != "$mb_modball_sha256" ]; then
22ff07
			error_msg "$mb_package: sha256 signature of modball $mb_modball does not match!"
22ff07
			exit 1
22ff07
		fi
22ff07
	fi
22ff07
22ff07
	if [ -n "$mb_rawball" ]; then
22ff07
		eval mb_rawball=$(printf '%s' "$mb_rawball")
22ff07
22ff07
		if [ -z "$mb_rawball_sha256" ]; then
22ff07
			error_msg "$mb_package: --rawball-sha256 must be provided."
22ff07
			error_msg "in conjunction with --rawball."
22ff07
			exit 1
22ff07
		fi
22ff07
22ff07
		mb_rawball_sha256_test=$(sha256sum "$mb_rawball")
22ff07
		mb_rawball_sha256_test="${mb_rawball_sha256_test%% *}"
22ff07
22ff07
		if [ "$mb_rawball_sha256_test" != "$mb_rawball_sha256" ]; then
22ff07
			error_msg "$mb_package: sha256 signature of rawball $mb_rawball does not match!"
22ff07
			exit 1
22ff07
		fi
22ff07
22ff07
		mb_rawball_topdir=$(xz -c -d "$mb_rawball" | pax | sed -n '1,1p')
22ff07
		mb_source_dir="./srctree/$mb_package/${mb_rawball_topdir%/}"
22ff07
22ff07
		mb_rawball_dirname=$(cd -- "${mb_rawball%/*}" ; pwd -P)
22ff07
		mb_rawball_basename=${mb_rawball##*/}
22ff07
		mb_rawball="$mb_rawball_dirname/$mb_rawball_basename"
22ff07
22ff07
		mkdir -p "./srctree/$mb_package"
22ff07
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_rawball" | pax -r)
22ff07
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
22ff07
	fi
22ff07
22ff07
	if [ -n "$mb_modball" ]; then
22ff07
		mb_modball_dirname=$(cd -- "${mb_modball%/*}" ; pwd -P)
22ff07
		mb_modball_basename=${mb_modball##*/}
22ff07
		mb_modball="$mb_modball_dirname/$mb_modball_basename"
22ff07
22ff07
		mb_modball_topdir="./modtree/$mb_package/$mb_modball_sha256"
22ff07
		mkdir -p "$mb_modball_topdir"
22ff07
		mb_modball_topdir=$(cd -- $mb_modball_topdir; pwd -P)
22ff07
		mb_dummy=$(cd -- "$mb_modball_topdir"; xz -c -d "$mb_modball" | pax -r)
22ff07
22ff07
		if [ -d "$mb_modball_topdir/overlay" ]; then
22ff07
			mb_dummy=$(cd -- "$mb_modball_topdir/overlay"; \
22ff07
				cp -p -P -R . "$mb_source_dir")
22ff07
		fi
22ff07
22ff07
		if [ -d "$mb_modball_topdir/patches" ]; then
22ff07
			mb_dummy=$(cd -- "$mb_source_dir";                        \
22ff07
				for p in $mb_modball_topdir/patches/*.patch; do  \
22ff07
					patch -p1 < $p;                         \
22ff07
				done);
22ff07
		fi
22ff07
	fi
22ff07
22ff07
	output_step_epilog
22ff07
}
22ff07
22ff07
52d60d
common_defaults()
52d60d
{
b5f5b5
	# step prolog
b5f5b5
	output_step_prolog ${mb_script} 'common_defaults'
b5f5b5
2f6758
	# project-specific config definitions
2f6758
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
2f6758
		cat $sfrt_cfgdefs_in > cfgdefs.mk
2f6758
	else
2f6758
		printf '%s %s\n\n' \
2f6758
				'# this project does not include' \
2f6758
				'a custom config step.'           \
2f6758
			> cfgdefs.mk
2f6758
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
2f6758
2f6758
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
2f6758
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
2f6758
		fi
2f6758
	fi
2f6758
2f6758
	# user build-time overrides
2f6758
	touch usrdefs.mk
2f6758
7b4710
	# git
7b4710
	if [ -n "$mb_source_dir" ]; then
7b4710
		if [ -d "$mb_source_dir/.git" ]; then
60c2b4
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
7b4710
		fi
7b4710
	elif [ -d "$mb_project_dir/.git" ]; then
60c2b4
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
7b4710
	fi
7b4710
5b49a6
	# project
b31d41
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
b31d41
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
b31d41
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
5b49a6
a4c3b9
	# pkgconfig
b31d41
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
b31d41
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
b31d41
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
b31d41
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
b31d41
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
b31d41
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
4046d2
	[ -n "$mb_pkgbugs" ]		|| mb_pkgbugs="$mb_default_pkgbugs"
4046d2
	[ -n "$mb_pkghome" ]		|| mb_pkghome="$mb_default_pkghome"
b31d41
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
b31d41
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
a4c3b9
22ff07
	# srcinfo
22ff07
	[ -n "$mb_rawball" ]		|| mb_rawball="$mb_default_rawball"
22ff07
	[ -n "$mb_rawball_url" ]	|| mb_rawball_url="$mb_default_rawball_url"
22ff07
	[ -n "$mb_rawball_sha256" ]	|| mb_rawball_sha256="$mb_default_rawball_sha256"
22ff07
	[ -n "$mb_modball" ]		|| mb_modball="$mb_default_modball"
22ff07
	[ -n "$mb_modball_url" ]	|| mb_modball_url="$mb_default_modball_url"
22ff07
	[ -n "$mb_modball_sha256" ]	|| mb_modball_sha256="$mb_default_modball_sha256"
22ff07
	[ -n "$mb_srcball" ]		|| mb_srcball="$mb_default_srcball"
22ff07
	[ -n "$mb_srcball_url" ]	|| mb_srcball_url="$mb_default_srcball_url"
22ff07
	[ -n "$mb_srcball_sha256" ]	|| mb_srcball_sha256="$mb_default_srcball_sha256"
22ff07
52d60d
	# dirs
b31d41
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
b31d41
					|| mb_prefix='/usr/local'
b31d41
b31d41
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
b31d41
					|| mb_exec_prefix=$mb_prefix
b31d41
b31d41
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
b31d41
					|| [ -n "$mb_bindir_basename" ] \
b31d41
					|| mb_bindir=$mb_exec_prefix/bin
b31d41
b31d41
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
b31d41
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
b31d41
b31d41
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
b31d41
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
b31d41
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
b31d41
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
b31d41
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
b31d41
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
601b9d
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc/'$(PACKAGE)'
b31d41
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
b31d41
b31d41
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
b31d41
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
b31d41
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
b31d41
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
b31d41
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
b31d41
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
b31d41
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
b31d41
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
b31d41
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
b31d41
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
b31d41
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
b31d41
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
00d77f
52d60d
	# switches
b31d41
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
b31d41
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
b31d41
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
b31d41
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
b31d41
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
b31d41
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
b31d41
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
b31d41
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
b31d41
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
b31d41
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
b31d41
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
b31d41
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
b31d41
b31d41
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
b31d41
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
b31d41
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
b31d41
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
b31d41
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
b31d41
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
b31d41
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
b31d41
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
b31d41
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
b31d41
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
52d60d
4eeeee
	# native switches
b31d41
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
b31d41
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
4eeeee
5b49a6
	# config
b31d41
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
b31d41
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
b31d41
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
b31d41
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
b31d41
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
5b49a6
52d60d
	# host/target
b31d41
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
b31d41
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
52d60d
52d60d
	# sysroot
011344
	if [ -n "$mb_sysroot" ]; then
011344
		if [ -z "$mb_cflags_sysroot" ]; then
52d60d
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
52d60d
		fi
52d60d
011344
		if [ -z "$mb_ldflags_sysroot" ]; then
fcf74e
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
52d60d
		fi
52d60d
	fi
52d60d
52d60d
	# debug
e60976
	if [ _$mb_debug = _yes ]; then
011344
		if [ -z "$mb_cflags_debug" ]; then
4a1565
			mb_cflags_debug='$(_CFLAGS_g3) $(_CFLAGS_O0)'
52d60d
		fi
52d60d
	fi
8fd4aa
7ab7c8
	# make
7ab7c8
	if [ -z "$mb_make" ]; then
7ab7c8
		mb_make='make'
7ab7c8
	fi
7ab7c8
2fc574
	if [ -z "$mb_makemode" ]; then
2fc574
		mb_makemode='posix'
6dcb42
6dcb42
		printf '%s\n%s\n%s\n\n%s\n\n'        \
6dcb42
				'ifeq (a,b)'          \
6dcb42
				'VAR = val'            \
6dcb42
				'endif'                 \
6dcb42
				'all:'                   \
6dcb42
			| ${mb_make} -s -f - 2>/dev/null  \
6dcb42
		&& mb_makemode='modern'
6dcb42
2fc574
	fi
2fc574
4d957b
	# shell
4d957b
	if [ -z "$mb_shell" ]; then
4d957b
		mb_shell='/bin/sh'
4d957b
	fi
4d957b
8fd4aa
	# inherited cflags & ldflags
8fd4aa
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
8fd4aa
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
b5f5b5
37120c
	# add the prefix's library directory to the linker library path
37120c
	mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
37120c
b5f5b5
	# step epilog
b5f5b5
	output_step_epilog
52d60d
}
52d60d
52d60d
5b49a6
config_flags()
5b49a6
{
b5f5b5
	# step prolog
b5f5b5
	output_step_prolog ${mb_script} 'config_flags'
b5f5b5
5b49a6
	mb_ldflags_tmp=" $mb_ldflags "
df3fea
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
5b49a6
5b49a6
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
5b49a6
		mb_ldflags="$mb_ldflags_libs"
5b49a6
		mb_ldflags_util="$mb_ldflags_util -static"
5b49a6
	fi
5b49a6
5b49a6
	# ccstrict
e60976
	if [ _$mb_ccstrict = _yes ]; then
2e3ac6
		mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef)'
5b49a6
	fi
5b49a6
5b49a6
	# ldstrict
e60976
	if [ _$mb_ldstrict = _yes ]; then
2e3ac6
		mb_ldflags_strict='$(_CFLAGS_Wl___no_undefined)'
5b49a6
	fi
b5f5b5
b5f5b5
	# step epilog
b5f5b5
	output_step_epilog
5b49a6
}
5b49a6
5b49a6
fc6f51
config_opts()
fc6f51
{
fc6f51
	if [ "$mb_avoid_version" = 'yes' ]; then
fc6f51
		mb_version_opt='none'
fc6f51
	else
fc6f51
		mb_version_opt='used'
fc6f51
	fi
4d730e
4d730e
	if [ "$mb_custom_install_headers" = 'yes' ]; then
4d730e
		mb_install_headers_opt='custom'
4d730e
	else
4d730e
		mb_install_headers_opt='default'
4d730e
	fi
4d730e
4d730e
	if [ "$mb_disable_static" = 'yes' ]; then
4d730e
		mb_static_library_opt='disabled'
4d730e
	else
4d730e
		mb_static_library_opt='enabled'
4d730e
	fi
4d730e
4d730e
	if [ "$mb_disable_shared" = 'yes' ]; then
4d730e
		mb_shared_library_opt='disabled'
4d730e
	else
4d730e
		mb_shared_library_opt='enabled'
4d730e
	fi
4d730e
4d730e
	if [ "$mb_disable_frontend" = 'yes' ]; then
4d730e
		mb_app_frontend_opt='disabled'
4d730e
	else
4d730e
		mb_app_frontend_opt='enabled'
4d730e
	fi
4d730e
4d730e
	if [ "$mb_all_static" = 'yes' ]; then
4d730e
		mb_app_linking_opt='all_static'
4d730e
4d730e
	elif [ "$mb_all_shared" = 'yes' ]; then
4d730e
		mb_app_linking_opt='all_shared'
4d730e
4d730e
	else
4d730e
		mb_app_linking_opt='default'
4d730e
	fi
fc6f51
}
fc6f51
52d60d
config_copy()
52d60d
{
b5f5b5
	output_step_prolog ${mb_script} 'config_copy'
b5f5b5
48e10d
	mb_var_defs=
48e10d
	mb_sed_substs=
2fad3a
	mb_template="${1:-$mb_project_dir/Makefile.in}"
48e10d
fc6f51
	mb_vars=$(cut -d'=' -f1 "$sfrt_config_vars" "$sfrt_opt_vars" \
48e10d
		| grep -v '^#');
48e10d
48e10d
	for __var in $(printf '%s' "$mb_vars"); do
48e10d
		mb_sed_subst=$(printf '%s %s%s%s'  \
48e10d
				'-e' "'s^@$__var@"  \
48e10d
				"^___${__var}___"    \
48e10d
				"^g'")
48e10d
48e10d
		mb_sed_substs="$mb_sed_substs $mb_sed_subst"
48e10d
48e10d
		mb_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "mb_${__var}")
48e10d
		eval mb_var_defs='"$mb_var_defs "$mb_var_def'
48e10d
	done
48e10d
2fad3a
	eval sed $mb_sed_substs $mb_template         \
2fad3a
			| eval m4 $mb_var_defs -      \
2fad3a
			| sed -e 's/[[:blank:]]*$//g'  \
48e10d
		> $mb_pwd/Makefile.tmp
b5f5b5
b5f5b5
	output_step_epilog
1a1e15
}
927e2d
c0640c
1a1e15
config_ccenv()
1a1e15
{
1a1e15
	mkdir -p ./ccenv
1a1e15
	touch ./ccenv/host.mk
1a1e15
	touch ./ccenv/native.mk
c9d763
b5f5b5
	output_section_break
1a1e15
	ccenv_set_host_variables
b5f5b5
b5f5b5
	output_section_break
1a1e15
	ccenv_set_native_variables
a6352c
b5f5b5
	output_section_break
a6352c
	config_copy
1a1e15
}
c9d763
232c53
config_custom_cfgdefs()
232c53
{
232c53
	. $mb_project_dir/project/config/cfgdefs.sh
232c53
}
232c53
c9d763
config_custom()
c9d763
{
e60976
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
b5f5b5
		output_section_break
b5f5b5
		output_script_status ${mb_script} \
e119f1
			'invoking project-specific cfgdefs.sh'
b5f5b5
232c53
		eval config_custom_cfgdefs "$mb_custom_cfgdefs_args"
b5f5b5
b5f5b5
		output_section_break
a90633
a90633
		if [ -f "$mb_project_dir/project/config/Makefile.in" ]; then
a90633
			config_copy "$mb_project_dir/project/config/Makefile.in"
a90633
			mv $mb_pwd/Makefile.tmp Makefile
a90633
		fi
a90633
c9d763
		config_copy
c9d763
	fi
927e2d
e60976
	if [ _$mb_use_custom_usrdefs = _yes ]; then
b5f5b5
		output_section_break
b5f5b5
		output_script_status ${mb_scirpt} \
e119f1
			'invoking project-specific usrdefs.sh'
b5f5b5
c9d763
		. $mb_project_dir/project/usrdefs.sh
b5f5b5
		output_section_break
c9d763
	fi
c9d763
}
c9d763
c9d763
c9d763
config_cfghost()
c9d763
{
b5f5b5
	output_step_prolog ${mb_script} 'config_cfghost'
b5f5b5
1b579f
	if [ -z "$mb_cfghost" ]; then
1b579f
		mb_cfghost=$mb_cchost
1b579f
	fi
1b579f
1b579f
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
1b579f
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
1ab9f8
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
927e2d
1ab9f8
	rm  $mb_pwd/Makefile.tmp
4b6573
	mv  $mb_pwd/Makefile.host $mb_pwd/$mb_makefile
b5f5b5
b5f5b5
	output_step_epilog
52d60d
}
52d60d
52d60d
52d60d
config_host()
52d60d
{
367f6e
	# init
b5f5b5
	output_step_prolog ${mb_script} 'config_host'
b5f5b5
367f6e
	mb_cfghost_cc="$ccenv_host_cc"
367f6e
	mb_cfghost_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
367f6e
367f6e
	mb_cfghost_cflags=$(${mb_make} -n -f "$mb_makefile" \
367f6e
		.cflags-host)
367f6e
367f6e
	mb_cfghost_cflags="${mb_cfghost_cflags#*: }"
367f6e
0f937f
	if [ "$mb_cc_environment" = 'freestanding' ]; then
b6267f
		if [ -z "mb_cc_underscore" ]; then
b6267f
			mb_cfghost_start_fn='_start'
b6267f
		else
b6267f
			mb_cfghost_start_fn='start'
b6267f
		fi
b6267f
b6267f
		printf 'int %s(void){return 0;}' "$mb_cfghost_start_fn" \
b6267f
			> "$mb_cfghost_tmpname"
b6267f
b6267f
		mb_cfghost_cflags="$mb_cfghost_cflags -ffreestanding"
b6267f
		mb_cfghost_cflags="$mb_cfghost_cflags -nostdlib"
b6267f
	else
b6267f
		printf 'int main(void){return 0;}' \
b6267f
			> "$mb_cfghost_tmpname"
b6267f
	fi
367f6e
367f6e
	# log
367f6e
	printf '\n' >&3
367f6e
367f6e
	printf '%s\n'                                         \
367f6e
		'#'                                           \
367f6e
		'# verify that that following combination of' \
367f6e
		'# host compiler and host cflags is working.' \
367f6e
		'#'                                           \
367f6e
		>&3
367f6e
367f6e
	printf '\n%s' "$mb_cfghost_cc $ccenv_tmpname -o a.out" >&3
367f6e
cf977d
	for mb_cfghost_cflag in $(printf '%s' "$mb_cfghost_cflags"); do
367f6e
		printf ' \\\n\t%s' "$mb_cfghost_cflag" >&3
367f6e
	done
367f6e
367f6e
	printf '\n\n' >&3
367f6e
367f6e
	# execute
367f6e
	if eval $mb_cfghost_cc "$ccenv_tmpname" -o a.out    \
367f6e
			$(printf '%s' "$mb_cfghost_cflags") \
367f6e
			2>&3; then
367f6e
		rm a.out
367f6e
		rm $mb_cfghost_tmpname
367f6e
		mb_cfghost_ret=0
367f6e
	else
367f6e
		mb_cfghost_ret=1
367f6e
	fi
367f6e
367f6e
	if [ $mb_cfghost_ret = 0 ]; then
367f6e
		output_step_epilog
367f6e
		return 0
367f6e
	fi
52d60d
4b6573
	# should never happen
367f6e
	error_msg
52d60d
	error_msg "configure was able to generate a Makefile for the selected host,"
220bb3
	error_msg "however the host-targeting compiler was found to be missing"
52d60d
	error_msg "at least one of the required headers or features."
52d60d
	exit 2
52d60d
}
52d60d
52d60d
1434c9
config_fini()
1434c9
{
1434c9
	# project-specific post-configuration steps
1434c9
	if [ _$mb_use_custom_cfgfini = _yes ]; then
1434c9
		. "$mb_project_dir/project/config/cfgfini.sh"
1434c9
	fi
1434c9
}
1434c9
1434c9
52d60d
config_status()
52d60d
{
b5f5b5
	output_script_status ${mb_script} \
b5f5b5
		'configuration completed successfully.'
b5f5b5
	printf '\n'
52d60d
}
52d60d
1a8cc6
1a8cc6
config_failure()
1a8cc6
{
c1591f
	if [ _$mb_success = _yes ]; then
c1591f
		return 0
c1591f
	fi
c1591f
e119f1
	printf 'configure info: exiting due to an error.\n' >&3
e119f1
1a8cc6
	exit 2
1a8cc6
}
1a8cc6
1a8cc6
1a8cc6
config_success()
1a8cc6
{
1a8cc6
	trap '' EXIT
c1591f
	mb_success=yes
1a8cc6
	exit 0
1a8cc6
}
1a8cc6
1a8cc6
52d60d
# one: init
5c5f93
mb_args_defs=
5c5f93
mb_args_text=
5c5f93
mb_args_idx=0
5c5f93
5c5f93
init_log
e119f1
e119f1
for arg ; do
5c5f93
	mb_args_idx=$((mb_args_idx+1))
5c5f93
5c5f93
	mb_arg_def=$(printf '%s%s="${%s}"' "-D_" "${mb_args_idx}" "${mb_args_idx}")
5c5f93
	eval mb_args_defs='"$mb_args_defs "$mb_arg_def'
5c5f93
5c5f93
	mb_args_text="$mb_args_text '_$((mb_args_idx))'"
e119f1
done
e119f1
5c5f93
printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
5c5f93
5c5f93
if [ $mb_args_idx -gt 1 ]; then
5c5f93
	printf '$ %s' "$mb_script" >&3
5c5f93
5c5f93
	mb_args_idx=0
5c5f93
	mb_args_text=
5c5f93
5c5f93
	for arg; do
5c5f93
		mb_args_idx=$((mb_args_idx+1))
5c5f93
		mb_args_text="$mb_args_text"$(printf ' \\\\\n\t%s_%d%s' "'" "$mb_args_idx" "'")
5c5f93
	done
5c5f93
5c5f93
	printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
5c5f93
fi
5c5f93
52d60d
init_vars
52d60d
verify_build_directory
52d60d
52d60d
52d60d
# two: args
52d60d
for arg ; do
52d60d
	case "$arg" in
1a1e15
		--help)
1a1e15
			usage
1a1e15
			;;
1a1e15
		--help=ccenv)
1a1e15
			ccenv_usage
1a1e15
			;;
1a1e15
1a1e15
		# ccenv
1a1e15
		--cross-compile=*)
1a1e15
			mb_cross_compile=${arg#*=}
1a1e15
			;;
1a1e15
		--compiler=*)
1a1e15
			mb_compiler=${arg#*=}
1a1e15
			;;
1a1e15
		--toolchain=*)
1a1e15
			mb_toolchain=${arg#*=}
1a1e15
			;;
1a1e15
		--zealous)
1a1e15
			mb_agnostic=yes
1a1e15
			mb_zealous=
1a1e15
			;;
1a1e15
		--zealous=*)
1a1e15
			mb_zealous=${arg#*=}
1a1e15
			;;
1a1e15
		--ccenv=*)
1a1e15
			mb_ccenv=${arg#*=}
52d60d
			;;
52d60d
52d60d
		# dirs
52d60d
		--prefix=*)
48b5b4
			mb_prefix_set=yes
52d60d
			mb_prefix=${arg#*=}
52d60d
			;;
452aa8
		--exec-prefix=*)
48b5b4
			mb_exec_prefix_set=yes
452aa8
			mb_exec_prefix=${arg#*=}
452aa8
			;;
52d60d
		--bindir=*)
09b3f4
			mb_bindir_set=yes
52d60d
			mb_bindir=${arg#*=}
52d60d
			;;
7ef888
		--sbindir=*)
7ef888
			mb_sbindir=${arg#*=}
7ef888
			;;
52d60d
		--libdir=*)
52d60d
			mb_libdir=${arg#*=}
52d60d
			;;
52d60d
		--includedir=*)
52d60d
			mb_includedir=${arg#*=}
52d60d
			;;
00d77f
		--oldincludedir=*)
00d77f
			mb_oldincludedir=${arg#*=}
00d77f
			;;
52d60d
		--mandir=*)
52d60d
			mb_mandir=${arg#*=}
52d60d
			;;
52d60d
		--libexecdir=*)
52d60d
			mb_libexecdir=${arg#*=}
52d60d
			;;
52d60d
52d60d
00d77f
		--sysconfdir=*)
00d77f
			mb_sysconfdir=${arg#*=}
00d77f
			;;
00d77f
		--sharedstatedir=*)
00d77f
			mb_sharedstatedir=${arg#*=}
00d77f
			;;
00d77f
		--localstatedir=*)
00d77f
			mb_localstatedir=${arg#*=}
00d77f
			;;
00d77f
		--runstatedir=*)
00d77f
			mb_runstatedir=${arg#*=}
00d77f
			;;
00d77f
		--datarootdir=*)
00d77f
			mb_datarootdir=${arg#*=}
00d77f
			;;
00d77f
		--datadir=*)
00d77f
			mb_datadir=${arg#*=}
00d77f
			;;
00d77f
		--infodir=*)
00d77f
			mb_infodir=${arg#*=}
00d77f
			;;
00d77f
		--localedir=*)
00d77f
			mb_localedir=${arg#*=}
00d77f
			;;
00d77f
		--htmldir=*)
00d77f
			mb_htmldir=${arg#*=}
00d77f
			;;
00d77f
		--dvidir=*)
00d77f
			mb_dvidir=${arg#*=}
00d77f
			;;
00d77f
		--pdfdir=*)
00d77f
			mb_pdfdir=${arg#*=}
00d77f
			;;
00d77f
		--psdir=*)
00d77f
			mb_psdir=${arg#*=}
00d77f
			;;
00d77f
7ab7c8
		#make
7ab7c8
		--make=*)
7ab7c8
			mb_make=${arg#*=}
7ab7c8
			;;
00d77f
2fc574
		--makemode=*)
2fc574
			mb_makemode=${arg#*=}
2fc574
			;;
2fc574
e50c3b
		#pkgconf[ig]
e50c3b
		--pkgconf=*)
e50c3b
			mb_pkgconf=${arg#*=}
e50c3b
			;;
e50c3b
e50c3b
		--pkgconfig=*)
e50c3b
			mb_pkgconf=${arg#*=}
e50c3b
			;;
e50c3b
52d60d
		# build
52d60d
		--build=*)
52d60d
			mb_build=${arg#*=}
52d60d
			;;
52d60d
		--host=*)
52d60d
			mb_host=${arg#*=}
52d60d
			;;
927e2d
		--cchost=*)
927e2d
			mb_cchost=${arg#*=}
e2a544
			mb_cchost_set=yes
927e2d
			;;
1b579f
		--cfghost=*)
1b579f
			mb_cfghost=${arg#*=}
1b579f
			;;
52d60d
		--target=*)
52d60d
			mb_target=${arg#*=}
52d60d
			;;
52d60d
		--arch=*)
52d60d
			mb_arch=${arg#*=}
52d60d
			;;
52d60d
		--sysroot=*)
52d60d
			mb_sysroot=${arg#*=}
52d60d
			;;
52d60d
		--shell=*)
52d60d
			mb_shell=${arg#*=}
52d60d
			;;
52d60d
		--debug)
e60976
			mb_debug=yes
52d60d
			;;
5b49a6
5b49a6
		# config
5b49a6
		--all-static)
e60976
			mb_all_static=yes
65b93b
			mb_all_shared=no
5b49a6
			;;
5b49a6
		--all-shared)
e60976
			mb_all_shared=yes
65b93b
			mb_all_static=no
5b49a6
			;;
5b49a6
		--disable-frontend)
e60976
			mb_disable_frontend=yes
5b49a6
			;;
5b49a6
		--disable-app)
e60976
			mb_disable_frontend=yes
5b49a6
			;;
5b49a6
		--enable-frontend)
5b49a6
			mb_disable_frontend='no'
5b49a6
			;;
5b49a6
		--enable-app)
5b49a6
			mb_disable_frontend='no'
5b49a6
			;;
5b49a6
		--disable-static)
e60976
			mb_disable_static=yes
5b49a6
			;;
5b49a6
		--disable-shared)
e60976
			mb_disable_shared=yes
5b49a6
			;;
5b49a6
		--enable-static)
5b49a6
			mb_disable_static='no'
5b49a6
			;;
5b49a6
		--enable-shared)
5b49a6
			mb_disable_shared='no'
5b49a6
			;;
5b49a6
5b49a6
		# convenience
5b49a6
		--strict)
e60976
			mb_ccstrict=yes
e60976
			mb_ldstrict=yes
5b49a6
			;;
5b49a6
		--ccstrict)
e60976
			mb_ccstrict=yes
5b49a6
			;;
5b49a6
		--ldstrict)
e60976
			mb_ldstrict=yes
5b49a6
			;;
5b49a6
5b49a6
		# project
5b49a6
		--nickname=*)
5b49a6
			mb_nickname=${arg#*=}
5b49a6
			;;
206a49
		--program-prefix=*)
206a49
			mb_program_prefix=${arg#*=}
206a49
			;;
5b49a6
		--avoid-version)
e60976
			mb_avoid_version=yes
5b49a6
			;;
7b4710
		--source-dir=*)
7b4710
			mb_source_dir=${arg#*=}
22ff07
			mb_source_dir_set=yes
7b4710
			;;
eb5f93
		--srcdir=*)
eb5f93
			mb_source_dir=${arg#*=}
22ff07
			mb_source_dir_set=yes
eb5f93
			;;
5b49a6
a4c3b9
		# pkgconfig
a4c3b9
		--pkgname=*)
a4c3b9
			mb_pkgname=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgdesc=*)
a4c3b9
			mb_pkgdesc=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgusrc=*)
a4c3b9
			mb_pkgusrc=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgrepo=*)
a4c3b9
			mb_pkgrepo=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgpsrc=*)
a4c3b9
			mb_pkgpsrc=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgdurl=*)
a4c3b9
			mb_pkgdurl=${arg#*=}
a4c3b9
			;;
a4c3b9
4046d2
		--pkgbugs=*)
4046d2
			mb_pkgbugs=${arg#*=}
4046d2
			;;
4046d2
4046d2
		--pkghome=*)
4046d2
			mb_pkghome=${arg#*=}
4046d2
			;;
4046d2
a4c3b9
		--pkgdefs=*)
a4c3b9
			mb_pkgdefs=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkglibs=*)
a4c3b9
			mb_pkglibs=${arg#*=}
a4c3b9
			;;
a4c3b9
22ff07
		# srcinfo
0feda5
		--srcinfo=*)
0feda5
			mb_srcinfo=${arg#*=}
0feda5
			;;
0feda5
0feda5
		--srcsite=*)
0feda5
			mb_srcsite=${arg#*=}
0feda5
			;;
0feda5
0feda5
		--pgprkey=*)
0feda5
			mb_pgprkey=${arg#*=}
0feda5
			;;
0feda5
0feda5
		--pgpskey=*)
0feda5
			mb_pgpskey=${arg#*=}
0feda5
			;;
0feda5
22ff07
		--rawball=*)
22ff07
			mb_rawball=${arg#*=}
22ff07
			;;
22ff07
22ff07
		--rawball-url=*)
22ff07
			mb_rawball_url=${arg#*=}
22ff07
			;;
22ff07
22ff07
		--rawball-sha256=*)
22ff07
			mb_rawball_sha256=${arg#*=}
22ff07
			;;
22ff07
22ff07
		--modball=*)
22ff07
			mb_modball=${arg#*=}
22ff07
			;;
22ff07
22ff07
		--modball-url=*)
22ff07
			mb_modball_url=${arg#*=}
22ff07
			;;
22ff07
22ff07
		--modball-sha256=*)
22ff07
			mb_modball_sha256=${arg#*=}
22ff07
			;;
22ff07
22ff07
		--srcball=*)
22ff07
			mb_srcball=${arg#*=}
22ff07
			;;
22ff07
22ff07
		--srcball-url=*)
22ff07
			mb_srcball_url=${arg#*=}
22ff07
			;;
22ff07
22ff07
		--srcball-sha256=*)
22ff07
			mb_srcball_sha256=${arg#*=}
22ff07
			;;
22ff07
1df58c
		# compatibility
1df58c
		--enable-dependency-tracking)
1df58c
			;;
1df58c
		--disable-dependency-tracking)
1df58c
			;;
1df58c
52d60d
		*)
e60976
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
f4662b
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
f4662b
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
f4662b
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
f4662b
				mb_custom_cfgdefs_space=' '
c9d763
			else
c9d763
				error_msg ${arg#}: "unsupported config argument."
c9d763
				exit 2
c9d763
			fi
52d60d
			;;
52d60d
	esac
39bc3b
39bc3b
	mb_safe_path_desc='source directory'
39bc3b
	mb_safe_path_name="$mb_source_dir"
39bc3b
	verify_safe_path
52d60d
done
52d60d
52d60d
52d60d
7b4710
# three: validation
7b4710
verify_source_directory
22ff07
verify_source_info
7b4710
206a49
if ! [ -z "$mb_program_prefix" ]; then
206a49
	error_msg "--program-prefix is not yet fully support (must be null)."
206a49
fi
206a49
7b4710
7b4710
7b4710
# four: defaults
52d60d
common_defaults
52d60d
52d60d
7b4710
# five: config
5b49a6
config_flags
fc6f51
config_opts
52d60d
config_copy
1a1e15
config_ccenv
c9d763
config_custom
c9d763
config_cfghost
52d60d
config_host
1434c9
config_fini
52d60d
config_status
52d60d
52d60d
52d60d
# all done
1a8cc6
config_success