orbea / cross / slibtool

Forked from cross/slibtool 3 years ago
Clone

Blame configure

9ca8c4
#!/bin/sh
9ca8c4
5ca785
set -eu
5ca785
c0614b
trap config_failure 1 2 EXIT
c0614b
cb498a
# before we begin...
cb498a
mb_path="$PATH"
3dcb0d
mb_script="$0"
3dcb0d
mb_success=no
cb498a
9ca8c4
usage()
9ca8c4
{
9ca8c4
	cat "$mb_project_dir"/config.usage
d2a366
29a758
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
d2a366
		printf '\n\n%s%s\n' \
d2a366
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
d2a366
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
d2a366
d2a366
		printf '%s%s\n' \
d2a366
			"| Listed above are configure's common switches " \
d2a366
			"and environment variables.     |"
d2a366
d2a366
		printf '%s%s\n' \
d2a366
			"| Found below are project-specific variables " \
d2a366
			"and other customization options. |"
d2a366
d2a366
		printf '%s%s\n\n\n' \
d2a366
			" ___________________________________________" \
d2a366
			"__________________________________"
d2a366
d2a366
		cat "$mb_project_dir"/project/config/cfgdefs.usage
d2a366
	fi
d2a366
d2a366
	exit 0
9ca8c4
}
9ca8c4
9ca8c4
error_msg()
9ca8c4
{
14aaab
	printf '%s' "$@" >&2
9ca8c4
}
9ca8c4
bd640f
warning_msg()
bd640f
{
14aaab
	printf '%s' "$@" >&2
bd640f
}
bd640f
8d201c
verify_safe_path()
8d201c
{
8d201c
	case "$mb_safe_path_name" in
8d201c
		-*)
8d201c
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
8d201c
			exit 2
8d201c
			;;
8d201c
8d201c
		*\ *)
8d201c
			error_msg "$mb_safe_path_desc may not contain spaces."
8d201c
			exit 2
8d201c
			;;
8d201c
	esac
