Blame configure

52d60d
#!/bin/sh
52d60d
0bcce4
set -eu
0bcce4
1a8cc6
trap config_failure 1 2 EXIT
1a8cc6
df59ab
# before we begin...
df59ab
mb_path="$PATH"
a0f28b
mb_script="$0"
a0f28b
mb_success=no
df59ab
52d60d
usage()
52d60d
{
98322c
	cat "$mb_project_dir"/config.usage
c9d763
e60976
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
c9d763
		printf '\n\n%s%s\n' \
c9d763
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
c9d763
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
c9d763
c9d763
		printf '%s%s\n' \
c9d763
			"| Listed above are configure's common switches " \
c9d763
			"and environment variables.     |"
c9d763
c9d763
		printf '%s%s\n' \
c9d763
			"| Found below are project-specific variables " \
c9d763
			"and other customization options. |"
c9d763
c9d763
		printf '%s%s\n\n\n' \
c9d763
			" ___________________________________________" \
c9d763
			"__________________________________"
c9d763
c9d763
		cat "$mb_project_dir"/project/config/cfgdefs.usage
c9d763
	fi
c9d763
c9d763
	exit 0
52d60d
}
52d60d
52d60d
error_msg()
52d60d
{
dd4afc
	printf '%s\n' "$@" >&2
52d60d
}
52d60d
1f0e35
warning_msg()
1f0e35
{
dd4afc
	printf '%s\n' "$@" >&2
1f0e35
}
1f0e35
b5f5b5
output_step_prolog()
b5f5b5
{
b5f5b5
	mb_line_dots='..................................'
b5f5b5
	mb_line_dots="${mb_line_dots}${mb_line_dots}"
b5f5b5
	mb_step_desc="${mb_package} : ${1##*/} : ${2}() "
b5f5b5
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
b5f5b5
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s " "${mb_step_desc}" "${mb_line_dots}"
b5f5b5
}
b5f5b5
b5f5b5
output_step_epilog()
b5f5b5
{
b5f5b5
	printf 'OK.\n'
b5f5b5
}
b5f5b5
b5f5b5
output_script_status()
b5f5b5
{
b5f5b5
	mb_step_name="${1##*/} : ${2}"
b5f5b5
	mb_step_desc="${mb_package} : ${mb_step_name}"
b5f5b5
	printf "%s\n" "${mb_step_desc}"
b5f5b5
}
b5f5b5
b5f5b5
output_section_break()
b5f5b5
{
b5f5b5
	printf '...\n'
b5f5b5
}
b5f5b5
39bc3b
verify_safe_path()
39bc3b
{
39bc3b
	case "$mb_safe_path_name" in
39bc3b
		-*)
39bc3b
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
39bc3b
			exit 2
39bc3b
			;;
39bc3b
39bc3b
		*\ *)
39bc3b
			error_msg "$mb_safe_path_desc may not contain spaces."
39bc3b
			exit 2
39bc3b
			;;
39bc3b
	esac
