Blame configure

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