8d201c
}
9ca8c4
9ca8c4
init_vars()
9ca8c4
{
ee0864
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
28bf9c
	mb_pwd=$(pwd -P)
9ca8c4
8d201c
	mb_safe_path_desc='project directory'
8d201c
	mb_safe_path_name="$mb_project_dir"
8d201c
	verify_safe_path
8d201c
8d201c
	mb_safe_path_desc='working directory'
8d201c
	mb_safe_path_name="$mb_pwd"
8d201c
	verify_safe_path
8d201c
43dbe7
	mb_custom_cfgdefs_args=''
43dbe7
	mb_custom_cfgdefs_space=''
43dbe7
3cdb2f
	sfrt_impl_dir=$mb_project_dir/sofort
3cdb2f
	sfrt_config_dir=$sfrt_impl_dir/config
3cdb2f
	sfrt_core_dir=$sfrt_impl_dir/core
3cdb2f
	sfrt_config_vars=$sfrt_config_dir/config.vars
3cdb2f
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
3cdb2f
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
3cdb2f
e99ec7
	mb_make_vars=$(< "$sfrt_config_vars" \
e99ec7
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
103e4c
e99ec7
	mb_impl_vars=$(< "$sfrt_config_vars" \
e99ec7
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
eb9c1b
e99ec7
	mb_proj_vars=$(< "$sfrt_config_vars" \
e99ec7
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
eb9c1b
e99ec7
	mb_flag_vars=$(< "$sfrt_flag_vars" \
e99ec7
		grep -v -e '^#' -e '^$')
eb9c1b
eb9c1b
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
eb9c1b
7cf81c
	for mb_var in $(printf '%s' "$mb_vars") ; do
103e4c
		mb_expr=$mb_var='${'$mb_var':-}'
103e4c
		eval "$mb_expr"
103e4c
	done
103e4c
f7f887
	# ccenv
f7f887
	. $mb_project_dir/sofort/ccenv/ccenv.sh
f7f887
890075
	if ! [ -L ./ccenv ]; then
f7f887
		if [ -d ./ccenv ]; then
f7f887
			rm -f ./ccenv/host.mk
f7f887
			rm -f ./ccenv/native.mk
f7f887
			rmdir ./ccenv
f7f887
		fi
f7f887
	fi
f7f887
f7f887
	# config.project
9ca8c4
	if [ -z "$mb_config" ]; then
0d2779
		. $mb_project_dir/config.project
9ca8c4
	else
0d2779
		. "$mb_config"
9ca8c4
	fi
9ca8c4
be9551
	# project
be9551
	mb_nickname=$NICKNAME
613e01
	mb_source_dir=$SOURCE_DIR
be9551
9ca8c4
	# dirs
9ca8c4
	mb_prefix=$PREFIX
4a022e
	mb_exec_prefix=$EXEC_PREFIX
9ca8c4
	mb_bindir=$BINDIR
67be49
	mb_sbindir=$SBINDIR
9ca8c4
	mb_libdir=$LIBDIR
9ca8c4
	mb_includedir=$INCLUDEDIR
aacf07
	mb_oldincludedir=$OLDINCLUDEDIR
9ca8c4
	mb_mandir=$MANDIR
9ca8c4
	mb_docdir=$DOCDIR
9ca8c4
	mb_libexecdir=$LIBEXECDIR
9ca8c4
aacf07
	mb_sysconfdir=$SYSCONFDIR
aacf07
	mb_sharedstatedir=$SHAREDSTATEDIR
aacf07
	mb_localstatedir=$LOCALSTATEDIR
aacf07
	mb_runstatedir=$RUNSTATEDIR
aacf07
	mb_datarootdir=$DATAROOTDIR
aacf07
	mb_datadir=$DATADIR
aacf07
	mb_infodir=$INFODIR
aacf07
	mb_localedir=$LOCALEDIR
aacf07
	mb_htmldir=$HTMLDIR
aacf07
	mb_dvidir=$DVIDIR
aacf07
	mb_pdfdir=$PDFDIR
aacf07
	mb_psdir=$PSDIR
aacf07
9ca8c4
9ca8c4
	# build
9ca8c4
	mb_build=$BUILD
f83f76
	mb_cchost=$CCHOST
f9d92c
	mb_cfghost=$CFGHOST
9ca8c4
	mb_arch=$ARCH
9ca8c4
	mb_compiler=$COMPILER
9ca8c4
	mb_toolchain=$TOOLCHAIN
9ca8c4
	mb_sysroot=$SYSROOT
9ca8c4
	mb_cross_compile=$CROSS_COMPILE
9ca8c4
	mb_shell=$SHELL
9ca8c4
9ca8c4
	# switches
9ca8c4
	mb_cflags=$CFLAGS
9ca8c4
	mb_cflags_debug=$CFLAGS_DEBUG
9ca8c4
	mb_cflags_common=$CFLAGS_COMMON
9ca8c4
	mb_cflags_cmdline=$CFLAGS_CMDLINE
9ca8c4
	mb_cflags_config=$CFLAGS_CONFIG
9ca8c4
	mb_cflags_sysroot=$CFLAGS_SYSROOT
9ca8c4
	mb_cflags_os=$CFLAGS_OS
9ca8c4
	mb_cflags_site=$CFLAGS_SITE
9ca8c4
	mb_cflags_path=$CFLAGS_PATH
1e6e10
	mb_cflags_strict=$CFLAGS_STRICT
fbb1cf
	mb_cflags_util=$CFLAGS_UTIL
c5c9ea
	mb_cflags_last=$CFLAGS_LAST
c5c9ea
	mb_cflags_once=$CFLAGS_ONCE
9ca8c4
9ca8c4
	mb_ldflags=$LDFLAGS
9ca8c4
	mb_ldflags_debug=$LDFLAGS_DEBUG
9ca8c4
	mb_ldflags_common=$LDFLAGS_COMMON
9ca8c4
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
9ca8c4
	mb_ldflags_config=$LDFLAGS_CONFIG
9ca8c4
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
9ca8c4
	mb_ldflags_path=$LDFLAGS_PATH
1e6e10
	mb_ldflags_strict=$LDFLAGS_STRICT
fbb1cf
	mb_ldflags_util=$LDFLAGS_UTIL
c5c9ea
	mb_ldflags_last=$LDFLAGS_LAST
c5c9ea
	mb_ldflags_once=$LDFLAGS_ONCE
9ca8c4
9ca8c4
	mb_pe_subsystem=$PE_SUBSYSTEM
9ca8c4
	mb_pe_image_base=$PE_IMAGE_BASE
9ca8c4
9ca8c4
	# overrides
9ca8c4
	mb_user_cc=$CC
9ca8c4
	mb_user_cpp=$CPP
9ca8c4
	mb_user_cxx=$CXX
f7f887
f7f887
	mb_native_cc=$NATIVE_CC
f7f887
	mb_native_cpp=$NATIVE_CPP
f7f887
	mb_native_cxx=$NATIVE_CXX
f7f887
f7f887
	mb_native_host=$NATIVE_HOST
f7f887
	mb_native_cfghost=$NATIVE_CFGHOST
f7f887
	mb_native_cflags=$NATIVE_CFLAGS
f7f887
	mb_native_ldflags=$NATIVE_LDFLAGS
fc67fb
fc67fb
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
fc67fb
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
9ca8c4
}
9ca8c4
9ca8c4
9ca8c4
verify_build_directory()
9ca8c4
{
9ca8c4
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
29a758
		if [ _$mb_require_out_of_tree = _yes ]; then
9ca8c4
			error_msg "$mb_package: out-of-tree builds are required."
9ca8c4
			error_msg "please invoke configure again from a clean build directory."
0d2779
			exit 1
9ca8c4
		else
9ca8c4
			mb_project_dir='.'
9ca8c4
		fi
9ca8c4
	fi
c0614b
c0614b
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
9ca8c4
}
9ca8c4
9ca8c4
613e01
verify_source_directory()
613e01
{
613e01
	if [ -z "$mb_source_dir" ]; then
29a758
		if [ _$mb_require_source_dir = _yes ]; then
613e01
			error_msg "$mb_package: specifying an external source directory is required."
613e01
			error_msg "you can set the source directory either via --source-dir=<path>,"
613e01
			error_msg "or by setting the SOURCE_DIR variable."
0d2779
			exit 1
613e01
		fi
613e01
	fi
613e01
}
613e01
613e01
9ca8c4
common_defaults()
9ca8c4
{
c0cca9
	# project-specific config definitions
c0cca9
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
c0cca9
		cat $sfrt_cfgdefs_in > cfgdefs.mk
c0cca9
	else
c0cca9
		printf '%s %s\n\n' \
c0cca9
				'# this project does not include' \
c0cca9
				'a custom config step.'           \
c0cca9
			> cfgdefs.mk
c0cca9
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
c0cca9
c0cca9
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
c0cca9
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
c0cca9
		fi
c0cca9
	fi
c0cca9
c0cca9
	# user build-time overrides
c0cca9
	touch usrdefs.mk
c0cca9
613e01
	# git
613e01
	if [ -n "$mb_source_dir" ]; then
613e01
		if [ -d "$mb_source_dir/.git" ]; then
8ad14b
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
613e01
		fi
613e01
	elif [ -d "$mb_project_dir/.git" ]; then
8ad14b
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
613e01
	fi
613e01
be9551
	# project
bb6565
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
bb6565
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
bb6565
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
be9551
bb8747
	# pkgconfig
bb6565
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
bb6565
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
bb6565
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
bb6565
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
bb6565
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
bb6565
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
bb6565
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
bb6565
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
bb8747
9ca8c4
	# dirs
bb6565
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
bb6565
					|| mb_prefix='/usr/local'
bb6565
bb6565
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
bb6565
					|| mb_exec_prefix=$mb_prefix
bb6565
bb6565
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
bb6565
					|| [ -n "$mb_bindir_basename" ] \
bb6565
					|| mb_bindir=$mb_exec_prefix/bin
bb6565
bb6565
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
bb6565
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
bb6565
bb6565
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
bb6565
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
bb6565
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
bb6565
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
bb6565
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
bb6565
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
bb6565
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc
bb6565
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
bb6565
bb6565
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
bb6565
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
bb6565
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
bb6565
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
bb6565
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
bb6565
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
bb6565
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
bb6565
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
bb6565
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
bb6565
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
bb6565
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
bb6565
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
aacf07
9ca8c4
	# switches
bb6565
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
bb6565
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
bb6565
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
bb6565
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
bb6565
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
bb6565
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
bb6565
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
bb6565
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
bb6565
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
bb6565
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
bb6565
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
bb6565
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
bb6565
bb6565
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
bb6565
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
bb6565
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
bb6565
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
bb6565
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
bb6565
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
bb6565
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
bb6565
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
bb6565
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
bb6565
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
9ca8c4
12b021
	# native switches
bb6565
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
bb6565
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
12b021
ffb3a0
	# config
bb6565
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
bb6565
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
bb6565
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
bb6565
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
bb6565
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
ffb3a0
9ca8c4
	# host/target
bb6565
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
bb6565
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
9ca8c4
9ca8c4
	# sysroot
9ca8c4
	if [ -n "$mb_sysroot" ]; then
9ca8c4
		if [ -z "$mb_cflags_sysroot" ]; then
9ca8c4
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
9ca8c4
		fi
9ca8c4
9ca8c4
		if [ -z "$mb_ldflags_sysroot" ]; then
d561f3
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
9ca8c4
		fi
9ca8c4
	fi
9ca8c4
9ca8c4
	# debug
29a758
	if [ _$mb_debug = _yes ]; then
9ca8c4
		if [ -z "$mb_cflags_debug" ]; then
9ca8c4
			mb_cflags_debug='-g3 -O0'
9ca8c4
		fi
9ca8c4
	fi
bdbc6b
7e32ce
	# shell
7e32ce
	if [ -z "$mb_shell" ]; then
7e32ce
		mb_shell='/bin/sh'
7e32ce
	fi
7e32ce
bdbc6b
	# inherited cflags & ldflags
bdbc6b
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
bdbc6b
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
9ca8c4
}
9ca8c4
9ca8c4
b89c8d
config_flags()
b89c8d
{
b89c8d
	mb_ldflags_tmp=" $mb_ldflags "
14aaab
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
b89c8d
b89c8d
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
b89c8d
		mb_ldflags="$mb_ldflags_libs"
b89c8d
		mb_ldflags_util="$mb_ldflags_util -static"
b89c8d
	fi
1e6e10
1e6e10
	# ccstrict
29a758
	if [ _$mb_ccstrict = _yes ]; then
1e6e10
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
1e6e10
	fi
1e6e10
1e6e10
	# ldstrict
29a758
	if [ _$mb_ldstrict = _yes ]; then
1e6e10
		mb_ldflags_strict='-Wl,--no-undefined'
1e6e10
	fi
b89c8d
}
b89c8d
b89c8d
9ca8c4
config_copy()
9ca8c4
{
3cdb2f
	mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \
eb9c1b
			| grep -v '^#')
eb9c1b
eb9c1b
	mb_sed_substs=" \
7cf81c
		$(for __var in $(printf '%s' "$mb_vars"); do   \
eb9c1b
			printf '%s"$%s"%s' "-e 's^@$__var@^'" \
eb9c1b
				"mb_$__var" "'^g' ";           \
eb9c1b
		done)"
eb9c1b
eb9c1b
	eval sed $mb_sed_substs \
eb9c1b
		$mb_project_dir/Makefile.in    \
43a259
			| sed -e 's/[[:blank:]]*$//g' \
eb9c1b
			> $mb_pwd/Makefile.tmp
f7f887
}
f83f76
4a289f
f7f887
config_ccenv()
f7f887
{
f7f887
	mkdir -p ./ccenv
f7f887
	touch ./ccenv/host.mk
f7f887
	touch ./ccenv/native.mk
d2a366
f7f887
	ccenv_set_host_variables
f7f887
	ccenv_set_native_variables
853512
853512
	config_copy
f7f887
}
d2a366
d2a366
config_custom()
d2a366
{
29a758
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
43dbe7
		eval . $mb_project_dir/project/config/cfgdefs.sh \
43dbe7
			"$mb_custom_cfgdefs_args"
d2a366
		config_copy
d2a366
	fi
f83f76
29a758
	if [ _$mb_use_custom_usrdefs = _yes ]; then
d2a366
		. $mb_project_dir/project/usrdefs.sh
d2a366
	fi
d2a366
}
d2a366
d2a366
d2a366
config_cfghost()
d2a366
{
f9d92c
	if [ -z "$mb_cfghost" ]; then
f9d92c
		mb_cfghost=$mb_cchost
f9d92c
	fi
f9d92c
f9d92c
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
f9d92c
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
0d2779
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
f83f76
0d2779
	rm  $mb_pwd/Makefile.tmp
0d2779
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile
9ca8c4
}
9ca8c4
9ca8c4
9ca8c4
config_host()
9ca8c4
{
9ca8c4
	make -s host.tag && return 0
9ca8c4
9ca8c4
	error_msg "configure was able to generate a Makefile for the selected host,"
9ca8c4
	error_msg "however the host-targeting compiler was found to be missing"
9ca8c4
	error_msg "at least one of the required headers or features."
9ca8c4
	exit 2
9ca8c4
}
9ca8c4
9ca8c4
9ca8c4
config_status()
9ca8c4
{
7cf81c
	printf '\n\n'
3751a8
	make -j1 .display
7cf81c
	printf '\nconfiguration completed successfully.\n\n'
9ca8c4
}
9ca8c4
c0614b
c0614b
config_failure()
c0614b
{
7a7f40
	if [ _$mb_success = _yes ]; then
7a7f40
		return 0
7a7f40
	fi
7a7f40
c0614b
	if [ -f Makefile ]; then
c0614b
		mb_error='failed to use the generated Makefile.'
c0614b
		printf '\n%s: error: %s\n' "${0}" "$mb_error" >&2
c0614b
		mv Makefile Makefile.failed
c0614b
	fi
c0614b
c0614b
	exit 2
c0614b
}
c0614b
c0614b
c0614b
config_success()
c0614b
{
c0614b
	trap '' EXIT
7a7f40
	mb_success=yes
c0614b
	exit 0
c0614b
}
c0614b
c0614b
9ca8c4
# one: init
9ca8c4
init_vars
9ca8c4
verify_build_directory
9ca8c4
9ca8c4
9ca8c4
# two: args
9ca8c4
for arg ; do
9ca8c4
	case "$arg" in
f7f887
		--help)
f7f887
			usage
f7f887
			;;
f7f887
		--help=ccenv)