39bc3b
}
52d60d
52d60d
init_vars()
52d60d
{
5f9ced
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
7cd8f2
	mb_pwd=$(pwd -P)
52d60d
39bc3b
	mb_safe_path_desc='project directory'
39bc3b
	mb_safe_path_name="$mb_project_dir"
39bc3b
	verify_safe_path
39bc3b
39bc3b
	mb_safe_path_desc='working directory'
39bc3b
	mb_safe_path_name="$mb_pwd"
39bc3b
	verify_safe_path
39bc3b
f4662b
	mb_custom_cfgdefs_args=''
f4662b
	mb_custom_cfgdefs_space=''
f4662b
d0476e
	sfrt_impl_dir=$mb_project_dir/sofort
d0476e
	sfrt_config_dir=$sfrt_impl_dir/config
d0476e
	sfrt_core_dir=$sfrt_impl_dir/core
d0476e
	sfrt_config_vars=$sfrt_config_dir/config.vars
d0476e
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
d0476e
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
d0476e
151b2b
	mb_make_vars=$(< "$sfrt_config_vars" \
151b2b
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
2490ea
151b2b
	mb_impl_vars=$(< "$sfrt_config_vars" \
151b2b
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
c3272a
151b2b
	mb_proj_vars=$(< "$sfrt_config_vars" \
151b2b
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
c3272a
151b2b
	mb_flag_vars=$(< "$sfrt_flag_vars" \
151b2b
		grep -v -e '^#' -e '^$')
c3272a
c3272a
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
c3272a
cd0e7f
	for mb_var in $(printf '%s' "$mb_vars") ; do
2490ea
		mb_expr=$mb_var='${'$mb_var':-}'
2490ea
		eval "$mb_expr"
2490ea
	done
2490ea
1a1e15
	# ccenv
1a1e15
	. $mb_project_dir/sofort/ccenv/ccenv.sh
1a1e15
19dcd9
	if ! [ -L ./ccenv ]; then
1a1e15
		if [ -d ./ccenv ]; then
1a1e15
			rm -f ./ccenv/host.mk
1a1e15
			rm -f ./ccenv/native.mk
1a1e15
			rmdir ./ccenv
1a1e15
		fi
1a1e15
	fi
1a1e15
1a1e15
	# config.project
011344
	if [ -z "$mb_config" ]; then
1ab9f8
		. $mb_project_dir/config.project
52d60d
	else
1ab9f8
		. "$mb_config"
52d60d
	fi
52d60d
b5f5b5
	# step prolog
b5f5b5
	output_step_prolog ${mb_script} 'init_vars'
b5f5b5
5b49a6
	# project
5b49a6
	mb_nickname=$NICKNAME
7b4710
	mb_source_dir=$SOURCE_DIR
5b49a6
52d60d
	# dirs
52d60d
	mb_prefix=$PREFIX
452aa8
	mb_exec_prefix=$EXEC_PREFIX
52d60d
	mb_bindir=$BINDIR
7ef888
	mb_sbindir=$SBINDIR
52d60d
	mb_libdir=$LIBDIR
52d60d
	mb_includedir=$INCLUDEDIR
00d77f
	mb_oldincludedir=$OLDINCLUDEDIR
52d60d
	mb_mandir=$MANDIR
52d60d
	mb_docdir=$DOCDIR
52d60d
	mb_libexecdir=$LIBEXECDIR
52d60d
00d77f
	mb_sysconfdir=$SYSCONFDIR
00d77f
	mb_sharedstatedir=$SHAREDSTATEDIR
00d77f
	mb_localstatedir=$LOCALSTATEDIR
00d77f
	mb_runstatedir=$RUNSTATEDIR
00d77f
	mb_datarootdir=$DATAROOTDIR
00d77f
	mb_datadir=$DATADIR
00d77f
	mb_infodir=$INFODIR
00d77f
	mb_localedir=$LOCALEDIR
00d77f
	mb_htmldir=$HTMLDIR
00d77f
	mb_dvidir=$DVIDIR
00d77f
	mb_pdfdir=$PDFDIR
00d77f
	mb_psdir=$PSDIR
00d77f
52d60d
52d60d
	# build
52d60d
	mb_build=$BUILD
927e2d
	mb_cchost=$CCHOST
1b579f
	mb_cfghost=$CFGHOST
52d60d
	mb_arch=$ARCH
220bb3
	mb_compiler=$COMPILER
2c5c40
	mb_toolchain=$TOOLCHAIN
52d60d
	mb_sysroot=$SYSROOT
52d60d
	mb_cross_compile=$CROSS_COMPILE
52d60d
	mb_shell=$SHELL
52d60d
52d60d
	# switches
52d60d
	mb_cflags=$CFLAGS
52d60d
	mb_cflags_debug=$CFLAGS_DEBUG
52d60d
	mb_cflags_common=$CFLAGS_COMMON
52d60d
	mb_cflags_cmdline=$CFLAGS_CMDLINE
52d60d
	mb_cflags_config=$CFLAGS_CONFIG
52d60d
	mb_cflags_sysroot=$CFLAGS_SYSROOT
5b49a6
	mb_cflags_os=$CFLAGS_OS
5b49a6
	mb_cflags_site=$CFLAGS_SITE
52d60d
	mb_cflags_path=$CFLAGS_PATH
5b49a6
	mb_cflags_strict=$CFLAGS_STRICT
5b49a6
	mb_cflags_util=$CFLAGS_UTIL
4c529e
	mb_cflags_last=$CFLAGS_LAST
4c529e
	mb_cflags_once=$CFLAGS_ONCE
52d60d
52d60d
	mb_ldflags=$LDFLAGS
52d60d
	mb_ldflags_debug=$LDFLAGS_DEBUG
52d60d
	mb_ldflags_common=$LDFLAGS_COMMON
52d60d
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
52d60d
	mb_ldflags_config=$LDFLAGS_CONFIG
52d60d
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
52d60d
	mb_ldflags_path=$LDFLAGS_PATH
5b49a6
	mb_ldflags_strict=$LDFLAGS_STRICT
5b49a6
	mb_ldflags_util=$LDFLAGS_UTIL
4c529e
	mb_ldflags_last=$LDFLAGS_LAST
4c529e
	mb_ldflags_once=$LDFLAGS_ONCE
52d60d
52d60d
	mb_pe_subsystem=$PE_SUBSYSTEM
52d60d
	mb_pe_image_base=$PE_IMAGE_BASE
52d60d
52d60d
	# overrides
52d60d
	mb_user_cc=$CC
52d60d
	mb_user_cpp=$CPP
52d60d
	mb_user_cxx=$CXX
1a1e15
1a1e15
	mb_native_cc=$NATIVE_CC
1a1e15
	mb_native_cpp=$NATIVE_CPP
1a1e15
	mb_native_cxx=$NATIVE_CXX
1a1e15
1a1e15
	mb_native_host=$NATIVE_HOST
1a1e15
	mb_native_cfghost=$NATIVE_CFGHOST
1a1e15
	mb_native_cflags=$NATIVE_CFLAGS
1a1e15
	mb_native_ldflags=$NATIVE_LDFLAGS
75f1da
75f1da
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
75f1da
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
b5f5b5
b5f5b5
	# step epilog
b5f5b5
	output_step_epilog
52d60d
}
52d60d
52d60d
52d60d
verify_build_directory()
52d60d
{
b5f5b5
	output_step_prolog ${mb_script} 'verify_build_directory'
b5f5b5
011344
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
e60976
		if [ _$mb_require_out_of_tree = _yes ]; then
52d60d
			error_msg "$mb_package: out-of-tree builds are required."
52d60d
			error_msg "please invoke configure again from a clean build directory."
1ab9f8
			exit 1
52d60d
		else
52d60d
			mb_project_dir='.'
52d60d
		fi
52d60d
	fi
1a8cc6
1a8cc6
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
b5f5b5
b5f5b5
	output_step_epilog
52d60d
}
52d60d
52d60d
7b4710
verify_source_directory()
7b4710
{
b5f5b5
	output_step_prolog ${mb_script} 'verify_source_directory'
b5f5b5
7b4710
	if [ -z "$mb_source_dir" ]; then
e60976
		if [ _$mb_require_source_dir = _yes ]; then
7b4710
			error_msg "$mb_package: specifying an external source directory is required."
7b4710
			error_msg "you can set the source directory either via --source-dir=<path>,"
7b4710
			error_msg "or by setting the SOURCE_DIR variable."
1ab9f8
			exit 1
7b4710
		fi
7b4710
	fi
b5f5b5
b5f5b5
	output_step_epilog
7b4710
}
7b4710
7b4710
52d60d
common_defaults()
52d60d
{
b5f5b5
	# step prolog
b5f5b5
	output_step_prolog ${mb_script} 'common_defaults'
b5f5b5
2f6758
	# project-specific config definitions
2f6758
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
2f6758
		cat $sfrt_cfgdefs_in > cfgdefs.mk
2f6758
	else
2f6758
		printf '%s %s\n\n' \
2f6758
				'# this project does not include' \
2f6758
				'a custom config step.'           \
2f6758
			> cfgdefs.mk
2f6758
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
2f6758
2f6758
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
2f6758
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
2f6758
		fi
2f6758
	fi
2f6758
2f6758
	# user build-time overrides
2f6758
	touch usrdefs.mk
2f6758
7b4710
	# git
7b4710
	if [ -n "$mb_source_dir" ]; then
7b4710
		if [ -d "$mb_source_dir/.git" ]; then
60c2b4
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
7b4710
		fi
7b4710
	elif [ -d "$mb_project_dir/.git" ]; then
60c2b4
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
7b4710
	fi
7b4710
5b49a6
	# project
b31d41
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
b31d41
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
b31d41
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
5b49a6
a4c3b9
	# pkgconfig
b31d41
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
b31d41
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
b31d41
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
b31d41
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
b31d41
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
b31d41
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
b31d41
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
b31d41
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
a4c3b9
52d60d
	# dirs
b31d41
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
b31d41
					|| mb_prefix='/usr/local'
b31d41
b31d41
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
b31d41
					|| mb_exec_prefix=$mb_prefix
b31d41
b31d41
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
b31d41
					|| [ -n "$mb_bindir_basename" ] \
b31d41
					|| mb_bindir=$mb_exec_prefix/bin
b31d41
b31d41
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
b31d41
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
b31d41
b31d41
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
b31d41
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
b31d41
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
b31d41
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
b31d41
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
b31d41
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
b31d41
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc
b31d41
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
b31d41
b31d41
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
b31d41
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
b31d41
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
b31d41
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
b31d41
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
b31d41
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
b31d41
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
b31d41
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
b31d41
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
b31d41
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
b31d41
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
b31d41
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
00d77f
52d60d
	# switches
b31d41
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
b31d41
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
b31d41
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
b31d41
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
b31d41
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
b31d41
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
b31d41
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
b31d41
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
b31d41
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
b31d41
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
b31d41
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
b31d41
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
b31d41
b31d41
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
b31d41
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
b31d41
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
b31d41
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
b31d41
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
b31d41
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
b31d41
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
b31d41
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
b31d41
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
b31d41
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
52d60d
4eeeee
	# native switches
b31d41
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
b31d41
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
4eeeee
5b49a6
	# config
b31d41
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
b31d41
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
b31d41
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
b31d41
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
b31d41
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
5b49a6
52d60d
	# host/target
b31d41
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
b31d41
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
52d60d
52d60d
	# sysroot
011344
	if [ -n "$mb_sysroot" ]; then
011344
		if [ -z "$mb_cflags_sysroot" ]; then
52d60d
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
52d60d
		fi
52d60d
011344
		if [ -z "$mb_ldflags_sysroot" ]; then
fcf74e
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
52d60d
		fi
52d60d
	fi
52d60d
52d60d
	# debug
e60976
	if [ _$mb_debug = _yes ]; then
011344
		if [ -z "$mb_cflags_debug" ]; then
52d60d
			mb_cflags_debug='-g3 -O0'
52d60d
		fi
52d60d
	fi
8fd4aa
4d957b
	# shell
4d957b
	if [ -z "$mb_shell" ]; then
4d957b
		mb_shell='/bin/sh'
4d957b
	fi
4d957b
8fd4aa
	# inherited cflags & ldflags
8fd4aa
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
8fd4aa
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
b5f5b5
b5f5b5
	# step epilog
b5f5b5
	output_step_epilog
52d60d
}
52d60d
52d60d
5b49a6
config_flags()
5b49a6
{
b5f5b5
	# step prolog
b5f5b5
	output_step_prolog ${mb_script} 'config_flags'
b5f5b5
5b49a6
	mb_ldflags_tmp=" $mb_ldflags "
df3fea
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
5b49a6
5b49a6
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
5b49a6
		mb_ldflags="$mb_ldflags_libs"
5b49a6
		mb_ldflags_util="$mb_ldflags_util -static"
5b49a6
	fi
5b49a6
5b49a6
	# ccstrict
e60976
	if [ _$mb_ccstrict = _yes ]; then
5b49a6
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
5b49a6
	fi
5b49a6
5b49a6
	# ldstrict
e60976
	if [ _$mb_ldstrict = _yes ]; then
5b49a6
		mb_ldflags_strict='-Wl,--no-undefined'
5b49a6
	fi
b5f5b5
b5f5b5
	# step epilog
b5f5b5
	output_step_epilog
5b49a6
}
5b49a6
5b49a6
52d60d
config_copy()
52d60d
{
b5f5b5
	output_step_prolog ${mb_script} 'config_copy'
b5f5b5
d0476e
	mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \
c3272a
			| grep -v '^#')
c3272a
c3272a
	mb_sed_substs=" \
cd0e7f
		$(for __var in $(printf '%s' "$mb_vars"); do   \
c3272a
			printf '%s"$%s"%s' "-e 's^@$__var@^'" \
c3272a
				"mb_$__var" "'^g' ";           \
c3272a
		done)"
c3272a
c3272a
	eval sed $mb_sed_substs \
c3272a
		$mb_project_dir/Makefile.in    \
f91fe2
			| sed -e 's/[[:blank:]]*$//g' \
c3272a
			> $mb_pwd/Makefile.tmp
b5f5b5
b5f5b5
	output_step_epilog
1a1e15
}
927e2d
c0640c
1a1e15
config_ccenv()
1a1e15
{
1a1e15
	mkdir -p ./ccenv
1a1e15
	touch ./ccenv/host.mk
1a1e15
	touch ./ccenv/native.mk
c9d763
b5f5b5
	output_section_break
1a1e15
	ccenv_set_host_variables
b5f5b5
b5f5b5
	output_section_break
1a1e15
	ccenv_set_native_variables
a6352c
b5f5b5
	output_section_break
a6352c
	config_copy
1a1e15
}
c9d763
c9d763
config_custom()
c9d763
{
e60976
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
b5f5b5
		output_section_break
b5f5b5
		output_script_status ${mb_script} \
b5f5b5
			'invoking project-specific cfgdefs.sh ==>'
b5f5b5
f4662b
		eval . $mb_project_dir/project/config/cfgdefs.sh \
f4662b
			"$mb_custom_cfgdefs_args"
b5f5b5
b5f5b5
		output_section_break
c9d763
		config_copy
c9d763
	fi
927e2d
e60976
	if [ _$mb_use_custom_usrdefs = _yes ]; then
b5f5b5
		output_section_break
b5f5b5
		output_script_status ${mb_scirpt} \
b5f5b5
			'invoking project-specific usrdefs.sh ==>'
b5f5b5
c9d763
		. $mb_project_dir/project/usrdefs.sh
b5f5b5
		output_section_break
c9d763
	fi
c9d763
}
c9d763
c9d763
c9d763
config_cfghost()
c9d763
{
b5f5b5
	output_step_prolog ${mb_script} 'config_cfghost'
b5f5b5
1b579f
	if [ -z "$mb_cfghost" ]; then
1b579f
		mb_cfghost=$mb_cchost
1b579f
	fi
1b579f
1b579f
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
1b579f
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
1ab9f8
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
927e2d
1ab9f8
	rm  $mb_pwd/Makefile.tmp
1ab9f8
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile
b5f5b5
b5f5b5
	output_step_epilog
52d60d
}
52d60d
52d60d
52d60d
config_host()
52d60d
{
b5f5b5
	output_step_prolog ${mb_script} 'config_host'
b5f5b5
b5f5b5
	make -s host.tag             \
b5f5b5
		&& output_step_epilog \
b5f5b5
		&& return 0
52d60d
52d60d
	error_msg "configure was able to generate a Makefile for the selected host,"
220bb3
	error_msg "however the host-targeting compiler was found to be missing"
52d60d
	error_msg "at least one of the required headers or features."
52d60d
	exit 2
52d60d
}
52d60d
52d60d
52d60d
config_status()
52d60d
{
b5f5b5
	output_script_status ${mb_script} \
b5f5b5
		'configuration completed successfully.'
b5f5b5
	printf '\n'
52d60d
}
52d60d
1a8cc6
1a8cc6
config_failure()
1a8cc6
{
c1591f
	if [ _$mb_success = _yes ]; then
c1591f
		return 0
c1591f
	fi
c1591f
1a8cc6
	if [ -f Makefile ]; then
1a8cc6
		mb_error='failed to use the generated Makefile.'
1a8cc6
		printf '\n%s: error: %s\n' "${0}" "$mb_error" >&2
1a8cc6
		mv Makefile Makefile.failed
1a8cc6
	fi
1a8cc6
1a8cc6
	exit 2
1a8cc6
}
1a8cc6
1a8cc6
1a8cc6
config_success()
1a8cc6
{
1a8cc6
	trap '' EXIT
c1591f
	mb_success=yes
1a8cc6
	exit 0
1a8cc6
}
1a8cc6
1a8cc6
52d60d
# one: init
52d60d
init_vars
52d60d
verify_build_directory
52d60d
52d60d
52d60d
# two: args
52d60d
for arg ; do
52d60d
	case "$arg" in
1a1e15
		--help)
1a1e15
			usage
1a1e15
			;;
1a1e15
		--help=ccenv)
