Blame configure

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