f7f887
			ccenv_usage
f7f887
			;;
f7f887
f7f887
		# ccenv
f7f887
		--cross-compile=*)
f7f887
			mb_cross_compile=${arg#*=}
f7f887
			;;
f7f887
		--compiler=*)
f7f887
			mb_compiler=${arg#*=}
f7f887
			;;
f7f887
		--toolchain=*)
f7f887
			mb_toolchain=${arg#*=}
f7f887
			;;
f7f887
		--zealous)
f7f887
			mb_agnostic=yes
f7f887
			mb_zealous=
f7f887
			;;
f7f887
		--zealous=*)
f7f887
			mb_zealous=${arg#*=}
f7f887
			;;
f7f887
		--ccenv=*)
f7f887
			mb_ccenv=${arg#*=}
9ca8c4
			;;
9ca8c4
9ca8c4
		# dirs
9ca8c4
		--prefix=*)
250816
			mb_prefix_set=yes
9ca8c4
			mb_prefix=${arg#*=}
9ca8c4
			;;
4a022e
		--exec-prefix=*)
250816
			mb_exec_prefix_set=yes
4a022e
			mb_exec_prefix=${arg#*=}
4a022e
			;;
9ca8c4
		--bindir=*)
290087
			mb_bindir_set=yes
9ca8c4
			mb_bindir=${arg#*=}
9ca8c4
			;;
67be49
		--sbindir=*)