1a1e15
			ccenv_usage
1a1e15
			;;
1a1e15
1a1e15
		# ccenv
1a1e15
		--cross-compile=*)
1a1e15
			mb_cross_compile=${arg#*=}
1a1e15
			;;
1a1e15
		--compiler=*)
1a1e15
			mb_compiler=${arg#*=}
1a1e15
			;;
1a1e15
		--toolchain=*)
1a1e15
			mb_toolchain=${arg#*=}
1a1e15
			;;
1a1e15
		--zealous)
1a1e15
			mb_agnostic=yes
1a1e15
			mb_zealous=
1a1e15
			;;
1a1e15
		--zealous=*)
1a1e15
			mb_zealous=${arg#*=}
1a1e15
			;;
1a1e15
		--ccenv=*)
1a1e15
			mb_ccenv=${arg#*=}
52d60d
			;;
52d60d
52d60d
		# dirs
52d60d
		--prefix=*)
48b5b4
			mb_prefix_set=yes
52d60d
			mb_prefix=${arg#*=}
52d60d
			;;
452aa8
		--exec-prefix=*)
48b5b4
			mb_exec_prefix_set=yes
452aa8
			mb_exec_prefix=${arg#*=}
452aa8
			;;
52d60d
		--bindir=*)
09b3f4
			mb_bindir_set=yes
