Blame configure

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