67be49
			mb_sbindir=${arg#*=}
67be49
			;;
9ca8c4
		--libdir=*)
9ca8c4
			mb_libdir=${arg#*=}
9ca8c4
			;;
9ca8c4
		--includedir=*)
9ca8c4
			mb_includedir=${arg#*=}
9ca8c4
			;;
aacf07
		--oldincludedir=*)
aacf07
			mb_oldincludedir=${arg#*=}
aacf07
			;;
9ca8c4
		--mandir=*)
9ca8c4
			mb_mandir=${arg#*=}
9ca8c4
			;;
9ca8c4
		--libexecdir=*)
9ca8c4
			mb_libexecdir=${arg#*=}
9ca8c4
			;;
9ca8c4
9ca8c4
aacf07
		--sysconfdir=*)
aacf07
			mb_sysconfdir=${arg#*=}
aacf07
			;;
aacf07
		--sharedstatedir=*)
aacf07
			mb_sharedstatedir=${arg#*=}
aacf07
			;;
aacf07
		--localstatedir=*)
aacf07
			mb_localstatedir=${arg#*=}
aacf07
			;;
aacf07
		--runstatedir=*)
aacf07
			mb_runstatedir=${arg#*=}
aacf07
			;;
aacf07
		--datarootdir=*)
aacf07
			mb_datarootdir=${arg#*=}
aacf07
			;;
aacf07
		--datadir=*)
