09157951638 / compilers / bcparser

Forked from compilers/bcparser a year ago
Clone

Blame configure

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