Blame configure

66a30d
#!/bin/sh
66a30d
37dc93
# project-agnostic ./configure script, written by hand.
37dc93
# this file is covered by COPYING.SOFORT.
37dc93
147ce1
set -eu
147ce1
090216
trap config_failure 1 2 EXIT
090216
b4ba5b
# before we begin...
b4ba5b
mb_path="$PATH"
835f23
mb_script="$0"
835f23
mb_success=no
b4ba5b
66a30d
usage()
66a30d
{
66a30d
	cat "$mb_project_dir"/config.usage
ebbba6
6dc107
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
ebbba6
		printf '\n\n%s%s\n' \
ebbba6
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
ebbba6
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
ebbba6
ebbba6
		printf '%s%s\n' \
ebbba6
			"| Listed above are configure's common switches " \
ebbba6
			"and environment variables.     |"
ebbba6
ebbba6
		printf '%s%s\n' \
ebbba6
			"| Found below are project-specific variables " \
ebbba6
			"and other customization options. |"
ebbba6
ebbba6
		printf '%s%s\n\n\n' \
ebbba6
			" ___________________________________________" \
ebbba6
			"__________________________________"
ebbba6
ebbba6
		cat "$mb_project_dir"/project/config/cfgdefs.usage
ebbba6
	fi
ebbba6
ebbba6
	exit 0
66a30d
}
66a30d
66a30d
error_msg()
66a30d
{
b3d67c
	printf '%s\n' "$@" >&2
66a30d
}
66a30d
66a30d
warning_msg()
66a30d
{
b3d67c
	printf '%s\n' "$@" >&2
66a30d
}
66a30d
28f188
output_step_prolog()
28f188
{
ad20a7
	mb_line_dots='.................................'
ad20a7
	mb_line_dots="${mb_line_dots}.${mb_line_dots}"
b406a9
	mb_step_desc="${mb_package} : ${1##*/} : ${2}  "
28f188
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
15a870
b406a9
	printf "configure step: ${2}\n" >&3
ad20a7
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s  " "${mb_step_desc}" "${mb_line_dots}"
28f188
}
28f188
28f188
output_step_epilog()
28f188
{
28f188
	printf 'OK.\n'
28f188
}
28f188
28f188
output_script_status()
28f188
{
28f188
	mb_step_name="${1##*/} : ${2}"
28f188
	mb_step_desc="${mb_package} : ${mb_step_name}"
15a870
15a870
	printf "configure info: ${2}\n" >&3
28f188
	printf "%s\n" "${mb_step_desc}"
28f188
}
28f188
28f188
output_section_break()
28f188
{
841120
	printf ' ..\n'
28f188
}
28f188
111bd8
verify_safe_path()
111bd8
{
111bd8
	case "$mb_safe_path_name" in
111bd8
		-*)
111bd8
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
111bd8
			exit 2
111bd8
			;;
111bd8
111bd8
		*\ *)
111bd8
			error_msg "$mb_safe_path_desc may not contain spaces."
111bd8
			exit 2
111bd8
			;;
111bd8
	esac