aacf07
			mb_datadir=${arg#*=}
aacf07
			;;
aacf07
		--infodir=*)
aacf07
			mb_infodir=${arg#*=}
aacf07
			;;
aacf07
		--localedir=*)
aacf07
			mb_localedir=${arg#*=}
aacf07
			;;
aacf07
		--htmldir=*)
aacf07
			mb_htmldir=${arg#*=}
aacf07
			;;
aacf07
		--dvidir=*)
aacf07
			mb_dvidir=${arg#*=}
aacf07
			;;
aacf07
		--pdfdir=*)
aacf07
			mb_pdfdir=${arg#*=}
aacf07
			;;
aacf07
		--psdir=*)
aacf07
			mb_psdir=${arg#*=}
aacf07
			;;
aacf07
aacf07
9ca8c4
		# build
9ca8c4
		--build=*)
9ca8c4
			mb_build=${arg#*=}
9ca8c4
			;;
9ca8c4
		--host=*)
9ca8c4
			mb_host=${arg#*=}
9ca8c4
			;;
f83f76
		--cchost=*)
f83f76
			mb_cchost=${arg#*=}
f83f76
			;;
f9d92c
		--cfghost=*)
f9d92c
			mb_cfghost=${arg#*=}
f9d92c
			;;
9ca8c4
		--target=*)
