Blame configure

26e14f
#!/bin/sh
26e14f
794c0a
set -eu
794c0a
99b9ed
trap config_failure 1 2 EXIT
99b9ed
26e14f
usage()
26e14f
{
26e14f
	cat "$mb_project_dir"/config.usage
f7cf5c
dd7c0a
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
f7cf5c
		printf '\n\n%s%s\n' \
f7cf5c
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
f7cf5c
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
f7cf5c
f7cf5c
		printf '%s%s\n' \
f7cf5c
			"| Listed above are configure's common switches " \
f7cf5c
			"and environment variables.     |"
f7cf5c
f7cf5c
		printf '%s%s\n' \
f7cf5c
			"| Found below are project-specific variables " \
f7cf5c
			"and other customization options. |"
f7cf5c
f7cf5c
		printf '%s%s\n\n\n' \
f7cf5c
			" ___________________________________________" \
f7cf5c
			"__________________________________"
f7cf5c
f7cf5c
		cat "$mb_project_dir"/project/config/cfgdefs.usage
f7cf5c
	fi
f7cf5c
f7cf5c
	exit 0
26e14f
}
26e14f
26e14f
error_msg()
26e14f
{
26e14f
	echo "$@" >&2
26e14f
}
26e14f
26e14f
warning_msg()
26e14f
{
26e14f
	echo "$@" >&2
26e14f
}
26e14f
26e14f
26e14f
init_vars()
26e14f
{
18babb
	mb_project_dir=$(cd "$(dirname $0)" ; pwd)
4708b6
	mb_pwd=$(pwd)
26e14f
062152
	mb_custom_cfgdefs_args=''
062152
	mb_custom_cfgdefs_space=''
062152
80edc7
	mb_make_vars=$(cat $mb_project_dir/sofort/config.vars \
80edc7
		| grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
88d72b
80edc7
	mb_impl_vars=$(cat $mb_project_dir/sofort/config.vars \
80edc7
		| grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
80edc7
80edc7
	mb_proj_vars=$(cat $mb_project_dir/sofort/config.vars \
80edc7
		| grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
80edc7
80edc7
	mb_flag_vars=$(cat $mb_project_dir/sofort/flag.vars \
80edc7
		| grep -v -e '^#' -e '^$')
80edc7
80edc7
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
80edc7
80edc7
	for mb_var in $mb_vars ; do
88d72b
		mb_expr=$mb_var='${'$mb_var':-}'
88d72b
		eval "$mb_expr"
88d72b
	done
88d72b
dee5ee
	# ccenv
dee5ee
	. $mb_project_dir/sofort/ccenv/ccenv.sh
dee5ee
4e005e
	if ! [ -L ./ccenv ]; then
dee5ee
		if [ -d ./ccenv ]; then
dee5ee
			rm -f ./ccenv/host.mk
dee5ee
			rm -f ./ccenv/native.mk
dee5ee
			rmdir ./ccenv
dee5ee
		fi
dee5ee
	fi
dee5ee
dee5ee
	# config.project
26e14f
	if [ -z "$mb_config" ]; then
d415fa
		. $mb_project_dir/config.project
26e14f
	else
d415fa
		. "$mb_config"
26e14f
	fi
26e14f
d579c7
	# project-specific config definitions
dd7c0a
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
13c5e0
		cat $mb_project_dir/sofort/cfgdefs.in \
13c5e0
			> cfgdefs.mk
13c5e0
	else
13c5e0
		printf '%s %s\n\n' \
13c5e0
				'# this project does not include' \
13c5e0
				'a custom config step.'           \
13c5e0
			> cfgdefs.mk
13c5e0
		cat $mb_project_dir/sofort/cfgdefs.in >> cfgdefs.mk
d579c7
	fi
d579c7
d579c7
	# user build-time overrides
13c5e0
	touch usrdefs.mk
d579c7
26e14f
	# project
26e14f
	mb_nickname=$NICKNAME
26e14f
	mb_source_dir=$SOURCE_DIR
26e14f
26e14f
	# dirs
26e14f
	mb_prefix=$PREFIX
26e14f
	mb_exec_prefix=$EXEC_PREFIX
26e14f
	mb_bindir=$BINDIR
035302
	mb_sbindir=$SBINDIR
26e14f
	mb_libdir=$LIBDIR
26e14f
	mb_includedir=$INCLUDEDIR
cdceaf
	mb_oldincludedir=$OLDINCLUDEDIR
26e14f
	mb_mandir=$MANDIR
26e14f
	mb_docdir=$DOCDIR
26e14f
	mb_libexecdir=$LIBEXECDIR
26e14f
cdceaf
	mb_sysconfdir=$SYSCONFDIR
cdceaf
	mb_sharedstatedir=$SHAREDSTATEDIR
cdceaf
	mb_localstatedir=$LOCALSTATEDIR
cdceaf
	mb_runstatedir=$RUNSTATEDIR
cdceaf
	mb_datarootdir=$DATAROOTDIR
cdceaf
	mb_datadir=$DATADIR
cdceaf
	mb_infodir=$INFODIR
cdceaf
	mb_localedir=$LOCALEDIR
cdceaf
	mb_htmldir=$HTMLDIR
cdceaf
	mb_dvidir=$DVIDIR
cdceaf
	mb_pdfdir=$PDFDIR
cdceaf
	mb_psdir=$PSDIR
cdceaf
26e14f
26e14f
	# build
26e14f
	mb_build=$BUILD
26e14f
	mb_host=$HOST
04eb52
	mb_cchost=$CCHOST
5079dc
	mb_cfghost=$CFGHOST
26e14f
	mb_target=$TARGET
26e14f
	mb_arch=$ARCH
26e14f
	mb_compiler=$COMPILER
26e14f
	mb_toolchain=$TOOLCHAIN
26e14f
	mb_sysroot=$SYSROOT
26e14f
	mb_cross_compile=$CROSS_COMPILE
26e14f
	mb_shell=$SHELL
26e14f
26e14f
	# switches
26e14f
	mb_cflags=$CFLAGS
26e14f
	mb_cflags_debug=$CFLAGS_DEBUG
26e14f
	mb_cflags_common=$CFLAGS_COMMON
26e14f
	mb_cflags_cmdline=$CFLAGS_CMDLINE
26e14f
	mb_cflags_config=$CFLAGS_CONFIG
26e14f
	mb_cflags_sysroot=$CFLAGS_SYSROOT
26e14f
	mb_cflags_os=$CFLAGS_OS
26e14f
	mb_cflags_site=$CFLAGS_SITE
26e14f
	mb_cflags_path=$CFLAGS_PATH
26e14f
	mb_cflags_strict=$CFLAGS_STRICT
26e14f
	mb_cflags_util=$CFLAGS_UTIL
26e14f
	mb_cflags_last=$CFLAGS_LAST
26e14f
	mb_cflags_once=$CFLAGS_ONCE
26e14f
26e14f
	mb_ldflags=$LDFLAGS
26e14f
	mb_ldflags_debug=$LDFLAGS_DEBUG
26e14f
	mb_ldflags_common=$LDFLAGS_COMMON
26e14f
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
26e14f
	mb_ldflags_config=$LDFLAGS_CONFIG
26e14f
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
26e14f
	mb_ldflags_path=$LDFLAGS_PATH
26e14f
	mb_ldflags_strict=$LDFLAGS_STRICT
26e14f
	mb_ldflags_util=$LDFLAGS_UTIL
26e14f
	mb_ldflags_last=$LDFLAGS_LAST
26e14f
	mb_ldflags_once=$LDFLAGS_ONCE
26e14f
26e14f
	mb_pe_subsystem=$PE_SUBSYSTEM
26e14f
	mb_pe_image_base=$PE_IMAGE_BASE
26e14f
	mb_pe_config_defs=$PE_CONFIG_DEFS
26e14f
26e14f
	mb_elf_eh_frame=$ELF_EH_FRAME
26e14f
	mb_elf_hash_style=$ELF_HASH_STYLE
26e14f
	mb_elf_config_defs=$ELF_CONFIG_DEFS
26e14f
26e14f
	# overrides
26e14f
	mb_user_cc=$CC
26e14f
	mb_user_cpp=$CPP
26e14f
	mb_user_cxx=$CXX
dee5ee
dee5ee
	mb_native_cc=$NATIVE_CC
dee5ee
	mb_native_cpp=$NATIVE_CPP
dee5ee
	mb_native_cxx=$NATIVE_CXX
dee5ee
dee5ee
	mb_native_host=$NATIVE_HOST
dee5ee
	mb_native_cfghost=$NATIVE_CFGHOST
dee5ee
	mb_native_cflags=$NATIVE_CFLAGS
dee5ee
	mb_native_ldflags=$NATIVE_LDFLAGS
26e14f
}
26e14f
26e14f
26e14f
verify_build_directory()
26e14f
{
26e14f
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
dd7c0a
		if [ _$mb_require_out_of_tree = _yes ]; then
26e14f
			error_msg "$mb_package: out-of-tree builds are required."
26e14f
			error_msg "please invoke configure again from a clean build directory."
d415fa
			exit 1
26e14f
		else
26e14f
			mb_project_dir='.'
26e14f
		fi
26e14f
	fi
99b9ed
99b9ed
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
26e14f
}
26e14f
26e14f
26e14f
verify_source_directory()
26e14f
{
26e14f
	if [ -z "$mb_source_dir" ]; then
dd7c0a
		if [ _$mb_require_source_dir = _yes ]; then
26e14f
			error_msg "$mb_package: specifying an external source directory is required."
26e14f
			error_msg "you can set the source directory either via --source-dir=<path>,"
26e14f
			error_msg "or by setting the SOURCE_DIR variable."
d415fa
			exit 1
26e14f
		fi
26e14f
	fi
26e14f
}
26e14f
26e14f
26e14f
common_defaults()
26e14f
{
26e14f
	# git
26e14f
	if [ -n "$mb_source_dir" ]; then
26e14f
		if [ -d "$mb_source_dir/.git" ]; then
26e14f
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
26e14f
		fi
26e14f
	elif [ -d "$mb_project_dir/.git" ]; then
26e14f
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
26e14f
	fi
26e14f
26e14f
	# project
26e14f
	[ -z "$mb_nickname" ] 		&& mb_nickname=$mb_package
26e14f
	[ -z "$mb_source_dir" ] 	&& mb_source_dir=$mb_project_dir
26e14f
	[ -z "$mb_avoid_version" ] 	&& mb_avoid_version='no'
26e14f
750435
	# pkgconfig
750435
	[ -z "$mb_pkgname" ]		&& mb_pkgname="$mb_default_pkgname"
750435
	[ -z "$mb_pkgdesc" ]		&& mb_pkgdesc="$mb_default_pkgdesc"
750435
	[ -z "$mb_pkgusrc" ]		&& mb_pkgusrc="$mb_default_pkgusrc"
750435
	[ -z "$mb_pkgrepo" ]		&& mb_pkgrepo="$mb_default_pkgrepo"
750435
	[ -z "$mb_pkgpsrc" ]		&& mb_pkgpsrc="$mb_default_pkgpsrc"
750435
	[ -z "$mb_pkgdurl" ]		&& mb_pkgdurl="$mb_default_pkgdurl"
750435
	[ -z "$mb_pkgdefs" ]		&& mb_pkgdefs="$mb_default_pkgdefs"
750435
	[ -z "$mb_pkglibs" ]		&& mb_pkglibs="$mb_default_pkglibs"
750435
26e14f
	# dirs
26e14f
	[ -z "$mb_prefix" ] 		&& [ -z "$mb_prefix_set" ] \
26e14f
					&& mb_prefix='/usr/local'
26e14f
26e14f
	[ -z "$mb_exec_prefix" ] 	&& [ -z "$mb_exec_prefix_set" ]	\
26e14f
					&& mb_exec_prefix=$mb_prefix
26e14f
04cd68
	[ -z "$mb_bindir" ] 		&& [ -z "$mb_bindir_set" ] \
04cd68
					&& [ -z "$mb_bindir_basename" ] \
04cd68
					&& mb_bindir=$mb_exec_prefix/bin
04cd68
04cd68
	[ -z "$mb_bindir" ] 		&& [ -z "$mb_bindir_set" ] \
04cd68
					&& mb_bindir=$mb_exec_prefix/$mb_bindir_basename
04cd68
035302
	[ -z "$mb_sbindir" ] 		&& mb_sbindir=$mb_exec_prefix/sbin
26e14f
	[ -z "$mb_libdir" ] 		&& mb_libdir=$mb_exec_prefix/lib
26e14f
	[ -z "$mb_includedir" ]		&& mb_includedir=$mb_prefix/include
cdceaf
	[ -z "$mb_oldincludedir" ]	&& mb_oldincludedir=$mb_prefix/include
26e14f
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
26e14f
	[ -z "$mb_mandir" ] 		&& mb_mandir=$mb_datarootdir/man
26e14f
	[ -z "$mb_docdir" ] 		&& mb_docdir=$mb_datarootdir/doc
26e14f
	[ -z "$mb_libexecdir" ]		&& mb_libexecdir=$mb_exec_prefix/libexec
26e14f
cdceaf
	[ -z "$mb_sysconfdir" ] 	&& mb_sysconfdir=$mb_exec_prefix/etc
cdceaf
	[ -z "$mb_sharedstatedir" ] 	&& mb_sharedstatedir=$mb_prefix/com
cdceaf
	[ -z "$mb_localstatedir" ] 	&& mb_localstatedir=$mb_prefix/var
cdceaf
	[ -z "$mb_runstatedir" ] 	&& mb_runstatedir=$mb_localstatedir/run
cdceaf
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
cdceaf
	[ -z "$mb_datadir" ] 		&& mb_datadir=$mb_datarootdir
cdceaf
	[ -z "$mb_infodir" ] 		&& mb_infodir=$mb_datarootdir/info
cdceaf
	[ -z "$mb_localedir" ] 		&& mb_localedir=$mb_datarootdir/locale
cdceaf
	[ -z "$mb_htmldir" ] 		&& mb_htmldir=$mb_docdir
cdceaf
	[ -z "$mb_dvidir" ] 		&& mb_dvidir=$mb_docdir
cdceaf
	[ -z "$mb_pdfdir" ] 		&& mb_pdfdir=$mb_docdir
cdceaf
	[ -z "$mb_psdir" ] 		&& mb_psdir=$mb_docdir
cdceaf
cdceaf
26e14f
	# build
26e14f
	[ -z "$mb_build" ] 		&& mb_build=$mb_default_build
26e14f
	[ -z "$mb_host" ] 		&& mb_host=$mb_default_host
04eb52
	[ -z "$mb_cchost" ] 		&& mb_cchost=$mb_default_cchost
5079dc
	[ -z "$mb_cfghost" ] 		&& mb_cfghost=$mb_default_cfghost
26e14f
	[ -z "$mb_target" ] 		&& mb_target=$mb_default_target
26e14f
	[ -z "$mb_arch" ] 		&& mb_arch=$mb_default_arch
26e14f
	[ -z "$mb_compiler" ] 		&& mb_compiler=$mb_default_compiler
26e14f
	[ -z "$mb_toolchain" ] 		&& mb_toolchain=$mb_default_toolchain
26e14f
	[ -z "$mb_sysroot" ] 		&& mb_sysroot=$mb_default_sysroot
26e14f
	[ -z "$mb_cross_compile" ] 	&& mb_cross_compile=$mb_default_cross_compile
26e14f
	[ -z "$mb_shell" ] 		&& mb_shell=$mb_default_shell
26e14f
26e14f
	# switches
26e14f
	[ -z "$mb_cflags_debug" ]	&& mb_cflags_debug=$mb_default_cflags_debug
26e14f
	[ -z "$mb_cflags_common" ]	&& mb_cflags_common=$mb_default_cflags_common
26e14f
	[ -z "$mb_cflags_cmdline" ]	&& mb_cflags_cmdline=$mb_default_cflags_cmdline
26e14f
	[ -z "$mb_cflags_config" ]	&& mb_cflags_config=$mb_default_cflags_config
26e14f
	[ -z "$mb_cflags_sysroot" ]	&& mb_cflags_sysroot=$mb_default_cflags_sysroot
26e14f
	[ -z "$mb_cflags_os" ]		&& mb_cflags_os=$mb_default_cflags_os
26e14f
	[ -z "$mb_cflags_site" ]	&& mb_cflags_site=$mb_default_cflags_site
26e14f
	[ -z "$mb_cflags_path" ]	&& mb_cflags_path=$mb_default_cflags_path
26e14f
	[ -z "$mb_cflags_strict" ]	&& mb_cflags_strict=$mb_default_cflags_strict
26e14f
	[ -z "$mb_cflags_util" ]	&& mb_cflags_util=$mb_default_cflags_util
26e14f
	[ -z "$mb_cflags_last" ]	&& mb_cflags_last=$mb_default_cflags_last
26e14f
	[ -z "$mb_cflags_once" ]	&& mb_cflags_once=$mb_default_cflags_once
26e14f
26e14f
	[ -z "$mb_ldflags_debug" ]	&& mb_ldflags_debug=$mb_default_ldflags_debug
26e14f
	[ -z "$mb_ldflags_common" ]	&& mb_ldflags_common=$mb_default_ldflags_common
26e14f
	[ -z "$mb_ldflags_cmdline" ]	&& mb_ldflags_cmdline=$mb_default_ldflags_cmdline
26e14f
	[ -z "$mb_ldflags_config" ]	&& mb_ldflags_config=$mb_default_ldflags_config
26e14f
	[ -z "$mb_ldflags_sysroot" ]	&& mb_ldflags_sysroot=$mb_default_ldflags_sysroot
26e14f
	[ -z "$mb_ldflags_path" ]	&& mb_ldflags_path=$mb_default_ldflags_path
26e14f
	[ -z "$mb_ldflags_strict" ]	&& mb_ldflags_strict=$mb_default_ldflags_strict
26e14f
	[ -z "$mb_ldflags_util" ]	&& mb_ldflags_util=$mb_default_ldflags_util
26e14f
	[ -z "$mb_ldflags_last" ]	&& mb_ldflags_last=$mb_default_ldflags_last
26e14f
	[ -z "$mb_ldflags_once" ]	&& mb_ldflags_once=$mb_default_ldflags_once
26e14f
26e14f
	[ -z "$mb_pe_subsystem" ]	&& mb_pe_subsystem=$mb_default_pe_subsystem
26e14f
	[ -z "$mb_pe_image_base" ]	&& mb_pe_image_base=$mb_default_pe_image_base
26e14f
	[ -z "$mb_pe_config_defs" ]	&& mb_pe_config_defs=$mb_default_pe_config_defs
26e14f
26e14f
	[ -z "$mb_elf_eh_frame" ]	&& mb_elf_eh_frame=$mb_default_elf_eh_frame
26e14f
	[ -z "$mb_elf_hash_style" ]	&& mb_elf_hash_style=$mb_default_elf_hash_style
26e14f
	[ -z "$mb_elf_config_defs" ]	&& mb_elf_config_defs=$mb_default_elf_config_defs
26e14f
26e14f
	# config
26e14f
	[ -z "$mb_all_static" ]		&& mb_all_static='no'
26e14f
	[ -z "$mb_all_shared" ]		&& mb_all_shared='no'
26e14f
	[ -z "$mb_disable_frontend" ]	&& mb_disable_frontend='no'
26e14f
	[ -z "$mb_disable_static" ]	&& mb_disable_static='no'
26e14f
	[ -z "$mb_disable_shared" ]	&& mb_disable_shared='no'
26e14f
26e14f
	# host/target
26e14f
	[ -z "$mb_host" ] 		&& mb_host=$mb_target
26e14f
	[ -z "$mb_target" ] 		&& mb_target=$mb_host
26e14f
26e14f
	# sysroot
26e14f
	if [ -n "$mb_sysroot" ]; then
26e14f
		if [ -z "$mb_cflags_sysroot" ]; then
26e14f
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
26e14f
		fi
26e14f
26e14f
		if [ -z "$mb_ldflags_sysroot" ]; then
26e14f
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
26e14f
		fi
26e14f
	fi
26e14f
26e14f
	# debug
dd7c0a
	if [ _$mb_debug = _yes ]; then
26e14f
		if [ -z "$mb_cflags_debug" ]; then
26e14f
			mb_cflags_debug='-g3 -O0'
26e14f
		fi
26e14f
	fi
297266
297266
	# inherited cflags & ldflags
297266
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
297266
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
26e14f
}
26e14f
26e14f
26e14f
config_flags()
26e14f
{
26e14f
	mb_ldflags_tmp=" $mb_ldflags "
4708b6
	mb_ldflags_libs=$(echo "$mb_ldflags_tmp" | sed 's/ -static / /g')
26e14f
26e14f
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
26e14f
		mb_ldflags="$mb_ldflags_libs"
26e14f
		mb_ldflags_util="$mb_ldflags_util -static"
26e14f
	fi
26e14f
26e14f
	# ccstrict
dd7c0a
	if [ _$mb_ccstrict = _yes ]; then
26e14f
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
26e14f
	fi
26e14f
26e14f
	# ldstrict
dd7c0a
	if [ _$mb_ldstrict = _yes ]; then
26e14f
		mb_ldflags_strict='-Wl,--no-undefined'
26e14f
	fi
26e14f
}
26e14f
26e14f
26e14f
config_copy()
26e14f
{
80edc7
	mb_vars=$(cut -d'=' -f1 "$mb_project_dir/sofort/config.vars" \
80edc7
			| grep -v '^#')
80edc7
80edc7
	mb_sed_substs=" \
80edc7
		$(for __var in $mb_vars; do                  \
80edc7
			printf '%s"$%s"%s' "-e 's^@$__var@^'" \
80edc7
				"mb_$__var" "'^g' ";           \
80edc7
		done)"
80edc7
80edc7
	eval sed $mb_sed_substs \
80edc7
		$mb_project_dir/Makefile.in    \
80edc7
			| sed -e 's/[ \t]*$//g' \
80edc7
			> $mb_pwd/Makefile.tmp
dee5ee
}
04eb52
5fdd07
dee5ee
config_ccenv()
dee5ee
{
dee5ee
	mkdir -p ./ccenv
dee5ee
	touch ./ccenv/host.mk
dee5ee
	touch ./ccenv/native.mk
f7cf5c
dee5ee
	ccenv_set_host_variables
dee5ee
	ccenv_set_native_variables
f64fbb
f64fbb
	config_copy
dee5ee
}
f7cf5c
f7cf5c
config_custom()
f7cf5c
{
dd7c0a
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
062152
		eval . $mb_project_dir/project/config/cfgdefs.sh \
062152
			"$mb_custom_cfgdefs_args"
f7cf5c
		config_copy
f7cf5c
	fi
04eb52
dd7c0a
	if [ _$mb_use_custom_usrdefs = _yes ]; then
f7cf5c
		. $mb_project_dir/project/usrdefs.sh
f7cf5c
	fi
f7cf5c
}
f7cf5c
f7cf5c
f7cf5c
config_cfghost()
f7cf5c
{
5079dc
	if [ -z "$mb_cfghost" ]; then
5079dc
		mb_cfghost=$mb_cchost
5079dc
	fi
5079dc
5079dc
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
5079dc
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
d415fa
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
04eb52
d415fa
	rm  $mb_pwd/Makefile.tmp
d415fa
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile
26e14f
}
26e14f
26e14f
26e14f
config_support()
26e14f
{
dd7c0a
	[ _$mb_disable_shared = _yes ] && return 0
26e14f
4708b6
	mbt_cc=$(make .display-cc)
4708b6
	mbt_cflags=$(make .display-cflags)
26e14f
	mbt_source='int foo(int x){return ++x;}'
859d84
	mbt_result=no
26e14f
26e14f
	rm -f a.out
859d84
	printf '%s' "$mbt_source" | $mbt_cc -shared -o a.out -xc -
859d84
	[ -f a.out ] && mbt_result=yes
26e14f
	rm -f a.out
26e14f
859d84
	if [ $mbt_result = no ]; then
dd7c0a
		mb_disable_shared=yes
26e14f
		config_copy
26e14f
	fi
26e14f
}
26e14f
26e14f
26e14f
config_host()
26e14f
{
26e14f
	make -s host.tag && return 0
26e14f
26e14f
	error_msg "configure was able to generate a Makefile for the selected host,"
26e14f
	error_msg "however the host-targeting compiler was found to be missing"
26e14f
	error_msg "at least one of the required headers or features."
26e14f
	exit 2
26e14f
}
26e14f
26e14f
26e14f
config_status()
26e14f
{
26e14f
	printf "\n\n"
26e14f
	make .display
26e14f
	printf "\nconfiguration completed successfully.\n\n"
26e14f
}
26e14f
99b9ed
99b9ed
config_failure()
99b9ed
{
99b9ed
	if [ -f Makefile ]; then
99b9ed
		mb_error='failed to use the generated Makefile.'
99b9ed
		printf '\n%s: error: %s\n' "${0}" "$mb_error" >&2
99b9ed
		mv Makefile Makefile.failed
99b9ed
	fi
99b9ed
99b9ed
	exit 2
99b9ed
}
99b9ed
99b9ed
99b9ed
config_success()
99b9ed
{
99b9ed
	trap '' EXIT
99b9ed
	exit 0
99b9ed
}
99b9ed
99b9ed
26e14f
# one: init
26e14f
init_vars
26e14f
verify_build_directory
26e14f
26e14f
26e14f
# two: args
26e14f
for arg ; do
26e14f
	case "$arg" in
dee5ee
		--help)
dee5ee
			usage
dee5ee
			;;
dee5ee
		--help=ccenv)
dee5ee
			ccenv_usage
dee5ee
			;;
dee5ee
dee5ee
		# ccenv
dee5ee
		--cross-compile=*)
