Blame configure

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