52d60d
			mb_bindir=${arg#*=}
52d60d
			;;
7ef888
		--sbindir=*)
7ef888
			mb_sbindir=${arg#*=}
7ef888
			;;
52d60d
		--libdir=*)
52d60d
			mb_libdir=${arg#*=}
52d60d
			;;
52d60d
		--includedir=*)
52d60d
			mb_includedir=${arg#*=}
52d60d
			;;
00d77f
		--oldincludedir=*)
00d77f
			mb_oldincludedir=${arg#*=}
00d77f
			;;
52d60d
		--mandir=*)
52d60d
			mb_mandir=${arg#*=}
52d60d
			;;
52d60d
		--libexecdir=*)
52d60d
			mb_libexecdir=${arg#*=}
52d60d
			;;
52d60d
52d60d
00d77f
		--sysconfdir=*)
00d77f
			mb_sysconfdir=${arg#*=}
00d77f
			;;
00d77f
		--sharedstatedir=*)
00d77f
			mb_sharedstatedir=${arg#*=}
00d77f
			;;
00d77f
		--localstatedir=*)
00d77f
			mb_localstatedir=${arg#*=}
00d77f
			;;
00d77f
		--runstatedir=*)
00d77f
			mb_runstatedir=${arg#*=}
00d77f
			;;
00d77f
		--datarootdir=*)