dee5ee
			mb_cross_compile=${arg#*=}
dee5ee
			;;
dee5ee
		--compiler=*)
dee5ee
			mb_compiler=${arg#*=}
dee5ee
			;;
dee5ee
		--toolchain=*)
dee5ee
			mb_toolchain=${arg#*=}
dee5ee
			;;
dee5ee
		--zealous)
dee5ee
			mb_agnostic=yes
dee5ee
			mb_zealous=
dee5ee
			;;
dee5ee
		--zealous=*)
dee5ee
			mb_zealous=${arg#*=}
dee5ee
			;;
dee5ee
		--ccenv=*)
dee5ee
			mb_ccenv=${arg#*=}
26e14f
			;;
26e14f
26e14f
		# dirs
26e14f
		--prefix=*)
26e14f
			mb_prefix_set=yes
26e14f
			mb_prefix=${arg#*=}
26e14f
			;;
26e14f
		--exec-prefix=*)
26e14f
			mb_exec_prefix_set=yes
26e14f
			mb_exec_prefix=${arg#*=}
26e14f
			;;
26e14f
		--bindir=*)
04cd68
			mb_bindir_set=yes
26e14f
			mb_bindir=${arg#*=}
26e14f
			;;
035302
		--sbindir=*)
035302
			mb_sbindir=${arg#*=}
035302
			;;
26e14f
		--libdir=*)
