Blame configure

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