9ca8c4
			mb_target=${arg#*=}
9ca8c4
			;;
9ca8c4
		--arch=*)
9ca8c4
			mb_arch=${arg#*=}
9ca8c4
			;;
9ca8c4
		--sysroot=*)
9ca8c4
			mb_sysroot=${arg#*=}
9ca8c4
			;;
9ca8c4
		--shell=*)
9ca8c4
			mb_shell=${arg#*=}
9ca8c4
			;;
9ca8c4
		--debug)
29a758
			mb_debug=yes
9ca8c4
			;;
be9551
ffb3a0
		# config
ffb3a0
		--all-static)
29a758
			mb_all_static=yes
5f2aa4
			mb_all_shared=no
ffb3a0
			;;
ffb3a0
		--all-shared)
29a758
			mb_all_shared=yes
5f2aa4
			mb_all_static=no
ffb3a0
			;;
bf8bd3
		--disable-frontend)
29a758
			mb_disable_frontend=yes
bf8bd3
			;;
bf8bd3
		--disable-app)
29a758
			mb_disable_frontend=yes
bf8bd3
			;;
bf8bd3
		--enable-frontend)
bf8bd3
			mb_disable_frontend='no'
bf8bd3
			;;
bf8bd3
		--enable-app)
bf8bd3
			mb_disable_frontend='no'