00d77f
			mb_datarootdir=${arg#*=}
00d77f
			;;
00d77f
		--datadir=*)
00d77f
			mb_datadir=${arg#*=}
00d77f
			;;
00d77f
		--infodir=*)
00d77f
			mb_infodir=${arg#*=}
00d77f
			;;
00d77f
		--localedir=*)
00d77f
			mb_localedir=${arg#*=}
00d77f
			;;
00d77f
		--htmldir=*)
00d77f
			mb_htmldir=${arg#*=}
00d77f
			;;
00d77f
		--dvidir=*)
00d77f
			mb_dvidir=${arg#*=}
00d77f
			;;
00d77f
		--pdfdir=*)
00d77f
			mb_pdfdir=${arg#*=}
00d77f
			;;
00d77f
		--psdir=*)
00d77f
			mb_psdir=${arg#*=}
00d77f
			;;
00d77f
00d77f
52d60d
		# build
52d60d
		--build=*)
52d60d
			mb_build=${arg#*=}
52d60d
			;;
52d60d
		--host=*)
52d60d
			mb_host=${arg#*=}
52d60d
			;;
927e2d
		--cchost=*)
927e2d
			mb_cchost=${arg#*=}
927e2d
			;;
1b579f
		--cfghost=*)
1b579f
			mb_cfghost=${arg#*=}
1b579f
			;;
52d60d
		--target=*)