26e14f
			mb_libdir=${arg#*=}
26e14f
			;;
26e14f
		--includedir=*)
26e14f
			mb_includedir=${arg#*=}
26e14f
			;;
cdceaf
		--oldincludedir=*)
cdceaf
			mb_oldincludedir=${arg#*=}
cdceaf
			;;
26e14f
		--mandir=*)
26e14f
			mb_mandir=${arg#*=}
26e14f
			;;
26e14f
		--libexecdir=*)
26e14f
			mb_libexecdir=${arg#*=}
26e14f
			;;
26e14f
26e14f
cdceaf
		--sysconfdir=*)
cdceaf
			mb_sysconfdir=${arg#*=}
cdceaf
			;;
cdceaf
		--sharedstatedir=*)
cdceaf
			mb_sharedstatedir=${arg#*=}
cdceaf
			;;
cdceaf
		--localstatedir=*)
cdceaf
			mb_localstatedir=${arg#*=}
cdceaf
			;;
cdceaf
		--runstatedir=*)
cdceaf
			mb_runstatedir=${arg#*=}
cdceaf
			;;
cdceaf
		--datarootdir=*)
cdceaf
			mb_datarootdir=${arg#*=}
cdceaf
			;;
cdceaf
		--datadir=*)
cdceaf
			mb_datadir=${arg#*=}
cdceaf
			;;
cdceaf
		--infodir=*)