bf8bd3
			;;
ffb3a0
		--disable-static)
29a758
			mb_disable_static=yes
ffb3a0
			;;
ffb3a0
		--disable-shared)
29a758
			mb_disable_shared=yes
ffb3a0
			;;
ffb3a0
		--enable-static)
ffb3a0
			mb_disable_static='no'
ffb3a0
			;;
ffb3a0
		--enable-shared)
ffb3a0
			mb_disable_shared='no'
ffb3a0
			;;
ffb3a0
1e6e10
		# convenience
1e6e10
		--strict)
29a758
			mb_ccstrict=yes
29a758
			mb_ldstrict=yes
1e6e10
			;;
1e6e10
		--ccstrict)
29a758
			mb_ccstrict=yes
1e6e10
			;;
1e6e10
		--ldstrict)
29a758
			mb_ldstrict=yes
1e6e10
			;;
1e6e10
be9551
		# project
be9551
		--nickname=*)
be9551
			mb_nickname=${arg#*=}
be9551
			;;
7e3001
		--program-prefix=*)
7e3001
			mb_program_prefix=${arg#*=}
7e3001
			;;
2c8d99
		--avoid-version)
29a758
			mb_avoid_version=yes
2c8d99
			;;
613e01
		--source-dir=*)
613e01
			mb_source_dir=${arg#*=}
613e01
			;;
580a2a
		--srcdir=*)
580a2a
			mb_source_dir=${arg#*=}
580a2a
			;;
be9551
bb8747
		# pkgconfig
bb8747
		--pkgname=*)
bb8747
			mb_pkgname=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgdesc=*)
bb8747
			mb_pkgdesc=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgusrc=*)
bb8747
			mb_pkgusrc=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgrepo=*)
bb8747
			mb_pkgrepo=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgpsrc=*)
bb8747
			mb_pkgpsrc=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgdurl=*)
bb8747
			mb_pkgdurl=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgdefs=*)
bb8747
			mb_pkgdefs=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkglibs=*)
bb8747
			mb_pkglibs=${arg#*=}
bb8747
			;;
bb8747
25d614
		# compatibility
25d614
		--enable-dependency-tracking)
25d614
			;;
25d614
		--disable-dependency-tracking)
25d614
			;;
25d614
9ca8c4
		*)
29a758
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
43dbe7
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
43dbe7
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
43dbe7
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
43dbe7
				mb_custom_cfgdefs_space=' '
d2a366
			else
d2a366
				error_msg ${arg#}: "unsupported config argument."
d2a366
				exit 2
d2a366
			fi
9ca8c4
			;;
9ca8c4
	esac
8d201c
8d201c
	mb_safe_path_desc='source directory'
8d201c
	mb_safe_path_name="$mb_source_dir"
8d201c
	verify_safe_path
9ca8c4
done
9ca8c4
9ca8c4
9ca8c4
613e01
# three: validation
613e01
verify_source_directory
613e01
7e3001
if ! [ -z "$mb_program_prefix" ]; then
7e3001
	error_msg "--program-prefix is not yet fully support (must be null)."
7e3001
fi
7e3001
613e01
613e01
613e01
# four: defaults
9ca8c4
common_defaults
9ca8c4
9ca8c4
613e01
# five: config
b89c8d
config_flags
9ca8c4
config_copy
f7f887
config_ccenv
d2a366
config_custom
d2a366
config_cfghost
9ca8c4
config_host
9ca8c4
config_status
9ca8c4
9ca8c4
9ca8c4
# all done
c0614b
config_success