Blame configure

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