cdceaf
			mb_infodir=${arg#*=}
cdceaf
			;;
cdceaf
		--localedir=*)
cdceaf
			mb_localedir=${arg#*=}
cdceaf
			;;
cdceaf
		--htmldir=*)
cdceaf
			mb_htmldir=${arg#*=}
cdceaf
			;;
cdceaf
		--dvidir=*)
cdceaf
			mb_dvidir=${arg#*=}
cdceaf
			;;
cdceaf
		--pdfdir=*)
cdceaf
			mb_pdfdir=${arg#*=}
cdceaf
			;;
cdceaf
		--psdir=*)
cdceaf
			mb_psdir=${arg#*=}
cdceaf
			;;
cdceaf
cdceaf
26e14f
		# build
26e14f
		--build=*)
26e14f
			mb_build=${arg#*=}
26e14f
			;;
26e14f
		--host=*)
26e14f
			mb_host=${arg#*=}
26e14f
			;;
04eb52
		--cchost=*)
04eb52
			mb_cchost=${arg#*=}
04eb52
			;;
5079dc
		--cfghost=*)
5079dc
			mb_cfghost=${arg#*=}
5079dc
			;;
26e14f
		--target=*)
26e14f
			mb_target=${arg#*=}
26e14f
			;;
26e14f
		--arch=*)