111bd8
}
66a30d
15a870
init_log()
15a870
{
15a870
	exec 3> config.log
15a870
15a870
	printf "This is config.log, generated by sofort's configure script.\n\n" >&3
15a870
	printf '$ %s' "$mb_script" >&3
15a870
}
15a870
66a30d
init_vars()
66a30d
{
564014
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
7b203e
	mb_pwd=$(pwd -P)
66a30d
111bd8
	mb_safe_path_desc='project directory'
111bd8
	mb_safe_path_name="$mb_project_dir"
111bd8
	verify_safe_path
111bd8
111bd8
	mb_safe_path_desc='working directory'
111bd8
	mb_safe_path_name="$mb_pwd"
111bd8
	verify_safe_path
111bd8
c4ed3b
	mb_custom_cfgdefs_args=''
c4ed3b
	mb_custom_cfgdefs_space=''
c4ed3b
c037c0
	mb_srcinfo='$(PROJECT_DIR)/project/srcdist/srcinfo.in'
c037c0
	mb_srcsite='localhost'
c037c0
c037c0
	mb_pgprkey='!!VARIABLE_NOT_SET!!'
c037c0
	mb_pgpskey='!!VARIABLE_NOT_SET!!'
c037c0
cd2145
	sfrt_impl_dir=$mb_project_dir/sofort
cd2145
	sfrt_config_dir=$sfrt_impl_dir/config
cd2145
	sfrt_core_dir=$sfrt_impl_dir/core
cd2145
	sfrt_config_vars=$sfrt_config_dir/config.vars
cd2145
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
f228da
	sfrt_opt_vars=$sfrt_config_dir/opt.vars
cd2145
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
cd2145
b88a21
	mb_make_vars=$(< "$sfrt_config_vars" \
b88a21
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
11c7b5
b88a21
	mb_impl_vars=$(< "$sfrt_config_vars" \
b88a21
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
553940
b88a21
	mb_proj_vars=$(< "$sfrt_config_vars" \
b88a21
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
553940
b88a21
	mb_flag_vars=$(< "$sfrt_flag_vars" \
b88a21
		grep -v -e '^#' -e '^$')
553940
553940
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
553940
e2dba3
	for mb_var in $(printf '%s' "$mb_vars") ; do
11c7b5
		mb_expr=$mb_var='${'$mb_var':-}'
11c7b5
		eval "$mb_expr"
11c7b5
	done
11c7b5
943bff
	# cfgtest
943bff
	. $mb_project_dir/sofort/cfgtest/cfgtest.sh
943bff
7e34aa
	# ccenv
7e34aa
	. $mb_project_dir/sofort/ccenv/ccenv.sh
7e34aa
cba45e
	if ! [ -L ./ccenv ]; then
7e34aa
		if [ -d ./ccenv ]; then
7e34aa
			rm -f ./ccenv/host.mk
7e34aa
			rm -f ./ccenv/native.mk
7e34aa
			rmdir ./ccenv
7e34aa
		fi
7e34aa
	fi
7e34aa
7e34aa
	# config.project
66a30d
	if [ -z "$mb_config" ]; then
2b1d38
		mb_config="$mb_project_dir/config.project"
2b1d38
	fi
2b1d38
2b1d38
	. "$mb_config"
2b1d38
f9914b
	# config.project make preferences
f9914b
	if [ -z "${MAKE}" ]; then
f9914b
		MAKE="$mb_make"
f9914b
	fi
f9914b
f9914b
	if [ -z "${MAKEMODE}" ]; then
f9914b
		MAKEMODE="$mb_makemode"
f9914b
	fi
f9914b
76b5c8
76b5c8
	if [ -z "$mb_makefile" ]; then
76b5c8
		mb_makefile='Makefile'
76b5c8
	fi
76b5c8
ad6d9c
	# pkgconf (host)
ad6d9c
	if [ -z "${PKGCONF}" ]; then
ad6d9c
		PKGCONF="$mb_pkgconf"
ad6d9c
	fi
ad6d9c
ad6d9c
	if [ -z "${PKGCONF}" ]; then
ad6d9c
		PKGCONF="${PKGCONFIG}"
ad6d9c
	fi
ad6d9c
ad6d9c
	# pkgconf (native)
ad6d9c
	if [ -z "${NATIVE_PKGCONF}" ]; then
ad6d9c
		NATIVE_PKGCONF="$mb_native_pkgconf"
ad6d9c
	fi
ad6d9c
ad6d9c
	if [ -z "${NATIVE_PKGCONF}" ]; then
ad6d9c
		NATIVE_PKGCONF="${NATIVE_PKGCONFIG}"
ad6d9c
	fi
ad6d9c
a28efc
	# project-specific initialization
a28efc
	if [ _$mb_use_custom_cfginit = _yes ]; then
a28efc
		. "$mb_project_dir/project/config/cfginit.sh"
a28efc
	fi
a28efc
2b1d38
	# package
2b1d38
	if [ -z "$mb_package" ]; then
2b1d38
		error_msg "$mb_script: incomplete information in $mb_config."
2b1d38
		error_msg "$mb_script: \$mb_package not set."
2b1d38
		exit 1
66a30d
	fi
66a30d
54e8ce
	if [ -z "${NICKNAME}" ]; then
54e8ce
		NICKNAME="$mb_nickname"
54e8ce
	fi
54e8ce
a50a27
	# srcinfo
a50a27
	if [ -n "$SOURCE_DIR" ]; then
a50a27
		mb_source_dir_set=yes
a50a27
	fi
a50a27
17c863
	# cchost
17c863
	if [ -n "$CCHOST" ]; then
17c863
		mb_cchost_set=yes
17c863
	fi
17c863
28f188
	# step prolog
28f188
	output_step_prolog ${mb_script} 'init_vars'
28f188
66a30d
	# project
66a30d
	mb_nickname=$NICKNAME
66a30d
	mb_source_dir=$SOURCE_DIR
66a30d
66a30d
	# dirs
66a30d
	mb_prefix=$PREFIX
66a30d
	mb_exec_prefix=$EXEC_PREFIX
66a30d
	mb_bindir=$BINDIR
66a30d
	mb_sbindir=$SBINDIR
66a30d
	mb_libdir=$LIBDIR
66a30d
	mb_includedir=$INCLUDEDIR
66a30d
	mb_oldincludedir=$OLDINCLUDEDIR
66a30d
	mb_mandir=$MANDIR
66a30d
	mb_docdir=$DOCDIR
66a30d
	mb_libexecdir=$LIBEXECDIR
66a30d
66a30d
	mb_sysconfdir=$SYSCONFDIR
66a30d
	mb_sharedstatedir=$SHAREDSTATEDIR
66a30d
	mb_localstatedir=$LOCALSTATEDIR
66a30d
	mb_runstatedir=$RUNSTATEDIR
66a30d
	mb_datarootdir=$DATAROOTDIR
66a30d
	mb_datadir=$DATADIR
66a30d
	mb_infodir=$INFODIR
66a30d
	mb_localedir=$LOCALEDIR
66a30d
	mb_htmldir=$HTMLDIR
66a30d
	mb_dvidir=$DVIDIR
66a30d
	mb_pdfdir=$PDFDIR
66a30d
	mb_psdir=$PSDIR
66a30d
867bfd
	# make
867bfd
	mb_make=$MAKE
81b037
	mb_makemode=$MAKEMODE
66a30d
66a30d
	# build
66a30d
	mb_build=$BUILD
66a30d
	mb_cchost=$CCHOST
f6645d
	mb_cfghost=$CFGHOST
66a30d
	mb_arch=$ARCH
66a30d
	mb_compiler=$COMPILER
66a30d
	mb_toolchain=$TOOLCHAIN
66a30d
	mb_sysroot=$SYSROOT
66a30d
	mb_cross_compile=$CROSS_COMPILE
b119ba
	mb_shell=$CONFIG_SHELL
66a30d
ad6d9c
	# pkgconf
ad6d9c
	mb_pkgconf=$PKGCONF
ad6d9c
66a30d
	# switches
66a30d
	mb_cflags=$CFLAGS
66a30d
	mb_cflags_debug=$CFLAGS_DEBUG
66a30d
	mb_cflags_common=$CFLAGS_COMMON
66a30d
	mb_cflags_cmdline=$CFLAGS_CMDLINE
66a30d
	mb_cflags_config=$CFLAGS_CONFIG
66a30d
	mb_cflags_sysroot=$CFLAGS_SYSROOT
66a30d
	mb_cflags_os=$CFLAGS_OS
66a30d
	mb_cflags_site=$CFLAGS_SITE
66a30d
	mb_cflags_path=$CFLAGS_PATH
66a30d
	mb_cflags_strict=$CFLAGS_STRICT
66a30d
	mb_cflags_util=$CFLAGS_UTIL
66a30d
	mb_cflags_last=$CFLAGS_LAST
66a30d
	mb_cflags_once=$CFLAGS_ONCE
66a30d
66a30d
	mb_ldflags=$LDFLAGS
66a30d
	mb_ldflags_debug=$LDFLAGS_DEBUG
66a30d
	mb_ldflags_common=$LDFLAGS_COMMON
66a30d
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
66a30d
	mb_ldflags_config=$LDFLAGS_CONFIG
66a30d
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
66a30d
	mb_ldflags_path=$LDFLAGS_PATH
66a30d
	mb_ldflags_strict=$LDFLAGS_STRICT
66a30d
	mb_ldflags_util=$LDFLAGS_UTIL
66a30d
	mb_ldflags_last=$LDFLAGS_LAST
66a30d
	mb_ldflags_once=$LDFLAGS_ONCE
66a30d
66a30d
	mb_pe_subsystem=$PE_SUBSYSTEM
66a30d
	mb_pe_image_base=$PE_IMAGE_BASE
66a30d
66a30d
	# overrides
66a30d
	mb_user_cc=$CC
66a30d
	mb_user_cpp=$CPP
66a30d
	mb_user_cxx=$CXX
7e34aa
7e34aa
	mb_native_cc=$NATIVE_CC
7e34aa
	mb_native_cpp=$NATIVE_CPP
7e34aa
	mb_native_cxx=$NATIVE_CXX
7e34aa
7e34aa
	mb_native_host=$NATIVE_HOST
7e34aa
	mb_native_cfghost=$NATIVE_CFGHOST
7e34aa
	mb_native_cflags=$NATIVE_CFLAGS
7e34aa
	mb_native_ldflags=$NATIVE_LDFLAGS
b39a10
ad6d9c
	mb_native_pkgconf=$NATIVE_PKGCONF
ad6d9c
b39a10
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
b39a10
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
28f188
28f188
	# step epilog
28f188
	output_step_epilog
66a30d
}
66a30d
66a30d
66a30d
verify_build_directory()
66a30d
{
28f188
	output_step_prolog ${mb_script} 'verify_build_directory'
28f188
66a30d
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
6dc107
		if [ _$mb_require_out_of_tree = _yes ]; then
66a30d
			error_msg "$mb_package: out-of-tree builds are required."
66a30d
			error_msg "please invoke configure again from a clean build directory."
b988f8
			exit 1
66a30d
		else
66a30d
			mb_project_dir='.'
66a30d
		fi
66a30d
	fi
090216
9d230a
	if [ -f "$mb_pwd/Makefile.common" ]; then
9d230a
		error_msg
9d230a
		error_msg "$mb_package: the file-name Makefile.common is reserved for bootstrapping projects."
9d230a
		error_msg "$mb_package: please remove or rename the file manually and then re-run configure."
9d230a
		exit 1
9d230a
	fi
9d230a
76b5c8
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed $mb_makefile
28f188
28f188
	output_step_epilog
66a30d
}
66a30d
66a30d
66a30d
verify_source_directory()
66a30d
{
28f188
	output_step_prolog ${mb_script} 'verify_source_directory'
28f188
1d5133
	if [ _"$mb_source_dir" != _${mb_source_dir##* } ]; then
1d5133
		error_msg "source directory path contains spaces, aborting."
1d5133
		exit 1
1d5133
	fi
1d5133
1d5133
	eval mb_source_dir=$(printf '%s' "$mb_source_dir")
1d5133
66a30d
	if [ -z "$mb_source_dir" ]; then
6dc107
		if [ _$mb_require_source_dir = _yes ]; then
66a30d
			error_msg "$mb_package: specifying an external source directory is required."
66a30d
			error_msg "you can set the source directory either via --source-dir=<path>,"
66a30d
			error_msg "or by setting the SOURCE_DIR variable."
b988f8
			exit 1
66a30d
		fi
66a30d
	fi
28f188
28f188
	output_step_epilog
66a30d
}
66a30d
66a30d
a50a27
verify_source_info()
a50a27
{
a50a27
	output_step_prolog ${mb_script} 'verify_source_info'
a50a27
a50a27
	if [ "${mb_source_dir_set:-}" = yes ]; then
a50a27
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ] || [ -n "$mb_srcball" ]; then
a50a27
			error_msg "$mb_package: conflicting arguments: --rawball/--modball/--srcball arguments"
a50a27
			error_msg "may not be used together with an explicit source-dir argument or variable."
a50a27
			exit 1
a50a27
		fi
a50a27
	fi
a50a27
a50a27
	if [ -n "$mb_srcball" ]; then
a50a27
		eval mb_srcball=$(printf '%s' "$mb_srcball")
a50a27
a50a27
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ]; then
a50a27
			error_msg "$mb_package: conflicting arguments: --rawball and/or --modball arguments"
a50a27
			error_msg "may not be used together with an explicitly --srcball argument."
a50a27
			exit 1
a50a27
		fi
a50a27
a50a27
		if [ -z "$mb_srcball_sha256" ]; then
a50a27
			error_msg "$mb_package: --srcball-sha256 must be provided"
a50a27
			error_msg "in conjunction with --srcball."
a50a27
			exit 1
a50a27
		fi
a50a27
a50a27
		mb_srcball_sha256_test=$(sha256sum "$mb_srcball")
a50a27
		mb_srcball_sha256_test="${mb_srcball_sha256_test%% *}"
a50a27
a50a27
		if [ "$mb_srcball_sha256_test" != "$mb_srcball_sha256" ]; then
a50a27
			error_msg "$mb_package: sha256 signature of srcball $mb_srcball does not match!"
a50a27
			exit 1
a50a27
		fi
a50a27
a50a27
		mb_srcball_topdir=$(xz -c -d "$mb_srcball" | pax | sed -n '1,1p')
a50a27
		mb_source_dir="./srctree/$mb_package/${mb_srcball_topdir%/}"
a50a27
a50a27
		mb_srcball_dirname=$(cd -- "${mb_srcball%/*}" ; pwd -P)
a50a27
		mb_srcball_basename=${mb_srcball##*/}
a50a27
		mb_srcball="$mb_srcball_dirname/$mb_srcball_basename"
a50a27
a50a27
		mkdir -p "./srctree/$mb_package"
a50a27
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_srcball" | pax -r)
a50a27
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
a50a27
	fi
a50a27
a50a27
	if [ -z "$mb_rawball" ] && [ -n "$mb_modball" ]; then
a50a27
		error_msg "$mb_package: conflicting arguments: --modball argument may only be used"
a50a27
		error_msg "together with an explicit --rawball argument."
a50a27
		exit 1
a50a27
	fi
a50a27
a50a27
	if [ -n "$mb_modball" ]; then
a50a27
		eval mb_modball=$(printf '%s' "$mb_modball")
a50a27
a50a27
		if [ -z "$mb_modball_sha256" ]; then
a50a27
			error_msg "$mb_package: --modball-sha256 must be provided"
a50a27
			error_msg "in conjunction with --modball."
a50a27
			exit 1
a50a27
		fi
a50a27
a50a27
		mb_modball_sha256_test=$(sha256sum "$mb_modball")
a50a27
		mb_modball_sha256_test="${mb_modball_sha256_test%% *}"
a50a27
a50a27
		if [ "$mb_modball_sha256_test" != "$mb_modball_sha256" ]; then
a50a27
			error_msg "$mb_package: sha256 signature of modball $mb_modball does not match!"
a50a27
			exit 1
a50a27
		fi
a50a27
	fi
a50a27
a50a27
	if [ -n "$mb_rawball" ]; then
a50a27
		eval mb_rawball=$(printf '%s' "$mb_rawball")
a50a27
a50a27
		if [ -z "$mb_rawball_sha256" ]; then
a50a27
			error_msg "$mb_package: --rawball-sha256 must be provided."
a50a27
			error_msg "in conjunction with --rawball."
a50a27
			exit 1
a50a27
		fi
a50a27
a50a27
		mb_rawball_sha256_test=$(sha256sum "$mb_rawball")
a50a27
		mb_rawball_sha256_test="${mb_rawball_sha256_test%% *}"
a50a27
a50a27
		if [ "$mb_rawball_sha256_test" != "$mb_rawball_sha256" ]; then
a50a27
			error_msg "$mb_package: sha256 signature of rawball $mb_rawball does not match!"
a50a27
			exit 1
a50a27
		fi
a50a27
a50a27
		mb_rawball_topdir=$(xz -c -d "$mb_rawball" | pax | sed -n '1,1p')
a50a27
		mb_source_dir="./srctree/$mb_package/${mb_rawball_topdir%/}"
a50a27
a50a27
		mb_rawball_dirname=$(cd -- "${mb_rawball%/*}" ; pwd -P)
a50a27
		mb_rawball_basename=${mb_rawball##*/}
a50a27
		mb_rawball="$mb_rawball_dirname/$mb_rawball_basename"
a50a27
a50a27
		mkdir -p "./srctree/$mb_package"
a50a27
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_rawball" | pax -r)
a50a27
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
a50a27
	fi
a50a27
a50a27
	if [ -n "$mb_modball" ]; then
a50a27
		mb_modball_dirname=$(cd -- "${mb_modball%/*}" ; pwd -P)
a50a27
		mb_modball_basename=${mb_modball##*/}
a50a27
		mb_modball="$mb_modball_dirname/$mb_modball_basename"
a50a27
a50a27
		mb_modball_topdir="./modtree/$mb_package/$mb_modball_sha256"
a50a27
		mkdir -p "$mb_modball_topdir"
a50a27
		mb_modball_topdir=$(cd -- $mb_modball_topdir; pwd -P)
a50a27
		mb_dummy=$(cd -- "$mb_modball_topdir"; xz -c -d "$mb_modball" | pax -r)
a50a27
a50a27
		if [ -d "$mb_modball_topdir/overlay" ]; then
a50a27
			mb_dummy=$(cd -- "$mb_modball_topdir/overlay"; \
a50a27
				cp -p -P -R . "$mb_source_dir")
a50a27
		fi
a50a27
a50a27
		if [ -d "$mb_modball_topdir/patches" ]; then
a50a27
			mb_dummy=$(cd -- "$mb_source_dir";                        \
a50a27
				for p in $mb_modball_topdir/patches/*.patch; do  \
a50a27
					patch -p1 < $p;                         \
a50a27
				done);
a50a27
		fi
a50a27
	fi
a50a27
a50a27
	output_step_epilog
a50a27
}
a50a27
a50a27
66a30d
common_defaults()
66a30d
{
28f188
	# step prolog
28f188
	output_step_prolog ${mb_script} 'common_defaults'
28f188
0b2b68
	# project-specific config definitions
0b2b68
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
0b2b68
		cat $sfrt_cfgdefs_in > cfgdefs.mk
0b2b68
	else
0b2b68
		printf '%s %s\n\n' \
0b2b68
				'# this project does not include' \
0b2b68
				'a custom config step.'           \
0b2b68
			> cfgdefs.mk
0b2b68
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
0b2b68
0b2b68
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
0b2b68
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
0b2b68
		fi
0b2b68
	fi
0b2b68
0b2b68
	# user build-time overrides
0b2b68
	touch usrdefs.mk
0b2b68
66a30d
	# git
66a30d
	if [ -n "$mb_source_dir" ]; then
66a30d
		if [ -d "$mb_source_dir/.git" ]; then
66a30d
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
66a30d
		fi
66a30d
	elif [ -d "$mb_project_dir/.git" ]; then
66a30d
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
66a30d
	fi
66a30d
66a30d
	# project
c4c457
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
c4c457
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
c4c457
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
66a30d
66a30d
	# pkgconfig
c4c457
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
c4c457
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
c4c457
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
c4c457
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
c4c457
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
c4c457
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
543c16
	[ -n "$mb_pkgbugs" ]		|| mb_pkgbugs="$mb_default_pkgbugs"
543c16
	[ -n "$mb_pkghome" ]		|| mb_pkghome="$mb_default_pkghome"
c4c457
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
c4c457
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
66a30d
a50a27
	# srcinfo
a50a27
	[ -n "$mb_rawball" ]		|| mb_rawball="$mb_default_rawball"
a50a27
	[ -n "$mb_rawball_url" ]	|| mb_rawball_url="$mb_default_rawball_url"
a50a27
	[ -n "$mb_rawball_sha256" ]	|| mb_rawball_sha256="$mb_default_rawball_sha256"
a50a27
	[ -n "$mb_modball" ]		|| mb_modball="$mb_default_modball"
a50a27
	[ -n "$mb_modball_url" ]	|| mb_modball_url="$mb_default_modball_url"
a50a27
	[ -n "$mb_modball_sha256" ]	|| mb_modball_sha256="$mb_default_modball_sha256"
a50a27
	[ -n "$mb_srcball" ]		|| mb_srcball="$mb_default_srcball"
a50a27
	[ -n "$mb_srcball_url" ]	|| mb_srcball_url="$mb_default_srcball_url"
a50a27
	[ -n "$mb_srcball_sha256" ]	|| mb_srcball_sha256="$mb_default_srcball_sha256"
a50a27
66a30d
	# dirs
c4c457
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
c4c457
					|| mb_prefix='/usr/local'
c4c457
c4c457
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
c4c457
					|| mb_exec_prefix=$mb_prefix
c4c457
c4c457
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
c4c457
					|| [ -n "$mb_bindir_basename" ] \
c4c457
					|| mb_bindir=$mb_exec_prefix/bin
c4c457
c4c457
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
c4c457
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
c4c457
c4c457
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
c4c457
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
c4c457
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
c4c457
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
c4c457
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
c4c457
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
12a659
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc/'$(PACKAGE)'
c4c457
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
c4c457
c4c457
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
c4c457
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
c4c457
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
c4c457
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
c4c457
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
c4c457
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
c4c457
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
c4c457
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
c4c457
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
c4c457
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
c4c457
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
c4c457
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
66a30d
66a30d
	# switches
c4c457
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
c4c457
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
c4c457
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
c4c457
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
c4c457
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
c4c457
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
c4c457
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
c4c457
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
c4c457
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
c4c457
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
c4c457
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
c4c457
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
c4c457
c4c457
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
c4c457
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
c4c457
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
c4c457
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
c4c457
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
c4c457
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
c4c457
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
c4c457
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
c4c457
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
c4c457
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
66a30d
4b14d5
	# native switches
c4c457
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
c4c457
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
4b14d5
66a30d
	# config
c4c457
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
c4c457
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
c4c457
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
c4c457
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
c4c457
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
66a30d
66a30d
	# host/target
c4c457
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
c4c457
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
66a30d
66a30d
	# sysroot
66a30d
	if [ -n "$mb_sysroot" ]; then
66a30d
		if [ -z "$mb_cflags_sysroot" ]; then
b0a311
			mb_cflags_sysroot='$(_CFLAGS_SYSROOT)'
66a30d
		fi
66a30d
66a30d
		if [ -z "$mb_ldflags_sysroot" ]; then
b0a311
			mb_ldflags_sysroot='$(_LDFLAGS_SYSROOT)'
66a30d
		fi
66a30d
	fi
66a30d
66a30d
	# debug
6dc107
	if [ _$mb_debug = _yes ]; then
66a30d
		if [ -z "$mb_cflags_debug" ]; then
21f7f2
			mb_cflags_debug='$(_CFLAGS_g3) $(_CFLAGS_O0)'
66a30d
		fi
66a30d
	fi
69bae7
867bfd
	# make
867bfd
	if [ -z "$mb_make" ]; then
867bfd
		mb_make='make'
867bfd
	fi
867bfd
81b037
	if [ -z "$mb_makemode" ]; then
81b037
		mb_makemode='posix'
024476
024476
		printf '%s\n%s\n%s\n\n%s\n\n'        \
024476
				'ifeq (a,b)'          \
024476
				'VAR = val'            \
024476
				'endif'                 \
024476
				'all:'                   \
024476
			| ${mb_make} -s -f - 2>/dev/null  \
024476
		&& mb_makemode='modern'
024476
81b037
	fi
81b037
0c76e6
	# shell
0c76e6
	if [ -z "$mb_shell" ]; then
0c76e6
		mb_shell='/bin/sh'
0c76e6
	fi
0c76e6
69bae7
	# inherited cflags & ldflags
69bae7
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
69bae7
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
28f188
28f188
	# step epilog
28f188
	output_step_epilog
66a30d
}
66a30d
66a30d
66a30d
config_flags()
66a30d
{
28f188
	# step prolog
28f188
	output_step_prolog ${mb_script} 'config_flags'
28f188
66a30d
	mb_ldflags_tmp=" $mb_ldflags "
07412b
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
66a30d
66a30d
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
66a30d
		mb_ldflags="$mb_ldflags_libs"
66a30d
		mb_ldflags_util="$mb_ldflags_util -static"
66a30d
	fi
66a30d
66a30d
	# ccstrict
6dc107
	if [ _$mb_ccstrict = _yes ]; then
6c25ef
		mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef)'
66a30d
	fi
66a30d
66a30d
	# ldstrict
6dc107
	if [ _$mb_ldstrict = _yes ]; then
6c25ef
		mb_ldflags_strict='$(_CFLAGS_Wl___no_undefined)'
66a30d
	fi
28f188
28f188
	# step epilog
28f188
	output_step_epilog
66a30d
}
66a30d
66a30d
f228da
config_opts()
f228da
{
f228da
	if [ "$mb_avoid_version" = 'yes' ]; then
f228da
		mb_version_opt='none'
f228da
	else
f228da
		mb_version_opt='used'
f228da
	fi
641793
641793
	if [ "$mb_custom_install_headers" = 'yes' ]; then
641793
		mb_install_headers_opt='custom'
641793
	else
641793
		mb_install_headers_opt='default'
641793
	fi
641793
641793
	if [ "$mb_disable_static" = 'yes' ]; then
641793
		mb_static_library_opt='disabled'
641793
	else
641793
		mb_static_library_opt='enabled'
641793
	fi
641793
641793
	if [ "$mb_disable_shared" = 'yes' ]; then
641793
		mb_shared_library_opt='disabled'
641793
	else
641793
		mb_shared_library_opt='enabled'
641793
	fi
641793
641793
	if [ "$mb_disable_frontend" = 'yes' ]; then
641793
		mb_app_frontend_opt='disabled'
641793
	else
641793
		mb_app_frontend_opt='enabled'
641793
	fi
641793
641793
	if [ "$mb_all_static" = 'yes' ]; then
641793
		mb_app_linking_opt='all_static'
641793
641793
	elif [ "$mb_all_shared" = 'yes' ]; then
641793
		mb_app_linking_opt='all_shared'
641793
641793
	else
641793
		mb_app_linking_opt='default'
641793
	fi
f228da
}
f228da
66a30d
config_copy()
66a30d
{
28f188
	output_step_prolog ${mb_script} 'config_copy'
28f188
7875bb
	mb_var_defs=
7875bb
	mb_sed_substs=
8956b2
	mb_template="${1:-$mb_project_dir/Makefile.in}"
7875bb
f228da
	mb_vars=$(cut -d'=' -f1 "$sfrt_config_vars" "$sfrt_opt_vars" \
7875bb
		| grep -v '^#');
7875bb
7875bb
	for __var in $(printf '%s' "$mb_vars"); do
7875bb
		mb_sed_subst=$(printf '%s %s%s%s'  \
7875bb
				'-e' "'s^@$__var@"  \
7875bb
				"^___${__var}___"    \
7875bb
				"^g'")
7875bb
7875bb
		mb_sed_substs="$mb_sed_substs $mb_sed_subst"
7875bb
7875bb
		mb_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "mb_${__var}")
7875bb
		eval mb_var_defs='"$mb_var_defs "$mb_var_def'
7875bb
	done
7875bb
8956b2
	eval sed $mb_sed_substs $mb_template         \
8956b2
			| eval m4 $mb_var_defs -      \
8956b2
			| sed -e 's/[[:blank:]]*$//g'  \
7875bb
		> $mb_pwd/Makefile.tmp
28f188
28f188
	output_step_epilog
7e34aa
}
66a30d
127aed
7e34aa
config_ccenv()
7e34aa
{
7e34aa
	mkdir -p ./ccenv
7e34aa
	touch ./ccenv/host.mk
7e34aa
	touch ./ccenv/native.mk
ebbba6
28f188
	output_section_break
7e34aa
	ccenv_set_host_variables
28f188
28f188
	output_section_break
7e34aa
	ccenv_set_native_variables
3a3fb5
4ab93f
	# implicit --sysroot for use with pkgconf and friends
4ab93f
	if [ -z "$mb_sysroot" ]; then
4ab93f
		mb_sysroot="$ccenv_host_sysroot"
4ab93f
	fi
4ab93f
c92f25
	# require --sysroot when cross-compiling
4ab93f
	if [ "$mb_cchost" != "$mb_native_cchost" ]                   \
4ab93f
			&& [ "$ccenv_host_cc" != "$ccenv_native_cc" ] \
4ab93f
			&& [ -z "$mb_sysroot" ]; then
a22aef
		mb_pretty=$(printf "%-${#mb_package}s" '')
a22aef
a22aef
		error_msg ' !!'
a22aef
		error_msg "$mb_package: host machine:    $mb_cchost"
a22aef
		error_msg "$mb_package: host compiler:   $ccenv_host_cc"
a22aef
a22aef
		error_msg ' !!'
a22aef
		error_msg "$mb_package: native machine:  $mb_native_cchost"
a22aef
		error_msg "$mb_package: native compiler: $ccenv_native_cc"
a22aef
a22aef
		error_msg ' !!'
a22aef
		error_msg "$mb_package: detected host machine and native machine differ, assuming cross-compilation."
a22aef
a22aef
		error_msg ' !!'
a22aef
		error_msg "$mb_package: native compilation mode can be forced via --cchost=$mb_native_cchost"
a22aef
		error_msg "${mb_pretty}  or otherwise by setting the NATIVE_CC environment variable to '$ccenv_host_cc',"
a22aef
		error_msg "${mb_pretty}  however that should almost never be necessary; then again,"
a22aef
		error_msg "${mb_pretty}  forcing native mode when cross-building is strictly prohibited."
c92f25
	fi
c92f25
d3ed71
	# add the include and library directories to the compiler and linker search path
fe21e8
	if [ "$mb_cchost" = "$mb_native_cchost" ]; then
d3ed71
		mb_cflags_last="$mb_cflags_last -I$mb_includedir"
fe21e8
		mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
fe21e8
	else
fe21e8
		case "$mb_libdir" in
fe21e8
			/*)
41490e
				mb_cflags_last="$mb_cflags_last -I$mb_sysroot/.$mb_includedir"
fe21e8
				mb_ldflags_last="$mb_ldflags_last -L$mb_sysroot/.$mb_libdir"
fe21e8
				;;
fe21e8
			*)
41490e
				mb_cflags_last="$mb_cflags_last -I$mb_includedir"
fe21e8
				mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
fe21e8
		esac
fe21e8
	fi
fe21e8
c92f25
	# re-generate Makefile.tmp
28f188
	output_section_break
3a3fb5
	config_copy
c92f25
7e34aa
}
ebbba6
4990b0
config_custom_cfgdefs()
4990b0
{
4990b0
	. $mb_project_dir/project/config/cfgdefs.sh
4990b0
}
4990b0
ebbba6
config_custom()
ebbba6
{
6dc107
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
28f188
		output_section_break
28f188
		output_script_status ${mb_script} \
15a870
			'invoking project-specific cfgdefs.sh'
28f188
4990b0
		eval config_custom_cfgdefs "$mb_custom_cfgdefs_args"
28f188
28f188
		output_section_break
bfdf20
bfdf20
		if [ -f "$mb_project_dir/project/config/Makefile.in" ]; then
bfdf20
			config_copy "$mb_project_dir/project/config/Makefile.in"
bfdf20
			mv $mb_pwd/Makefile.tmp Makefile
bfdf20
		fi
bfdf20
ebbba6
		config_copy
ebbba6
	fi
66a30d
6dc107
	if [ _$mb_use_custom_usrdefs = _yes ]; then
28f188
		output_section_break
28f188
		output_script_status ${mb_scirpt} \
15a870
			'invoking project-specific usrdefs.sh'
28f188
ebbba6
		. $mb_project_dir/project/usrdefs.sh
28f188
		output_section_break
ebbba6
	fi
ebbba6
}
ebbba6
ebbba6
ebbba6
config_cfghost()
ebbba6
{
28f188
	output_step_prolog ${mb_script} 'config_cfghost'
28f188
f6645d
	if [ -z "$mb_cfghost" ]; then
f6645d
		mb_cfghost=$mb_cchost
f6645d
	fi
f6645d
f6645d
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
f6645d
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
b988f8
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
66a30d
b988f8
	rm  $mb_pwd/Makefile.tmp
76b5c8
	mv  $mb_pwd/Makefile.host $mb_pwd/$mb_makefile
28f188
28f188
	output_step_epilog
66a30d
}
66a30d
66a30d
66a30d
config_host()
66a30d
{
f90367
	# init
28f188
	output_step_prolog ${mb_script} 'config_host'
28f188
f90367
	mb_cfghost_cc="$ccenv_host_cc"
f90367
	mb_cfghost_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
f90367
f90367
	mb_cfghost_cflags=$(${mb_make} -n -f "$mb_makefile" \
f90367
		.cflags-host)
f90367
f90367
	mb_cfghost_cflags="${mb_cfghost_cflags#*: }"
f90367
8ff1e7
	if [ "$mb_cc_environment" = 'freestanding' ]; then
de5f2c
		if [ -z "mb_cc_underscore" ]; then
de5f2c
			mb_cfghost_start_fn='_start'
de5f2c
		else
de5f2c
			mb_cfghost_start_fn='start'
de5f2c
		fi
de5f2c
de5f2c
		printf 'int %s(void){return 0;}' "$mb_cfghost_start_fn" \
de5f2c
			> "$mb_cfghost_tmpname"
de5f2c
de5f2c
		mb_cfghost_cflags="$mb_cfghost_cflags -ffreestanding"
de5f2c
		mb_cfghost_cflags="$mb_cfghost_cflags -nostdlib"
de5f2c
	else
de5f2c
		printf 'int main(void){return 0;}' \
de5f2c
			> "$mb_cfghost_tmpname"
de5f2c
	fi
f90367
f90367
	# log
f90367
	printf '\n' >&3
f90367
f90367
	printf '%s\n'                                         \
f90367
		'#'                                           \
f90367
		'# verify that that following combination of' \
f90367
		'# host compiler and host cflags is working.' \
f90367
		'#'                                           \
f90367
		>&3
f90367
f90367
	printf '\n%s' "$mb_cfghost_cc $ccenv_tmpname -o a.out" >&3
f90367
f76b35
	for mb_cfghost_cflag in $(printf '%s' "$mb_cfghost_cflags"); do
f90367
		printf ' \\\n\t%s' "$mb_cfghost_cflag" >&3
f90367
	done
f90367
f90367
	printf '\n\n' >&3
f90367
f90367
	# execute
f90367
	if eval $mb_cfghost_cc "$ccenv_tmpname" -o a.out    \
f90367
			$(printf '%s' "$mb_cfghost_cflags") \
f90367
			2>&3; then
f90367
		rm a.out
f90367
		rm $mb_cfghost_tmpname
f90367
		mb_cfghost_ret=0
f90367
	else
f90367
		mb_cfghost_ret=1
f90367
	fi
f90367
f90367
	if [ $mb_cfghost_ret = 0 ]; then
f90367
		output_step_epilog
f90367
		return 0
f90367
	fi
66a30d
76b5c8
	# should never happen
f90367
	error_msg
66a30d
	error_msg "configure was able to generate a Makefile for the selected host,"
66a30d
	error_msg "however the host-targeting compiler was found to be missing"
66a30d
	error_msg "at least one of the required headers or features."
66a30d
	exit 2
66a30d
}
66a30d
66a30d
a28efc
config_fini()
a28efc
{
a28efc
	# project-specific post-configuration steps
a28efc
	if [ _$mb_use_custom_cfgfini = _yes ]; then
a28efc
		. "$mb_project_dir/project/config/cfgfini.sh"
a28efc
	fi
a28efc
}
a28efc
a28efc
66a30d
config_status()
66a30d
{
28f188
	output_script_status ${mb_script} \
28f188
		'configuration completed successfully.'
28f188
	printf '\n'
66a30d
}
66a30d
090216
090216
config_failure()
090216
{
789b0e
	if [ _$mb_success = _yes ]; then
789b0e
		return 0
789b0e
	fi
789b0e
15a870
	printf 'configure info: exiting due to an error.\n' >&3
15a870
090216
	exit 2
090216
}
090216
090216
090216
config_success()
090216
{
090216
	trap '' EXIT
789b0e
	mb_success=yes
090216
	exit 0
090216
}
090216
090216
66a30d
# one: init
888fe6
mb_args_defs=
888fe6
mb_args_text=
888fe6
mb_args_idx=0
888fe6
888fe6
init_log
15a870
15a870
for arg ; do
888fe6
	mb_args_idx=$((mb_args_idx+1))
888fe6
888fe6
	mb_arg_def=$(printf '%s%s="${%s}"' "-D_" "${mb_args_idx}" "${mb_args_idx}")
888fe6
	eval mb_args_defs='"$mb_args_defs "$mb_arg_def'
888fe6
888fe6
	mb_args_text="$mb_args_text '_$((mb_args_idx))'"
15a870
done
15a870
888fe6
printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
888fe6
888fe6
if [ $mb_args_idx -gt 1 ]; then
888fe6
	printf '$ %s' "$mb_script" >&3
888fe6
888fe6
	mb_args_idx=0
888fe6
	mb_args_text=
888fe6
888fe6
	for arg; do
888fe6
		mb_args_idx=$((mb_args_idx+1))
888fe6
		mb_args_text="$mb_args_text"$(printf ' \\\\\n\t%s_%d%s' "'" "$mb_args_idx" "'")
888fe6
	done
888fe6
888fe6
	printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
888fe6
fi
888fe6
66a30d
init_vars
66a30d
verify_build_directory
66a30d
66a30d
66a30d
# two: args
66a30d
for arg ; do
66a30d
	case "$arg" in
7e34aa
		--help)
7e34aa
			usage
7e34aa
			;;
7e34aa
		--help=ccenv)
7e34aa
			ccenv_usage
7e34aa
			;;
7e34aa
7e34aa
		# ccenv
7e34aa
		--cross-compile=*)
7e34aa
			mb_cross_compile=${arg#*=}
7e34aa
			;;
7e34aa
		--compiler=*)
7e34aa
			mb_compiler=${arg#*=}
7e34aa
			;;
7e34aa
		--toolchain=*)
7e34aa
			mb_toolchain=${arg#*=}
7e34aa
			;;
7e34aa
		--zealous)
7e34aa
			mb_agnostic=yes
7e34aa
			mb_zealous=
7e34aa
			;;
7e34aa
		--zealous=*)
7e34aa
			mb_zealous=${arg#*=}
7e34aa
			;;
7e34aa
		--ccenv=*)
7e34aa
			mb_ccenv=${arg#*=}
66a30d
			;;
66a30d
66a30d
		# dirs
66a30d
		--prefix=*)
66a30d
			mb_prefix_set=yes
66a30d
			mb_prefix=${arg#*=}
66a30d
			;;
66a30d
		--exec-prefix=*)
66a30d
			mb_exec_prefix_set=yes
66a30d
			mb_exec_prefix=${arg#*=}
66a30d
			;;
66a30d
		--bindir=*)
66a30d
			mb_bindir_set=yes
66a30d
			mb_bindir=${arg#*=}
66a30d
			;;
66a30d
		--sbindir=*)
66a30d
			mb_sbindir=${arg#*=}
66a30d
			;;
66a30d
		--libdir=*)
66a30d
			mb_libdir=${arg#*=}
66a30d
			;;
66a30d
		--includedir=*)
66a30d
			mb_includedir=${arg#*=}
66a30d
			;;
66a30d
		--oldincludedir=*)
66a30d
			mb_oldincludedir=${arg#*=}
66a30d
			;;
66a30d
		--mandir=*)
66a30d
			mb_mandir=${arg#*=}
66a30d
			;;
66a30d
		--libexecdir=*)
66a30d
			mb_libexecdir=${arg#*=}
66a30d
			;;
66a30d
66a30d
66a30d
		--sysconfdir=*)
66a30d
			mb_sysconfdir=${arg#*=}
66a30d
			;;
66a30d
		--sharedstatedir=*)
66a30d
			mb_sharedstatedir=${arg#*=}
66a30d
			;;
66a30d
		--localstatedir=*)
66a30d
			mb_localstatedir=${arg#*=}
66a30d
			;;
66a30d
		--runstatedir=*)
66a30d
			mb_runstatedir=${arg#*=}
66a30d
			;;
66a30d
		--datarootdir=*)
66a30d
			mb_datarootdir=${arg#*=}
66a30d
			;;
66a30d
		--datadir=*)
66a30d
			mb_datadir=${arg#*=}
66a30d
			;;
66a30d
		--infodir=*)
66a30d
			mb_infodir=${arg#*=}
66a30d
			;;
66a30d
		--localedir=*)
66a30d
			mb_localedir=${arg#*=}
66a30d
			;;
66a30d
		--htmldir=*)
66a30d
			mb_htmldir=${arg#*=}
66a30d
			;;
66a30d
		--dvidir=*)
66a30d
			mb_dvidir=${arg#*=}
66a30d
			;;
66a30d
		--pdfdir=*)
66a30d
			mb_pdfdir=${arg#*=}
66a30d
			;;
66a30d
		--psdir=*)
66a30d
			mb_psdir=${arg#*=}
66a30d
			;;
66a30d
867bfd
		#make
867bfd
		--make=*)
867bfd
			mb_make=${arg#*=}
867bfd
			;;
66a30d
81b037
		--makemode=*)
81b037
			mb_makemode=${arg#*=}
81b037
			;;
81b037
ad6d9c
		#pkgconf[ig]
ad6d9c
		--pkgconf=*)
ad6d9c
			mb_pkgconf=${arg#*=}
ad6d9c
			;;
ad6d9c
ad6d9c
		--pkgconfig=*)
ad6d9c
			mb_pkgconf=${arg#*=}
ad6d9c
			;;
ad6d9c
66a30d
		# build
66a30d
		--build=*)
66a30d
			mb_build=${arg#*=}
66a30d
			;;
66a30d
		--host=*)
66a30d
			mb_host=${arg#*=}
66a30d
			;;
66a30d
		--cchost=*)
66a30d
			mb_cchost=${arg#*=}
17c863
			mb_cchost_set=yes
66a30d
			;;
f6645d
		--cfghost=*)
f6645d
			mb_cfghost=${arg#*=}
f6645d
			;;
66a30d
		--target=*)
66a30d
			mb_target=${arg#*=}
66a30d
			;;
66a30d
		--arch=*)
66a30d
			mb_arch=${arg#*=}
66a30d
			;;
66a30d
		--sysroot=*)
66a30d
			mb_sysroot=${arg#*=}
66a30d
			;;
66a30d
		--shell=*)
66a30d
			mb_shell=${arg#*=}
66a30d
			;;
66a30d
		--debug)
6dc107
			mb_debug=yes
66a30d
			;;
66a30d
66a30d
		# config
66a30d
		--all-static)
6dc107
			mb_all_static=yes
afd788
			mb_all_shared=no
66a30d
			;;
66a30d
		--all-shared)
6dc107
			mb_all_shared=yes
afd788
			mb_all_static=no
66a30d
			;;
66a30d
		--disable-frontend)
6dc107
			mb_disable_frontend=yes
66a30d
			;;
66a30d
		--disable-app)
6dc107
			mb_disable_frontend=yes
66a30d
			;;
66a30d
		--enable-frontend)
66a30d
			mb_disable_frontend='no'
66a30d
			;;
66a30d
		--enable-app)
66a30d
			mb_disable_frontend='no'
66a30d
			;;
66a30d
		--disable-static)
6dc107
			mb_disable_static=yes
66a30d
			;;
66a30d
		--disable-shared)
6dc107
			mb_disable_shared=yes
66a30d
			;;
66a30d
		--enable-static)
66a30d
			mb_disable_static='no'
66a30d
			;;
66a30d
		--enable-shared)
66a30d
			mb_disable_shared='no'
66a30d
			;;
66a30d
66a30d
		# convenience
66a30d
		--strict)
6dc107
			mb_ccstrict=yes
6dc107
			mb_ldstrict=yes
66a30d
			;;
66a30d
		--ccstrict)
6dc107
			mb_ccstrict=yes
66a30d
			;;
66a30d
		--ldstrict)
6dc107
			mb_ldstrict=yes
66a30d
			;;
66a30d
66a30d
		# project
66a30d
		--nickname=*)
66a30d
			mb_nickname=${arg#*=}
66a30d
			;;
66a30d
		--program-prefix=*)
66a30d
			mb_program_prefix=${arg#*=}
66a30d
			;;
66a30d
		--avoid-version)
6dc107
			mb_avoid_version=yes
66a30d
			;;
66a30d
		--source-dir=*)
66a30d
			mb_source_dir=${arg#*=}
a50a27
			mb_source_dir_set=yes
66a30d
			;;
b75a1b
		--srcdir=*)
b75a1b
			mb_source_dir=${arg#*=}
a50a27
			mb_source_dir_set=yes
b75a1b
			;;
66a30d
66a30d
		# pkgconfig
66a30d
		--pkgname=*)
66a30d
			mb_pkgname=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgdesc=*)
66a30d
			mb_pkgdesc=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgusrc=*)
66a30d
			mb_pkgusrc=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgrepo=*)
66a30d
			mb_pkgrepo=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgpsrc=*)
66a30d
			mb_pkgpsrc=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkgdurl=*)
66a30d
			mb_pkgdurl=${arg#*=}
66a30d
			;;
66a30d
543c16
		--pkgbugs=*)
543c16
			mb_pkgbugs=${arg#*=}
543c16
			;;
543c16
543c16
		--pkghome=*)
543c16
			mb_pkghome=${arg#*=}
543c16
			;;
543c16
66a30d
		--pkgdefs=*)
66a30d
			mb_pkgdefs=${arg#*=}
66a30d
			;;
66a30d
66a30d
		--pkglibs=*)
66a30d
			mb_pkglibs=${arg#*=}
66a30d
			;;
66a30d
a50a27
		# srcinfo
c037c0
		--srcinfo=*)
c037c0
			mb_srcinfo=${arg#*=}
c037c0
			;;
c037c0
c037c0
		--srcsite=*)
c037c0
			mb_srcsite=${arg#*=}
c037c0
			;;
c037c0
c037c0
		--pgprkey=*)
c037c0
			mb_pgprkey=${arg#*=}
c037c0
			;;
c037c0
c037c0
		--pgpskey=*)
c037c0
			mb_pgpskey=${arg#*=}
c037c0
			;;
c037c0
a50a27
		--rawball=*)
a50a27
			mb_rawball=${arg#*=}
a50a27
			;;
a50a27
a50a27
		--rawball-url=*)
a50a27
			mb_rawball_url=${arg#*=}
a50a27
			;;
a50a27
a50a27
		--rawball-sha256=*)
a50a27
			mb_rawball_sha256=${arg#*=}
a50a27
			;;
a50a27
a50a27
		--modball=*)
a50a27
			mb_modball=${arg#*=}
a50a27
			;;
a50a27
a50a27
		--modball-url=*)
a50a27
			mb_modball_url=${arg#*=}
a50a27
			;;
a50a27
a50a27
		--modball-sha256=*)
a50a27
			mb_modball_sha256=${arg#*=}
a50a27
			;;
a50a27
a50a27
		--srcball=*)
a50a27
			mb_srcball=${arg#*=}
a50a27
			;;
a50a27
a50a27
		--srcball-url=*)
a50a27
			mb_srcball_url=${arg#*=}
a50a27
			;;
a50a27
a50a27
		--srcball-sha256=*)
a50a27
			mb_srcball_sha256=${arg#*=}
a50a27
			;;
a50a27
66a30d
		# compatibility
66a30d
		--enable-dependency-tracking)
66a30d
			;;
66a30d
		--disable-dependency-tracking)
66a30d
			;;
66a30d
66a30d
		*)
6dc107
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
c4ed3b
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
c4ed3b
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
c4ed3b
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
c4ed3b
				mb_custom_cfgdefs_space=' '
ebbba6
			else
ebbba6
				error_msg ${arg#}: "unsupported config argument."
ebbba6
				exit 2
ebbba6
			fi
66a30d
			;;
66a30d
	esac
111bd8
111bd8
	mb_safe_path_desc='source directory'
111bd8
	mb_safe_path_name="$mb_source_dir"
111bd8
	verify_safe_path
66a30d
done
66a30d
66a30d
66a30d
66a30d
# three: validation
66a30d
verify_source_directory
a50a27
verify_source_info
66a30d
66a30d
if ! [ -z "$mb_program_prefix" ]; then
66a30d
	error_msg "--program-prefix is not yet fully support (must be null)."
66a30d
fi
66a30d
66a30d
66a30d
66a30d
# four: defaults
66a30d
common_defaults
66a30d
66a30d
66a30d
# five: config
66a30d
config_flags
f228da
config_opts
66a30d
config_copy
7e34aa
config_ccenv
ebbba6
config_custom
ebbba6
config_cfghost
66a30d
config_host
a28efc
config_fini
66a30d
config_status
66a30d
66a30d
66a30d
# all done
090216
config_success