52d60d
			mb_target=${arg#*=}
52d60d
			;;
52d60d
		--arch=*)
52d60d
			mb_arch=${arg#*=}
52d60d
			;;
52d60d
		--sysroot=*)
52d60d
			mb_sysroot=${arg#*=}
52d60d
			;;
52d60d
		--shell=*)
52d60d
			mb_shell=${arg#*=}
52d60d
			;;
52d60d
		--debug)
e60976
			mb_debug=yes
52d60d
			;;
5b49a6
5b49a6
		# config
5b49a6
		--all-static)
e60976
			mb_all_static=yes
65b93b
			mb_all_shared=no
5b49a6
			;;
5b49a6
		--all-shared)
e60976
			mb_all_shared=yes
65b93b
			mb_all_static=no
5b49a6
			;;
5b49a6
		--disable-frontend)
e60976
			mb_disable_frontend=yes
5b49a6
			;;
5b49a6
		--disable-app)
e60976
			mb_disable_frontend=yes
5b49a6
			;;
5b49a6
		--enable-frontend)
5b49a6
			mb_disable_frontend='no'
5b49a6
			;;
5b49a6
		--enable-app)
5b49a6
			mb_disable_frontend='no'
5b49a6
			;;
5b49a6
		--disable-static)
e60976
			mb_disable_static=yes