26e14f
			mb_arch=${arg#*=}
26e14f
			;;
26e14f
		--sysroot=*)
26e14f
			mb_sysroot=${arg#*=}
26e14f
			;;
26e14f
		--shell=*)
26e14f
			mb_shell=${arg#*=}
26e14f
			;;
26e14f
		--debug)
dd7c0a
			mb_debug=yes
26e14f
			;;
26e14f
26e14f
		# config
26e14f
		--all-static)
dd7c0a
			mb_all_static=yes
26e14f
			;;
26e14f
		--all-shared)
dd7c0a
			mb_all_shared=yes
26e14f
			;;
26e14f
		--disable-frontend)
dd7c0a
			mb_disable_frontend=yes
26e14f
			;;
26e14f
		--disable-app)
dd7c0a
			mb_disable_frontend=yes
26e14f
			;;
26e14f
		--enable-frontend)
26e14f
			mb_disable_frontend='no'
26e14f
			;;
26e14f
		--enable-app)
26e14f
			mb_disable_frontend='no'
26e14f
			;;
26e14f
		--disable-static)
dd7c0a
			mb_disable_static=yes
26e14f
			;;
26e14f
		--disable-shared)
dd7c0a
			mb_disable_shared=yes
26e14f
			;;
26e14f
		--enable-static)
