Blame configure

d40d13
#!/bin/sh
d40d13
b3423c
# project-agnostic ./configure script, written by hand.
b3423c
# this file is covered by COPYING.SOFORT.
b3423c
83e725
set -eu
83e725
c55050
trap config_failure 1 2 EXIT
c55050
455efa
# before we begin...
455efa
mb_path="$PATH"
3671fc
mb_script="$0"
3671fc
mb_success=no
455efa
a554c2
usage()
a554c2
{
785495
	cat "$mb_project_dir"/config.usage
45b33c
ba54a5
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
45b33c
		printf '\n\n%s%s\n' \
45b33c
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
45b33c
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
45b33c
45b33c
		printf '%s%s\n' \
45b33c
			"| Listed above are configure's common switches " \
45b33c
			"and environment variables.     |"
45b33c
45b33c
		printf '%s%s\n' \
45b33c
			"| Found below are project-specific variables " \
45b33c
			"and other customization options. |"
45b33c
45b33c
		printf '%s%s\n\n\n' \
45b33c
			" ___________________________________________" \
45b33c
			"__________________________________"
45b33c
45b33c
		cat "$mb_project_dir"/project/config/cfgdefs.usage
45b33c
	fi
45b33c
45b33c
	exit 0
a554c2
}
a554c2
d40d13
error_msg()
d40d13
{
dd4f1b
	printf '%s\n' "$@" >&2
d40d13
}
d40d13
d93341
warning_msg()
d93341
{
dd4f1b
	printf '%s\n' "$@" >&2
d93341
}
d93341
188a79
output_step_prolog()
188a79
{
a94557
	mb_line_dots='.................................'
a94557
	mb_line_dots="${mb_line_dots}.${mb_line_dots}"
a94557
	mb_step_desc="${mb_package} : ${1##*/} : ${2}()  "
188a79
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
bbde52
bbde52
	printf "configure step: ${2}()\n" >&3
a94557
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s  " "${mb_step_desc}" "${mb_line_dots}"
188a79
}
188a79
188a79
output_step_epilog()
188a79
{
188a79
	printf 'OK.\n'
188a79
}
188a79
188a79
output_script_status()
188a79
{
188a79
	mb_step_name="${1##*/} : ${2}"
188a79
	mb_step_desc="${mb_package} : ${mb_step_name}"
bbde52
bbde52
	printf "configure info: ${2}\n" >&3
188a79
	printf "%s\n" "${mb_step_desc}"
188a79
}
188a79
188a79
output_section_break()
188a79
{
b7c699
	printf ' ..\n'
188a79
}
188a79
839391
verify_safe_path()
839391
{
839391
	case "$mb_safe_path_name" in
839391
		-*)
839391
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
839391
			exit 2
839391
			;;
839391
839391
		*\ *)
839391
			error_msg "$mb_safe_path_desc may not contain spaces."
839391
			exit 2
839391
			;;
839391
	esac
