Blame configure

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