26e14f
			mb_disable_static='no'
26e14f
			;;
26e14f
		--enable-shared)
26e14f
			mb_disable_shared='no'
26e14f
			;;
26e14f
26e14f
		# convenience
26e14f
		--strict)
dd7c0a
			mb_ccstrict=yes
dd7c0a
			mb_ldstrict=yes
26e14f
			;;
26e14f
		--ccstrict)
dd7c0a
			mb_ccstrict=yes
26e14f
			;;
26e14f
		--ldstrict)
dd7c0a
			mb_ldstrict=yes
26e14f
			;;
26e14f
26e14f
		# project
26e14f
		--nickname=*)
26e14f
			mb_nickname=${arg#*=}
26e14f
			;;
95c5c7
		--program-prefix=*)
95c5c7
			mb_program_prefix=${arg#*=}
95c5c7
			;;
26e14f
		--avoid-version)
dd7c0a
			mb_avoid_version=yes
26e14f
			;;
26e14f
		--source-dir=*)
26e14f
			mb_source_dir=${arg#*=}
26e14f
			;;
26e14f
750435
		# pkgconfig
750435
		--pkgname=*)
750435
			mb_pkgname=${arg#*=}
750435
			;;
750435
750435
		--pkgdesc=*)
750435
			mb_pkgdesc=${arg#*=}
750435
			;;
750435
750435
		--pkgusrc=*)
