Blame configure

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