Blame configure

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