750435
			mb_pkgusrc=${arg#*=}
750435
			;;
750435
750435
		--pkgrepo=*)
750435
			mb_pkgrepo=${arg#*=}
750435
			;;
750435
750435
		--pkgpsrc=*)
750435
			mb_pkgpsrc=${arg#*=}
750435
			;;
750435
750435
		--pkgdurl=*)
750435
			mb_pkgdurl=${arg#*=}
750435
			;;
750435
750435
		--pkgdefs=*)
750435
			mb_pkgdefs=${arg#*=}
750435
			;;
750435
750435
		--pkglibs=*)
750435
			mb_pkglibs=${arg#*=}
750435
			;;
750435
f7a506
		# compatibility
f7a506
		--enable-dependency-tracking)
f7a506
			;;
f7a506
		--disable-dependency-tracking)
f7a506
			;;
f7a506
26e14f
		*)
dd7c0a
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
062152
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
062152
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
062152
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
062152
				mb_custom_cfgdefs_space=' '
f7cf5c
			else
f7cf5c
				error_msg ${arg#}: "unsupported config argument."
f7cf5c
				exit 2
f7cf5c
			fi
26e14f
			;;
26e14f
	esac
26e14f
done
26e14f
26e14f
26e14f
26e14f
# three: validation
26e14f
verify_source_directory
26e14f
95c5c7
if ! [ -z "$mb_program_prefix" ]; then
95c5c7
	error_msg "--program-prefix is not yet fully support (must be null)."
95c5c7
fi
95c5c7
26e14f
26e14f
26e14f
# four: defaults
26e14f
common_defaults
26e14f
26e14f
26e14f
# five: config
26e14f
config_flags
26e14f
config_copy
dee5ee
config_ccenv
f7cf5c
config_custom
f7cf5c
config_cfghost
26e14f
config_support
26e14f
config_host
26e14f
config_status
26e14f
26e14f
26e14f
# all done
99b9ed
config_success