839391
}
d40d13
bbde52
init_log()
bbde52
{
bbde52
	exec 3> config.log
bbde52
bbde52
	printf "This is config.log, generated by sofort's configure script.\n\n" >&3
bbde52
	printf '$ %s' "$mb_script" >&3
bbde52
bbde52
	for arg in $mb_args; do
bbde52
		printf ' %s' "$arg" >&3
bbde52
	done
bbde52
bbde52
	printf '\n\n' >&3
bbde52
}
bbde52
d40d13
init_vars()
d40d13
{
64eb13
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
8a369b
	mb_pwd=$(pwd -P)
d40d13
839391
	mb_safe_path_desc='project directory'
839391
	mb_safe_path_name="$mb_project_dir"
839391
	verify_safe_path
839391
839391
	mb_safe_path_desc='working directory'
839391
	mb_safe_path_name="$mb_pwd"
839391
	verify_safe_path
839391
fd8eb5
	mb_custom_cfgdefs_args=''
fd8eb5
	mb_custom_cfgdefs_space=''
fd8eb5
afb44f
	mb_srcinfo='$(PROJECT_DIR)/project/srcdist/srcinfo.in'
afb44f
	mb_srcsite='localhost'
afb44f
afb44f
	mb_pgprkey='!!VARIABLE_NOT_SET!!'
afb44f
	mb_pgpskey='!!VARIABLE_NOT_SET!!'
afb44f
de823d
	sfrt_impl_dir=$mb_project_dir/sofort
de823d
	sfrt_config_dir=$sfrt_impl_dir/config
de823d
	sfrt_core_dir=$sfrt_impl_dir/core
de823d
	sfrt_config_vars=$sfrt_config_dir/config.vars
de823d
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
de823d
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
de823d
38d444
	mb_make_vars=$(< "$sfrt_config_vars" \
38d444
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
548c78
38d444
	mb_impl_vars=$(< "$sfrt_config_vars" \
38d444
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
16681e
38d444
	mb_proj_vars=$(< "$sfrt_config_vars" \
38d444
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
16681e
38d444
	mb_flag_vars=$(< "$sfrt_flag_vars" \
38d444
		grep -v -e '^#' -e '^$')
16681e
16681e
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
16681e
7d9a2d
	for mb_var in $(printf '%s' "$mb_vars") ; do
548c78
		mb_expr=$mb_var='${'$mb_var':-}'
548c78
		eval "$mb_expr"
548c78
	done
548c78
711507
	# ccenv
711507
	. $mb_project_dir/sofort/ccenv/ccenv.sh
711507
ce8e9e
	if ! [ -L ./ccenv ]; then
711507
		if [ -d ./ccenv ]; then
711507
			rm -f ./ccenv/host.mk
711507
			rm -f ./ccenv/native.mk
711507
			rmdir ./ccenv
711507
		fi
711507
	fi
711507
711507
	# config.project
47b1b5
	if [ -z "$mb_config" ]; then
fb2052
		. $mb_project_dir/config.project
d40d13
	else
fb2052
		. "$mb_config"
d40d13
	fi
d40d13
764ca5
	# srcinfo
764ca5
	if [ -n "$SOURCE_DIR" ]; then
764ca5
		mb_source_dir_set=yes
764ca5
	fi
764ca5
188a79
	# step prolog
188a79
	output_step_prolog ${mb_script} 'init_vars'
188a79
9c6a0f
	# project
9c6a0f
	mb_nickname=$NICKNAME
694972
	mb_source_dir=$SOURCE_DIR
9c6a0f
d40d13
	# dirs
d40d13
	mb_prefix=$PREFIX
58536c
	mb_exec_prefix=$EXEC_PREFIX
b023b2
	mb_bindir=$BINDIR
698a3c
	mb_sbindir=$SBINDIR
b023b2
	mb_libdir=$LIBDIR
b023b2
	mb_includedir=$INCLUDEDIR
47362f
	mb_oldincludedir=$OLDINCLUDEDIR
b023b2
	mb_mandir=$MANDIR
b023b2
	mb_docdir=$DOCDIR
b023b2
	mb_libexecdir=$LIBEXECDIR
d40d13
47362f
	mb_sysconfdir=$SYSCONFDIR
47362f
	mb_sharedstatedir=$SHAREDSTATEDIR
47362f
	mb_localstatedir=$LOCALSTATEDIR
47362f
	mb_runstatedir=$RUNSTATEDIR
47362f
	mb_datarootdir=$DATAROOTDIR
47362f
	mb_datadir=$DATADIR
47362f
	mb_infodir=$INFODIR
47362f
	mb_localedir=$LOCALEDIR
47362f
	mb_htmldir=$HTMLDIR
47362f
	mb_dvidir=$DVIDIR
47362f
	mb_pdfdir=$PDFDIR
47362f
	mb_psdir=$PSDIR
47362f
d40d13
d40d13
	# build
d40d13
	mb_build=$BUILD
1cc0e3
	mb_cchost=$CCHOST
15f27a
	mb_cfghost=$CFGHOST
d40d13
	mb_arch=$ARCH
aee992
	mb_compiler=$COMPILER
e5d4bb
	mb_toolchain=$TOOLCHAIN
d40d13
	mb_sysroot=$SYSROOT
d40d13
	mb_cross_compile=$CROSS_COMPILE
d40d13
	mb_shell=$SHELL
d40d13
d40d13
	# switches
d40d13
	mb_cflags=$CFLAGS
d40d13
	mb_cflags_debug=$CFLAGS_DEBUG
d40d13
	mb_cflags_common=$CFLAGS_COMMON
d40d13
	mb_cflags_cmdline=$CFLAGS_CMDLINE
d40d13
	mb_cflags_config=$CFLAGS_CONFIG
d40d13
	mb_cflags_sysroot=$CFLAGS_SYSROOT
596f2f
	mb_cflags_os=$CFLAGS_OS
596f2f
	mb_cflags_site=$CFLAGS_SITE
d40d13
	mb_cflags_path=$CFLAGS_PATH
598fb4
	mb_cflags_strict=$CFLAGS_STRICT
54173a
	mb_cflags_util=$CFLAGS_UTIL
b35cf1
	mb_cflags_last=$CFLAGS_LAST
b35cf1
	mb_cflags_once=$CFLAGS_ONCE
d40d13
d40d13
	mb_ldflags=$LDFLAGS
d40d13
	mb_ldflags_debug=$LDFLAGS_DEBUG
d40d13
	mb_ldflags_common=$LDFLAGS_COMMON
d40d13
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
d40d13
	mb_ldflags_config=$LDFLAGS_CONFIG
d40d13
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
d40d13
	mb_ldflags_path=$LDFLAGS_PATH
598fb4
	mb_ldflags_strict=$LDFLAGS_STRICT
54173a
	mb_ldflags_util=$LDFLAGS_UTIL
b35cf1
	mb_ldflags_last=$LDFLAGS_LAST
b35cf1
	mb_ldflags_once=$LDFLAGS_ONCE
d40d13
d40d13
	mb_pe_subsystem=$PE_SUBSYSTEM
d40d13
	mb_pe_image_base=$PE_IMAGE_BASE
d40d13
d40d13
	# overrides
7f572b
	mb_user_cc=$CC
7f572b
	mb_user_cpp=$CPP
7f572b
	mb_user_cxx=$CXX
711507
711507
	mb_native_cc=$NATIVE_CC
711507
	mb_native_cpp=$NATIVE_CPP
711507
	mb_native_cxx=$NATIVE_CXX
711507
711507
	mb_native_host=$NATIVE_HOST
711507
	mb_native_cfghost=$NATIVE_CFGHOST
711507
	mb_native_cflags=$NATIVE_CFLAGS
711507
	mb_native_ldflags=$NATIVE_LDFLAGS
ad1be2
ad1be2
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
ad1be2
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
188a79
188a79
	# step epilog
188a79
	output_step_epilog
d40d13
}
d40d13
d40d13
d40d13
verify_build_directory()
d40d13
{
188a79
	output_step_prolog ${mb_script} 'verify_build_directory'
188a79
47b1b5
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
ba54a5
		if [ _$mb_require_out_of_tree = _yes ]; then
d40d13
			error_msg "$mb_package: out-of-tree builds are required."
d40d13
			error_msg "please invoke configure again from a clean build directory."
fb2052
			exit 1
d40d13
		else
d40d13
			mb_project_dir='.'
d40d13
		fi
d40d13
	fi
c55050
c55050
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
188a79
188a79
	output_step_epilog
d40d13
}
d40d13
d40d13
694972
verify_source_directory()
694972
{
188a79
	output_step_prolog ${mb_script} 'verify_source_directory'
188a79
9e63aa
	if [ _"$mb_source_dir" != _${mb_source_dir##* } ]; then
9e63aa
		error_msg "source directory path contains spaces, aborting."
9e63aa
		exit 1
9e63aa
	fi
9e63aa
9e63aa
	eval mb_source_dir=$(printf '%s' "$mb_source_dir")
9e63aa
694972
	if [ -z "$mb_source_dir" ]; then
ba54a5
		if [ _$mb_require_source_dir = _yes ]; then
694972
			error_msg "$mb_package: specifying an external source directory is required."
694972
			error_msg "you can set the source directory either via --source-dir=<path>,"
694972
			error_msg "or by setting the SOURCE_DIR variable."
fb2052
			exit 1
694972
		fi
694972
	fi
188a79
188a79
	output_step_epilog
694972
}
694972
694972
764ca5
verify_source_info()
764ca5
{
764ca5
	output_step_prolog ${mb_script} 'verify_source_info'
764ca5
764ca5
	if [ "${mb_source_dir_set:-}" = yes ]; then
764ca5
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ] || [ -n "$mb_srcball" ]; then
764ca5
			error_msg "$mb_package: conflicting arguments: --rawball/--modball/--srcball arguments"
764ca5
			error_msg "may not be used together with an explicit source-dir argument or variable."
764ca5
			exit 1
764ca5
		fi
764ca5
	fi
764ca5
764ca5
	if [ -n "$mb_srcball" ]; then
764ca5
		eval mb_srcball=$(printf '%s' "$mb_srcball")
764ca5
764ca5
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ]; then
764ca5
			error_msg "$mb_package: conflicting arguments: --rawball and/or --modball arguments"
764ca5
			error_msg "may not be used together with an explicitly --srcball argument."
764ca5
			exit 1
764ca5
		fi
764ca5
764ca5
		if [ -z "$mb_srcball_sha256" ]; then
764ca5
			error_msg "$mb_package: --srcball-sha256 must be provided"
764ca5
			error_msg "in conjunction with --srcball."
764ca5
			exit 1
764ca5
		fi
764ca5
764ca5
		mb_srcball_sha256_test=$(sha256sum "$mb_srcball")
764ca5
		mb_srcball_sha256_test="${mb_srcball_sha256_test%% *}"
764ca5
764ca5
		if [ "$mb_srcball_sha256_test" != "$mb_srcball_sha256" ]; then
764ca5
			error_msg "$mb_package: sha256 signature of srcball $mb_srcball does not match!"
764ca5
			exit 1
764ca5
		fi
764ca5
764ca5
		mb_srcball_topdir=$(xz -c -d "$mb_srcball" | pax | sed -n '1,1p')
764ca5
		mb_source_dir="./srctree/$mb_package/${mb_srcball_topdir%/}"
764ca5
764ca5
		mb_srcball_dirname=$(cd -- "${mb_srcball%/*}" ; pwd -P)
764ca5
		mb_srcball_basename=${mb_srcball##*/}
764ca5
		mb_srcball="$mb_srcball_dirname/$mb_srcball_basename"
764ca5
764ca5
		mkdir -p "./srctree/$mb_package"
764ca5
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_srcball" | pax -r)
764ca5
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
764ca5
	fi
764ca5
764ca5
	if [ -z "$mb_rawball" ] && [ -n "$mb_modball" ]; then
764ca5
		error_msg "$mb_package: conflicting arguments: --modball argument may only be used"
764ca5
		error_msg "together with an explicit --rawball argument."
764ca5
		exit 1
764ca5
	fi
764ca5
764ca5
	if [ -n "$mb_modball" ]; then
764ca5
		eval mb_modball=$(printf '%s' "$mb_modball")
764ca5
764ca5
		if [ -z "$mb_modball_sha256" ]; then
764ca5
			error_msg "$mb_package: --modball-sha256 must be provided"
764ca5
			error_msg "in conjunction with --modball."
764ca5
			exit 1
764ca5
		fi
764ca5
764ca5
		mb_modball_sha256_test=$(sha256sum "$mb_modball")
764ca5
		mb_modball_sha256_test="${mb_modball_sha256_test%% *}"
764ca5
764ca5
		if [ "$mb_modball_sha256_test" != "$mb_modball_sha256" ]; then
764ca5
			error_msg "$mb_package: sha256 signature of modball $mb_modball does not match!"
764ca5
			exit 1
764ca5
		fi
764ca5
	fi
764ca5
764ca5
	if [ -n "$mb_rawball" ]; then
764ca5
		eval mb_rawball=$(printf '%s' "$mb_rawball")
764ca5
764ca5
		if [ -z "$mb_rawball_sha256" ]; then
764ca5
			error_msg "$mb_package: --rawball-sha256 must be provided."
764ca5
			error_msg "in conjunction with --rawball."
764ca5
			exit 1
764ca5
		fi
764ca5
764ca5
		mb_rawball_sha256_test=$(sha256sum "$mb_rawball")
764ca5
		mb_rawball_sha256_test="${mb_rawball_sha256_test%% *}"
764ca5
764ca5
		if [ "$mb_rawball_sha256_test" != "$mb_rawball_sha256" ]; then
764ca5
			error_msg "$mb_package: sha256 signature of rawball $mb_rawball does not match!"
764ca5
			exit 1
764ca5
		fi
764ca5
764ca5
		mb_rawball_topdir=$(xz -c -d "$mb_rawball" | pax | sed -n '1,1p')
764ca5
		mb_source_dir="./srctree/$mb_package/${mb_rawball_topdir%/}"
764ca5
764ca5
		mb_rawball_dirname=$(cd -- "${mb_rawball%/*}" ; pwd -P)
764ca5
		mb_rawball_basename=${mb_rawball##*/}
764ca5
		mb_rawball="$mb_rawball_dirname/$mb_rawball_basename"
764ca5
764ca5
		mkdir -p "./srctree/$mb_package"
764ca5
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_rawball" | pax -r)
764ca5
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
764ca5
	fi
764ca5
764ca5
	if [ -n "$mb_modball" ]; then
764ca5
		mb_modball_dirname=$(cd -- "${mb_modball%/*}" ; pwd -P)
764ca5
		mb_modball_basename=${mb_modball##*/}
764ca5
		mb_modball="$mb_modball_dirname/$mb_modball_basename"
764ca5
764ca5
		mb_modball_topdir="./modtree/$mb_package/$mb_modball_sha256"
764ca5
		mkdir -p "$mb_modball_topdir"
764ca5
		mb_modball_topdir=$(cd -- $mb_modball_topdir; pwd -P)
764ca5
		mb_dummy=$(cd -- "$mb_modball_topdir"; xz -c -d "$mb_modball" | pax -r)
764ca5
764ca5
		if [ -d "$mb_modball_topdir/overlay" ]; then
764ca5
			mb_dummy=$(cd -- "$mb_modball_topdir/overlay"; \
764ca5
				cp -p -P -R . "$mb_source_dir")
764ca5
		fi
764ca5
764ca5
		if [ -d "$mb_modball_topdir/patches" ]; then
764ca5
			mb_dummy=$(cd -- "$mb_source_dir";                        \
764ca5
				for p in $mb_modball_topdir/patches/*.patch; do  \
764ca5
					patch -p1 < $p;                         \
764ca5
				done);
764ca5
		fi
764ca5
	fi
764ca5
764ca5
	output_step_epilog
764ca5
}
764ca5
764ca5
d40d13
common_defaults()
d40d13
{
188a79
	# step prolog
188a79
	output_step_prolog ${mb_script} 'common_defaults'
188a79
e7f88a
	# project-specific config definitions
e7f88a
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
e7f88a
		cat $sfrt_cfgdefs_in > cfgdefs.mk
e7f88a
	else
e7f88a
		printf '%s %s\n\n' \
e7f88a
				'# this project does not include' \
e7f88a
				'a custom config step.'           \
e7f88a
			> cfgdefs.mk
e7f88a
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
e7f88a
e7f88a
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
e7f88a
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
e7f88a
		fi
e7f88a
	fi
e7f88a
e7f88a
	# user build-time overrides
e7f88a
	touch usrdefs.mk
e7f88a
694972
	# git
694972
	if [ -n "$mb_source_dir" ]; then
694972
		if [ -d "$mb_source_dir/.git" ]; then
414a20
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
694972
		fi
694972
	elif [ -d "$mb_project_dir/.git" ]; then
414a20
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
694972
	fi
694972
9c6a0f
	# project
cde787
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
cde787
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
cde787
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
9c6a0f
f6311b
	# pkgconfig
cde787
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
cde787
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
cde787
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
cde787
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
cde787
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
cde787
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
027b66
	[ -n "$mb_pkgbugs" ]		|| mb_pkgbugs="$mb_default_pkgbugs"
027b66
	[ -n "$mb_pkghome" ]		|| mb_pkghome="$mb_default_pkghome"
cde787
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
cde787
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
f6311b
764ca5
	# srcinfo
764ca5
	[ -n "$mb_rawball" ]		|| mb_rawball="$mb_default_rawball"
764ca5
	[ -n "$mb_rawball_url" ]	|| mb_rawball_url="$mb_default_rawball_url"
764ca5
	[ -n "$mb_rawball_sha256" ]	|| mb_rawball_sha256="$mb_default_rawball_sha256"
764ca5
	[ -n "$mb_modball" ]		|| mb_modball="$mb_default_modball"
764ca5
	[ -n "$mb_modball_url" ]	|| mb_modball_url="$mb_default_modball_url"
764ca5
	[ -n "$mb_modball_sha256" ]	|| mb_modball_sha256="$mb_default_modball_sha256"
764ca5
	[ -n "$mb_srcball" ]		|| mb_srcball="$mb_default_srcball"
764ca5
	[ -n "$mb_srcball_url" ]	|| mb_srcball_url="$mb_default_srcball_url"
764ca5
	[ -n "$mb_srcball_sha256" ]	|| mb_srcball_sha256="$mb_default_srcball_sha256"
764ca5
d40d13
	# dirs
cde787
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
cde787
					|| mb_prefix='/usr/local'
cde787
cde787
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
cde787
					|| mb_exec_prefix=$mb_prefix
cde787
cde787
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
cde787
					|| [ -n "$mb_bindir_basename" ] \
cde787
					|| mb_bindir=$mb_exec_prefix/bin
cde787
cde787
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
cde787
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
cde787
cde787
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
cde787
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
cde787
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
cde787
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
cde787
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
cde787
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
cde787
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc
cde787
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
cde787
cde787
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
cde787
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
cde787
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
cde787
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
cde787
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
cde787
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
cde787
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
cde787
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
cde787
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
cde787
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
cde787
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
cde787
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
47362f
d40d13
	# switches
cde787
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
cde787
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
cde787
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
cde787
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
cde787
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
cde787
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
cde787
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
cde787
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
cde787
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
cde787
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
cde787
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
cde787
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
cde787
cde787
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
cde787
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
cde787
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
cde787
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
cde787
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
cde787
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
cde787
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
cde787
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
cde787
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
cde787
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
d40d13
895cbe
	# native switches
cde787
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
cde787
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
895cbe
dbc5ee
	# config
cde787
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
cde787
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
cde787
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
cde787
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
cde787
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
dbc5ee
d40d13
	# host/target
cde787
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
cde787
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
d40d13
d40d13
	# sysroot
47b1b5
	if [ -n "$mb_sysroot" ]; then
47b1b5
		if [ -z "$mb_cflags_sysroot" ]; then
d40d13
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
d40d13
		fi
d40d13
47b1b5
		if [ -z "$mb_ldflags_sysroot" ]; then
85ef28
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
d40d13
		fi
d40d13
	fi
d40d13
d40d13
	# debug
ba54a5
	if [ _$mb_debug = _yes ]; then
47b1b5
		if [ -z "$mb_cflags_debug" ]; then
d40d13
			mb_cflags_debug='-g3 -O0'
d40d13
		fi
d40d13
	fi
7f7098
11cdd4
	# shell
11cdd4
	if [ -z "$mb_shell" ]; then
11cdd4
		mb_shell='/bin/sh'
11cdd4
	fi
11cdd4
7f7098
	# inherited cflags & ldflags
7f7098
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
7f7098
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
188a79
188a79
	# step epilog
188a79
	output_step_epilog
d40d13
}
d40d13
d40d13
591339
config_flags()
591339
{
188a79
	# step prolog
188a79
	output_step_prolog ${mb_script} 'config_flags'
188a79
591339
	mb_ldflags_tmp=" $mb_ldflags "
1f655e
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
591339
591339
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
591339
		mb_ldflags="$mb_ldflags_libs"
591339
		mb_ldflags_util="$mb_ldflags_util -static"
591339
	fi
598fb4
598fb4
	# ccstrict
ba54a5
	if [ _$mb_ccstrict = _yes ]; then
598fb4
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
598fb4
	fi
598fb4
598fb4
	# ldstrict
ba54a5
	if [ _$mb_ldstrict = _yes ]; then
598fb4
		mb_ldflags_strict='-Wl,--no-undefined'
598fb4
	fi
188a79
188a79
	# step epilog
188a79
	output_step_epilog
591339
}
591339
591339
d40d13
config_copy()
d40d13
{
188a79
	output_step_prolog ${mb_script} 'config_copy'
188a79
de823d
	mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \
16681e
			| grep -v '^#')
16681e
16681e
	mb_sed_substs=" \
7d9a2d
		$(for __var in $(printf '%s' "$mb_vars"); do   \
16681e
			printf '%s"$%s"%s' "-e 's^@$__var@^'" \
16681e
				"mb_$__var" "'^g' ";           \
16681e
		done)"
16681e
16681e
	eval sed $mb_sed_substs \
16681e
		$mb_project_dir/Makefile.in    \
e4cf2f
			| sed -e 's/[[:blank:]]*$//g' \
16681e
			> $mb_pwd/Makefile.tmp
188a79
188a79
	output_step_epilog
711507
}
1cc0e3
c68106
711507
config_ccenv()
711507
{
711507
	mkdir -p ./ccenv
711507
	touch ./ccenv/host.mk
711507
	touch ./ccenv/native.mk
45b33c
188a79
	output_section_break
711507
	ccenv_set_host_variables
188a79
188a79
	output_section_break
711507
	ccenv_set_native_variables
2b5dd6
188a79
	output_section_break
2b5dd6
	config_copy
711507
}
45b33c
20ad28
config_custom_cfgdefs()
20ad28
{
20ad28
	. $mb_project_dir/project/config/cfgdefs.sh
20ad28
}
20ad28
45b33c
config_custom()
45b33c
{
ba54a5
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
188a79
		output_section_break
188a79
		output_script_status ${mb_script} \
bbde52
			'invoking project-specific cfgdefs.sh'
188a79
20ad28
		eval config_custom_cfgdefs "$mb_custom_cfgdefs_args"
188a79
188a79
		output_section_break
45b33c
		config_copy
45b33c
	fi
1cc0e3
ba54a5
	if [ _$mb_use_custom_usrdefs = _yes ]; then
188a79
		output_section_break
188a79
		output_script_status ${mb_scirpt} \
bbde52
			'invoking project-specific usrdefs.sh'
188a79
45b33c
		. $mb_project_dir/project/usrdefs.sh
188a79
		output_section_break
45b33c
	fi
45b33c
}
45b33c
45b33c
45b33c
config_cfghost()
45b33c
{
188a79
	output_step_prolog ${mb_script} 'config_cfghost'
188a79
15f27a
	if [ -z "$mb_cfghost" ]; then
15f27a
		mb_cfghost=$mb_cchost
15f27a
	fi
15f27a
15f27a
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
15f27a
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
fb2052
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
1cc0e3
fb2052
	rm  $mb_pwd/Makefile.tmp
fb2052
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile
188a79
188a79
	output_step_epilog
d40d13
}
d40d13
d40d13
e61178
config_host()
e61178
{
188a79
	output_step_prolog ${mb_script} 'config_host'
188a79
188a79
	make -s host.tag             \
188a79
		&& output_step_epilog \
188a79
		&& return 0
e61178
e61178
	error_msg "configure was able to generate a Makefile for the selected host,"
aee992
	error_msg "however the host-targeting compiler was found to be missing"
e61178
	error_msg "at least one of the required headers or features."
e61178
	exit 2
e61178
}
e61178
d40d13
b8b59f
config_status()
b8b59f
{
188a79
	output_script_status ${mb_script} \
188a79
		'configuration completed successfully.'
188a79
	printf '\n'
b8b59f
}
b8b59f
c55050
c55050
config_failure()
c55050
{
53789e
	if [ _$mb_success = _yes ]; then
53789e
		return 0
53789e
	fi
53789e
bbde52
	printf 'configure info: exiting due to an error.\n' >&3
bbde52
c55050
	exit 2
c55050
}
c55050
c55050
c55050
config_success()
c55050
{
c55050
	trap '' EXIT
53789e
	mb_success=yes
c55050
	exit 0
c55050
}
c55050
c55050
d40d13
# one: init
bbde52
mb_args=
bbde52
mb_args_space=
bbde52
bbde52
for arg ; do
bbde52
	mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
bbde52
	mb_args="$mb_args$mb_args_space$mb_escaped_arg"
bbde52
	mb_args_space=' '
bbde52
done
bbde52
bbde52
init_log
d40d13
init_vars
d40d13
verify_build_directory
d40d13
d40d13
d40d13
# two: args
d40d13
for arg ; do
d40d13
	case "$arg" in
711507
		--help)
711507
			usage
711507
			;;
711507
		--help=ccenv)
711507
			ccenv_usage
711507
			;;
711507
711507
		# ccenv
711507
		--cross-compile=*)
711507
			mb_cross_compile=${arg#*=}
711507
			;;
711507
		--compiler=*)
711507
			mb_compiler=${arg#*=}
711507
			;;
711507
		--toolchain=*)
711507
			mb_toolchain=${arg#*=}
711507
			;;
711507
		--zealous)
711507
			mb_agnostic=yes
711507
			mb_zealous=
711507
			;;
711507
		--zealous=*)
711507
			mb_zealous=${arg#*=}
711507
			;;
711507
		--ccenv=*)
711507
			mb_ccenv=${arg#*=}
d40d13
			;;
d40d13
d40d13
		# dirs
d40d13
		--prefix=*)
be9f3e
			mb_prefix_set=yes
d40d13
			mb_prefix=${arg#*=}
d40d13
			;;
58536c
		--exec-prefix=*)
be9f3e
			mb_exec_prefix_set=yes
58536c
			mb_exec_prefix=${arg#*=}
58536c
			;;
d40d13
		--bindir=*)
5ed577
			mb_bindir_set=yes
d40d13
			mb_bindir=${arg#*=}
d40d13
			;;
698a3c
		--sbindir=*)
698a3c
			mb_sbindir=${arg#*=}
698a3c
			;;
d40d13
		--libdir=*)
d40d13
			mb_libdir=${arg#*=}
d40d13
			;;
d40d13
		--includedir=*)
d40d13
			mb_includedir=${arg#*=}
d40d13
			;;
47362f
		--oldincludedir=*)
47362f
			mb_oldincludedir=${arg#*=}
47362f
			;;
d40d13
		--mandir=*)
d40d13
			mb_mandir=${arg#*=}
d40d13
			;;
d40d13
		--libexecdir=*)
d40d13
			mb_libexecdir=${arg#*=}
d40d13
			;;
d40d13
d40d13
47362f
		--sysconfdir=*)
47362f
			mb_sysconfdir=${arg#*=}
47362f
			;;
47362f
		--sharedstatedir=*)
47362f
			mb_sharedstatedir=${arg#*=}
47362f
			;;
47362f
		--localstatedir=*)
47362f
			mb_localstatedir=${arg#*=}
47362f
			;;
47362f
		--runstatedir=*)
47362f
			mb_runstatedir=${arg#*=}
47362f
			;;
47362f
		--datarootdir=*)
47362f
			mb_datarootdir=${arg#*=}
47362f
			;;
47362f
		--datadir=*)
47362f
			mb_datadir=${arg#*=}
47362f
			;;
47362f
		--infodir=*)
47362f
			mb_infodir=${arg#*=}
47362f
			;;
47362f
		--localedir=*)
47362f
			mb_localedir=${arg#*=}
47362f
			;;
47362f
		--htmldir=*)
47362f
			mb_htmldir=${arg#*=}
47362f
			;;
47362f
		--dvidir=*)
47362f
			mb_dvidir=${arg#*=}
47362f
			;;
47362f
		--pdfdir=*)
47362f
			mb_pdfdir=${arg#*=}
47362f
			;;
47362f
		--psdir=*)
47362f
			mb_psdir=${arg#*=}
47362f
			;;
47362f
47362f
d40d13
		# build
d40d13
		--build=*)
d40d13
			mb_build=${arg#*=}
d40d13
			;;
d40d13
		--host=*)
d40d13
			mb_host=${arg#*=}
d40d13
			;;
1cc0e3
		--cchost=*)
1cc0e3
			mb_cchost=${arg#*=}
1cc0e3
			;;
15f27a
		--cfghost=*)
15f27a
			mb_cfghost=${arg#*=}
15f27a
			;;
d40d13
		--target=*)
d40d13
			mb_target=${arg#*=}
d40d13
			;;
d40d13
		--arch=*)
d40d13
			mb_arch=${arg#*=}
d40d13
			;;
d40d13
		--sysroot=*)
d40d13
			mb_sysroot=${arg#*=}
d40d13
			;;
d40d13
		--shell=*)
d40d13
			mb_shell=${arg#*=}
d40d13
			;;
d40d13
		--debug)
ba54a5
			mb_debug=yes
d40d13
			;;
9c6a0f
dbc5ee
		# config
dbc5ee
		--all-static)
ba54a5
			mb_all_static=yes
57b45a
			mb_all_shared=no
dbc5ee
			;;
dbc5ee
		--all-shared)
ba54a5
			mb_all_shared=yes
57b45a
			mb_all_static=no
dbc5ee
			;;
ad42d8
		--disable-frontend)
ba54a5
			mb_disable_frontend=yes
ad42d8
			;;
ad42d8
		--disable-app)
ba54a5
			mb_disable_frontend=yes
ad42d8
			;;
ad42d8
		--enable-frontend)
ad42d8
			mb_disable_frontend='no'
ad42d8
			;;
ad42d8
		--enable-app)
ad42d8
			mb_disable_frontend='no'
ad42d8
			;;
dbc5ee
		--disable-static)
ba54a5
			mb_disable_static=yes
dbc5ee
			;;
dbc5ee
		--disable-shared)
ba54a5
			mb_disable_shared=yes
dbc5ee
			;;
dbc5ee
		--enable-static)
dbc5ee
			mb_disable_static='no'
dbc5ee
			;;
dbc5ee
		--enable-shared)
dbc5ee
			mb_disable_shared='no'
dbc5ee
			;;
dbc5ee
598fb4
		# convenience
598fb4
		--strict)
ba54a5
			mb_ccstrict=yes
ba54a5
			mb_ldstrict=yes
598fb4
			;;
598fb4
		--ccstrict)
ba54a5
			mb_ccstrict=yes
598fb4
			;;
598fb4
		--ldstrict)
ba54a5
			mb_ldstrict=yes
598fb4
			;;
598fb4
9c6a0f
		# project
9c6a0f
		--nickname=*)
9c6a0f
			mb_nickname=${arg#*=}
9c6a0f
			;;
aa17d2
		--program-prefix=*)
aa17d2
			mb_program_prefix=${arg#*=}
aa17d2
			;;
d564ee
		--avoid-version)
ba54a5
			mb_avoid_version=yes
d564ee
			;;
694972
		--source-dir=*)
694972
			mb_source_dir=${arg#*=}
764ca5
			mb_source_dir_set=yes
694972
			;;
bf221e
		--srcdir=*)
bf221e
			mb_source_dir=${arg#*=}
764ca5
			mb_source_dir_set=yes
bf221e
			;;
9c6a0f
f6311b
		# pkgconfig
f6311b
		--pkgname=*)
f6311b
			mb_pkgname=${arg#*=}
f6311b
			;;
f6311b
f6311b
		--pkgdesc=*)
f6311b
			mb_pkgdesc=${arg#*=}
f6311b
			;;
f6311b
f6311b
		--pkgusrc=*)
f6311b
			mb_pkgusrc=${arg#*=}
f6311b
			;;
f6311b
f6311b
		--pkgrepo=*)
f6311b
			mb_pkgrepo=${arg#*=}
f6311b
			;;
f6311b
f6311b
		--pkgpsrc=*)
f6311b
			mb_pkgpsrc=${arg#*=}
f6311b
			;;
f6311b
f6311b
		--pkgdurl=*)
f6311b
			mb_pkgdurl=${arg#*=}
f6311b
			;;
f6311b
027b66
		--pkgbugs=*)
027b66
			mb_pkgbugs=${arg#*=}
027b66
			;;
027b66
027b66
		--pkghome=*)
027b66
			mb_pkghome=${arg#*=}
027b66
			;;
027b66
f6311b
		--pkgdefs=*)
f6311b
			mb_pkgdefs=${arg#*=}
f6311b
			;;
f6311b
f6311b
		--pkglibs=*)
f6311b
			mb_pkglibs=${arg#*=}
f6311b
			;;
f6311b
764ca5
		# srcinfo
afb44f
		--srcinfo=*)
afb44f
			mb_srcinfo=${arg#*=}
afb44f
			;;
afb44f
afb44f
		--srcsite=*)
afb44f
			mb_srcsite=${arg#*=}
afb44f
			;;
afb44f
afb44f
		--pgprkey=*)
afb44f
			mb_pgprkey=${arg#*=}
afb44f
			;;
afb44f
afb44f
		--pgpskey=*)
afb44f
			mb_pgpskey=${arg#*=}
afb44f
			;;
afb44f
764ca5
		--rawball=*)
764ca5
			mb_rawball=${arg#*=}
764ca5
			;;
764ca5
764ca5
		--rawball-url=*)
764ca5
			mb_rawball_url=${arg#*=}
764ca5
			;;
764ca5
764ca5
		--rawball-sha256=*)
764ca5
			mb_rawball_sha256=${arg#*=}
764ca5
			;;
764ca5
764ca5
		--modball=*)
764ca5
			mb_modball=${arg#*=}
764ca5
			;;
764ca5
764ca5
		--modball-url=*)
764ca5
			mb_modball_url=${arg#*=}
764ca5
			;;
764ca5
764ca5
		--modball-sha256=*)
764ca5
			mb_modball_sha256=${arg#*=}
764ca5
			;;
764ca5
764ca5
		--srcball=*)
764ca5
			mb_srcball=${arg#*=}
764ca5
			;;
764ca5
764ca5
		--srcball-url=*)
764ca5
			mb_srcball_url=${arg#*=}
764ca5
			;;
764ca5
764ca5
		--srcball-sha256=*)
764ca5
			mb_srcball_sha256=${arg#*=}
764ca5
			;;
764ca5
93c49a
		# compatibility
93c49a
		--enable-dependency-tracking)
93c49a
			;;
93c49a
		--disable-dependency-tracking)
93c49a
			;;
93c49a
d40d13
		*)
ba54a5
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
fd8eb5
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
fd8eb5
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
fd8eb5
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
fd8eb5
				mb_custom_cfgdefs_space=' '
45b33c
			else
45b33c
				error_msg ${arg#}: "unsupported config argument."
45b33c
				exit 2
45b33c
			fi
d40d13
			;;
d40d13
	esac
839391
839391
	mb_safe_path_desc='source directory'
839391
	mb_safe_path_name="$mb_source_dir"
839391
	verify_safe_path
d40d13
done
d40d13
d40d13
d40d13
694972
# three: validation
694972
verify_source_directory
764ca5
verify_source_info
694972
aa17d2
if ! [ -z "$mb_program_prefix" ]; then
aa17d2
	error_msg "--program-prefix is not yet fully support (must be null)."
aa17d2
fi
aa17d2
694972
694972
694972
# four: defaults
d40d13
common_defaults
d40d13
d40d13
694972
# five: config
591339
config_flags
d40d13
config_copy
711507
config_ccenv
45b33c
config_custom
45b33c
config_cfghost
e61178
config_host
b8b59f
config_status
d40d13
d40d13
d40d13
# all done
c55050
config_success