5b49a6
			;;
5b49a6
		--disable-shared)
e60976
			mb_disable_shared=yes
5b49a6
			;;
5b49a6
		--enable-static)
5b49a6
			mb_disable_static='no'
5b49a6
			;;
5b49a6
		--enable-shared)
5b49a6
			mb_disable_shared='no'
5b49a6
			;;
5b49a6
5b49a6
		# convenience
5b49a6
		--strict)
e60976
			mb_ccstrict=yes
e60976
			mb_ldstrict=yes
5b49a6
			;;
5b49a6
		--ccstrict)
e60976
			mb_ccstrict=yes
5b49a6
			;;
5b49a6
		--ldstrict)
e60976
			mb_ldstrict=yes
5b49a6
			;;
5b49a6
5b49a6
		# project
5b49a6
		--nickname=*)
5b49a6
			mb_nickname=${arg#*=}
5b49a6
			;;
206a49
		--program-prefix=*)
206a49
			mb_program_prefix=${arg#*=}
206a49
			;;
5b49a6
		--avoid-version)
e60976
			mb_avoid_version=yes
5b49a6
			;;
7b4710
		--source-dir=*)
7b4710
			mb_source_dir=${arg#*=}
7b4710
			;;
eb5f93
		--srcdir=*)
eb5f93
			mb_source_dir=${arg#*=}
eb5f93
			;;
5b49a6
a4c3b9
		# pkgconfig
a4c3b9
		--pkgname=*)
a4c3b9
			mb_pkgname=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgdesc=*)
a4c3b9
			mb_pkgdesc=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgusrc=*)
a4c3b9
			mb_pkgusrc=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgrepo=*)
a4c3b9
			mb_pkgrepo=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgpsrc=*)
a4c3b9
			mb_pkgpsrc=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgdurl=*)
a4c3b9
			mb_pkgdurl=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkgdefs=*)
a4c3b9
			mb_pkgdefs=${arg#*=}
a4c3b9
			;;
a4c3b9
a4c3b9
		--pkglibs=*)
a4c3b9
			mb_pkglibs=${arg#*=}
a4c3b9
			;;
a4c3b9
1df58c
		# compatibility
1df58c
		--enable-dependency-tracking)
1df58c
			;;
1df58c
		--disable-dependency-tracking)
1df58c
			;;
1df58c
52d60d
		*)
e60976
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
f4662b
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
f4662b
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
f4662b
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
f4662b
				mb_custom_cfgdefs_space=' '
c9d763
			else
c9d763
				error_msg ${arg#}: "unsupported config argument."
c9d763
				exit 2
c9d763
			fi
52d60d
			;;
52d60d
	esac
39bc3b
39bc3b
	mb_safe_path_desc='source directory'
39bc3b
	mb_safe_path_name="$mb_source_dir"
39bc3b
	verify_safe_path
52d60d
done
52d60d
52d60d
52d60d
7b4710
# three: validation
7b4710
verify_source_directory
7b4710
206a49
if ! [ -z "$mb_program_prefix" ]; then
206a49
	error_msg "--program-prefix is not yet fully support (must be null)."
206a49
fi
206a49
7b4710
7b4710
7b4710
# four: defaults
52d60d
common_defaults
52d60d
52d60d
7b4710
# five: config
5b49a6
config_flags
52d60d
config_copy
1a1e15
config_ccenv
c9d763
config_custom
c9d763
config_cfghost
52d60d
config_host
52d60d
config_status
52d60d
52d60d
52d60d
# all done
1a8cc6
config_success