Blame configure

26e14f
#!/bin/sh
26e14f
# we are no longer lazy.
26e14f
26e14f
# this script respects both CFLAGS and CFLAGS_CMDLINE,
26e14f
# as well as both LDFLAGS and LDFLAGS_CMDLINE, however
26e14f
# the latter variable of each pair should be preferred.
26e14f
26e14f
usage()
26e14f
{
26e14f
	cat "$mb_project_dir"/config.usage
26e14f
	exit $?
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
{
26e14f
	mb_project_dir=$(cd `dirname $0` ; pwd)
26e14f
	mb_pwd=`pwd`
26e14f
26e14f
	if [ -z "$mb_config" ]; then
26e14f
		. $mb_project_dir/config.project || exit 2
26e14f
	else
26e14f
		. "$mb_config" || exit 2
26e14f
	fi
26e14f
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
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_native_cc=$NATIVE_CC
26e14f
	mb_native_os=$NATIVE_OS
26e14f
	mb_native_os_bits=$NATIVE_OS_BITS
26e14f
	mb_native_os_underscore=$NATIVE_OS_UNDERSCORE
26e14f
26e14f
	mb_user_cc=$CC
26e14f
	mb_user_cpp=$CPP
26e14f
	mb_user_cxx=$CXX
26e14f
}
26e14f
26e14f
26e14f
verify_build_directory()
26e14f
{
26e14f
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
26e14f
		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."
26e14f
			exit 2
26e14f
		else
26e14f
			mb_project_dir='.'
26e14f
		fi
26e14f
	fi
26e14f
}
26e14f
26e14f
26e14f
verify_source_directory()
26e14f
{
26e14f
	if [ -z "$mb_source_dir" ]; then
26e14f
		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."
26e14f
			exit 2
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
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
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
26e14f
	if [ "$mb_debug" = yes ]; then
26e14f
		if [ -z "$mb_cflags_debug" ]; then
26e14f
			mb_cflags_debug='-g3 -O0'
26e14f
		fi
26e14f
	fi
26e14f
26e14f
	# compiler
26e14f
	if [ -n "$mb_compiler" ]; then
26e14f
		if [ -z "$mb_native_cc" ]; then
26e14f
			mb_native_cc=$mb_compiler
26e14f
		fi
26e14f
	fi
26e14f
26e14f
	# toolchain
26e14f
	if [ -z "$mb_toolchain" ]; then
26e14f
		mb_toolchain='binutils'
26e14f
	fi
26e14f
26e14f
	# fallback host recipe
26e14f
	if [ -n "$mb_host" ]; then
26e14f
		if ! [ -f $mb_project_dir/sysinfo/host/$mb_host.mk ]; then
26e14f
			if [ -z "$mb_cross_compile" ]; then
26e14f
				mb_cross_compile=$mb_host-
26e14f
			fi
26e14f
26e14f
			mb_host='any-host';
26e14f
		fi
26e14f
	fi
26e14f
26e14f
	# fallback compiler recipe
26e14f
	if [ -n "$mb_compiler" ]; then
26e14f
		if ! [ -f $mb_project_dir/sysinfo/compiler/$mb_compiler.mk ]; then
26e14f
			mb_compiler='any-compiler'
26e14f
		fi
26e14f
	fi
26e14f
}
26e14f
26e14f
26e14f
native_defaults()
26e14f
{
26e14f
	# CC (when set, must be valid)
26e14f
	if [ -n "$CC" ]; then
26e14f
		$CC -dM -E - < /dev/null > /dev/null || exit 2
26e14f
	fi
26e14f
26e14f
	# compiler
26e14f
	[ -z "$mb_native_cc" ] && mb_native_cc=$CC
26e14f
	[ -z "$mb_native_cc" ] && mb_native_cc='cc'
26e14f
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
26e14f
26e14f
	[ -z "$mb_native_cc" ] && mb_native_cc='gcc'
26e14f
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
26e14f
26e14f
	[ -z "$mb_native_cc" ] && mb_native_cc='clang'
26e14f
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
26e14f
26e14f
	[ -z "$mb_native_cc" ] && mb_native_cc='cparser'
26e14f
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
26e14f
26e14f
	if [ -z "$mb_native_cc" ]; then
26e14f
		echo "configure: info: could not find a working native compiler."
26e14f
		mb_native_cc='false'
26e14f
	fi
26e14f
26e14f
	if [ -z "$mb_compiler" ]; then
26e14f
		$mb_native_cc -dM -E - < /dev/null | grep -q '__clang__' && mb_compiler='clang'
26e14f
	fi
26e14f
26e14f
	if [ -z "$mb_compiler" ]; then
26e14f
		$mb_native_cc -dM -E - < /dev/null | grep -q '__GCC' && mb_compiler='gcc'
26e14f
	fi
26e14f
26e14f
	if [ -z "$mb_compiler" ]; then
26e14f
		$mb_native_cc -dM -E - < /dev/null | grep -q "^gcc" && mb_compiler='gcc'
26e14f
	fi
26e14f
26e14f
	if [ -z "$mb_compiler" ]; then
26e14f
		$mb_native_cc -dM -E - < /dev/null | grep -q '__CPARSER__' && mb_compiler='cparser'
26e14f
	fi
26e14f
26e14f
	if [ -z "$mb_compiler" ]; then
26e14f
		echo "configure: info: could not identify the native compiler."
26e14f
		mb_compiler='any-compiler'
26e14f
	fi
26e14f
26e14f
26e14f
	# host
26e14f
	if [ -z "$mb_host" ]; then
26e14f
		mb_host='native'
26e14f
	fi
26e14f
26e14f
26e14f
	# target
26e14f
	if [ -z "$mb_target" ]; then
26e14f
		mb_target='native'
26e14f
	fi
26e14f
26e14f
26e14f
	# os
26e14f
	if [ -z "$mb_native_os" ]; then
26e14f
		mb_native_os=`uname | tr '[:upper:]' '[:lower:]'`
26e14f
	fi
26e14f
26e14f
	mb_native_os_sizeof_pointer=`$mb_native_cc -dM -E - < /dev/null \
26e14f
			| awk '$2 == "__SIZEOF_POINTER__" { print $3 }'`
26e14f
26e14f
	mb_native_os_bits=$((8 * ${mb_native_os_sizeof_pointer:-0}))
26e14f
26e14f
	if [ $mb_native_os_bits = 32 ]; then
26e14f
		mb_native_os_underscore='_'
26e14f
	else
26e14f
		mb_native_os_underscore=''
26e14f
	fi
26e14f
26e14f
	if [ -z "$mb_native_os_sizeof_pointer" ]; then
26e14f
		warning_msg "config error: could not determine size of pointer on native system."
26e14f
	fi
26e14f
26e14f
	# grumpily support crooked uname output
26e14f
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
26e14f
		mb_native_os=`echo $mb_native_os | cut -d'_' -f1`
26e14f
	fi
26e14f
26e14f
	# fallback os recipe
26e14f
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
26e14f
		mb_native_os='any-os';
26e14f
	fi
26e14f
}
26e14f
26e14f
26e14f
cross_defaults()
26e14f
{
26e14f
	if [ -z "$mb_cross_compile" ] && [ "$mb_host" != native ]; then
26e14f
		mb_cross_compile=$mb_host'-'
26e14f
	fi
26e14f
}
26e14f
26e14f
26e14f
config_flags()
26e14f
{
26e14f
	mb_ldflags_tmp=" $mb_ldflags "
26e14f
	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
26e14f
	if [ "$mb_ccstrict" = 'yes' ]; then
26e14f
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
26e14f
	fi
26e14f
26e14f
	# ldstrict
26e14f
	if [ "$mb_ldstrict" = 'yes' ]; then
26e14f
		mb_ldflags_strict='-Wl,--no-undefined'
26e14f
	fi
26e14f
}
26e14f
26e14f
26e14f
config_copy()
26e14f
{
26e14f
	sed 		-e 's^@package@^'"$mb_package"'^g' 				\
26e14f
			-e 's^@nickname@^'"$mb_nickname"'^g'				\
26e14f
			-e 's^@project_dir@^'"$mb_project_dir"'^g'			\
26e14f
			-e 's^@source_dir@^'"$mb_source_dir"'^g'			\
26e14f
			-e 's^@git_reference_index@^'"$mb_git_reference_index"'^g'	\
26e14f
			-e 's^@custom_install_headers@^'"$mb_custom_install_headers"'^g' \
26e14f
			-e 's^@avoid_version@^'"$mb_avoid_version"'^g'			\
26e14f
											\
26e14f
			-e 's^@build@^'"$mb_build"'^g'					\
26e14f
			-e 's^@host@^'"$mb_host"'^g'					\
26e14f
			-e 's^@target@^'"$mb_target"'^g'				\
26e14f
			-e 's^@arch@^'"$mb_arch"'^g'					\
26e14f
			-e 's^@compiler@^'"$mb_compiler"'^g'				\
26e14f
			-e 's^@toolchain@^'"$mb_toolchain"'^g'				\
26e14f
			-e 's^@sysroot@^'"$mb_sysroot"'^g'				\
26e14f
			-e 's^@cross_compile@^'"$mb_cross_compile"'^g'			\
26e14f
			-e 's^@shell@^'"$mb_shell"'^g'					\
26e14f
											\
26e14f
			-e 's^@cflags@^'"$mb_cflags"'^g'				\
26e14f
			-e 's^@cflags_debug@^'"$mb_cflags_debug"'^g'			\
26e14f
			-e 's^@cflags_common@^'"$mb_cflags_common"'^g'			\
26e14f
			-e 's^@cflags_cmdline@^'"$mb_cflags $mb_cflags_cmdline"'^g'	\
26e14f
			-e 's^@cflags_config@^'"$mb_cflags_config"'^g'			\
26e14f
			-e 's^@cflags_sysroot@^'"$mb_cflags_sysroot"'^g'		\
26e14f
			-e 's^@cflags_os@^'"$mb_cflags_os"'^g'				\
26e14f
			-e 's^@cflags_site@^'"$mb_cflags_site"'^g'			\
26e14f
			-e 's^@cflags_path@^'"$mb_cflags_path"'^g'			\
26e14f
			-e 's^@cflags_strict@^'"$mb_cflags_strict"'^g'			\
26e14f
			-e 's^@cflags_util@^'"$mb_cflags_util"'^g'			\
26e14f
			-e 's^@cflags_last@^'"$mb_cflags_last"'^g'			\
26e14f
			-e 's^@cflags_once@^'"$mb_cflags_once"'^g'			\
26e14f
											\
26e14f
			-e 's^@ldflags@^'"$mb_ldflags"'^g'				\
26e14f
			-e 's^@ldflags_debug@^'"$mb_ldflags_debug"'^g'			\
26e14f
			-e 's^@ldflags_common@^'"$mb_ldflags_common"'^g'		\
26e14f
			-e 's^@ldflags_cmdline@^'"$mb_ldflags $mb_ldflags_cmdline"'^g'	\
26e14f
			-e 's^@ldflags_config@^'"$mb_ldflags_config"'^g'		\
26e14f
			-e 's^@ldflags_sysroot@^'"$mb_ldflags_sysroot"'^g'		\
26e14f
			-e 's^@ldflags_path@^'"$mb_ldflags_path"'^g'			\
26e14f
			-e 's^@ldflags_strict@^'"$mb_ldflags_strict"'^g'		\
26e14f
			-e 's^@ldflags_util@^'"$mb_ldflags_util"'^g'			\
26e14f
			-e 's^@ldflags_last@^'"$mb_ldflags_last"'^g'			\
26e14f
			-e 's^@ldflags_once@^'"$mb_ldflags_once"'^g'			\
26e14f
											\
26e14f
			-e 's^@pe_subsystem@^'"$mb_pe_subsystem"'^g'			\
26e14f
			-e 's^@pe_image\_base@^'"$mb_pe_image_base"'^g'			\
26e14f
			-e 's^@pe_config\_defs@^'"$mb_pe_config_defs"'^g'		\
26e14f
											\
26e14f
			-e 's^@elf_eh\_frame@^'"$mb_elf_eh_frame"'^g'			\
26e14f
			-e 's^@elf_hash\_style@^'"$mb_elf_hash_style"'^g'		\
26e14f
			-e 's^@elf_config\_defs@^'"$mb_elf_config_defs"'^g'		\
26e14f
											\
26e14f
			-e 's^@prefix@^'"$mb_prefix"'^g'				\
26e14f
			-e 's^@exec_prefix@^'"$mb_exec_prefix"'^g'			\
26e14f
			-e 's^@bindir@^'"$mb_bindir"'^g'				\
035302
			-e 's^@sbindir@^'"$mb_sbindir"'^g'				\
26e14f
			-e 's^@libdir@^'"$mb_libdir"'^g'				\
26e14f
			-e 's^@includedir@^'"$mb_includedir"'^g'			\
cdceaf
			-e 's^@oldincludedir@^'"$mb_oldincludedir"'^g'			\
26e14f
			-e 's^@mandir@^'"$mb_mandir"'^g'				\
26e14f
			-e 's^@docdir@^'"$mb_docdir"'^g'				\
26e14f
			-e 's^@libexecdir@^'"$mb_libexecdir"'^g'			\
26e14f
											\
cdceaf
			-e 's^@sysconfdir@^'"$mb_sysconfdir"'^g'			\
cdceaf
			-e 's^@sharedstatedir@^'"$mb_sharedstatedir"'^g'		\
cdceaf
			-e 's^@localstatedir@^'"$mb_localstatedir"'^g'			\
cdceaf
			-e 's^@runstatedir@^'"$mb_runstatedir"'^g'			\
cdceaf
			-e 's^@datarootdir@^'"$mb_datarootdir"'^g'			\
cdceaf
			-e 's^@datadir@^'"$mb_datadir"'^g'				\
cdceaf
			-e 's^@infodir@^'"$mb_infodir"'^g'				\
cdceaf
			-e 's^@localedir@^'"$mb_localedir"'^g'				\
cdceaf
			-e 's^@htmldir@^'"$mb_htmldir"'^g'				\
cdceaf
			-e 's^@dvidir@^'"$mb_dvidir"'^g'				\
cdceaf
			-e 's^@pdfdir@^'"$mb_pdfdir"'^g'				\
cdceaf
			-e 's^@psdir@^'"$mb_psdir"'^g'					\
cdceaf
											\
26e14f
			-e 's^@native_cc@^'"$mb_native_cc"'^g'				\
26e14f
			-e 's^@native_os@^'"$mb_native_os"'^g'				\
26e14f
			-e 's^@native_os_bits@^'"$mb_native_os_bits"'^g'		\
26e14f
			-e 's^@native_os_underscore@^'"$mb_native_os_underscore"'^g'	\
26e14f
											\
26e14f
			-e 's^@user_cc@^'"$mb_user_cc"'^g'				\
26e14f
			-e 's^@user_cpp@^'"$mb_user_cpp"'^g'				\
26e14f
			-e 's^@user_cxx@^'"$mb_user_cxx"'^g'				\
26e14f
											\
26e14f
			-e 's^@all_static@^'"$mb_all_static"'^g'			\
26e14f
			-e 's^@all_shared@^'"$mb_all_shared"'^g'			\
26e14f
			-e 's^@disable_frontend@^'"$mb_disable_frontend"'^g'		\
26e14f
			-e 's^@disable_static@^'"$mb_disable_static"'^g'		\
26e14f
			-e 's^@disable_shared@^'"$mb_disable_shared"'^g'		\
04eb52
		$mb_project_dir/Makefile.in > $mb_pwd/Makefile.tmp || exit 2
04eb52
04eb52
	if [ -z "$mb_cchost" ]; then
04eb52
		if [ "$mb_host" = 'native' ]; then
04eb52
			mb_cchost=`make -s -f $mb_pwd/Makefile.tmp cchost`
04eb52
		else
04eb52
			mb_cchost=$mb_host
04eb52
		fi
04eb52
	fi
04eb52
04eb52
	sed -e 's^@cchost@^'"$mb_cchost"'^g' $mb_pwd/Makefile.tmp \
04eb52
	  > $mb_pwd/Makefile.host                  || exit 2
04eb52
04eb52
	rm  $mb_pwd/Makefile.tmp                   || exit 2
04eb52
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile || exit 2
26e14f
}
26e14f
26e14f
26e14f
config_support()
26e14f
{
26e14f
	[ "$mb_disable_shared" = 'yes' ] && return 0
26e14f
26e14f
	mbt_cc=`make .display-cc`
26e14f
	mbt_cflags=`make .display-cflags`
26e14f
	mbt_source='int foo(int x){return ++x;}'
26e14f
	mbt_result='no'
26e14f
26e14f
	rm -f a.out
26e14f
	echo "$mbt_source" | "$mbt_cc" -shared -o a.out -xc -
26e14f
	stat a.out >/dev/null 2>&1 && mbt_result='yes'
26e14f
	rm -f a.out
26e14f
26e14f
	if [ "$mbt_result" = 'no' ]; then
26e14f
		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
26e14f
# one: init
26e14f
init_vars
26e14f
verify_build_directory
26e14f
26e14f
26e14f
# two: args
26e14f
for arg ; do
26e14f
	case "$arg" in
26e14f
		--help)	usage
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
			;;
26e14f
		--target=*)
26e14f
			mb_target=${arg#*=}
26e14f
			;;
26e14f
		--arch=*)
26e14f
			mb_arch=${arg#*=}
26e14f
			;;
26e14f
		--compiler=*)
26e14f
			mb_compiler=${arg#*=}
26e14f
			;;
26e14f
		--toolchain=*)
26e14f
			mb_toolchain=${arg#*=}
26e14f
			;;
26e14f
		--sysroot=*)
26e14f
			mb_sysroot=${arg#*=}
26e14f
			;;
26e14f
		--cross-compile=*)
26e14f
			mb_cross_compile=${arg#*=}
26e14f
			;;
26e14f
		--shell=*)
26e14f
			mb_shell=${arg#*=}
26e14f
			;;
26e14f
		--debug)
26e14f
			mb_debug='yes'
26e14f
			;;
26e14f
26e14f
		# config
26e14f
		--all-static)
26e14f
			mb_all_static='yes'
26e14f
			;;
26e14f
		--all-shared)
26e14f
			mb_all_shared='yes'
26e14f
			;;
26e14f
		--disable-frontend)
26e14f
			mb_disable_frontend='yes'
26e14f
			;;
26e14f
		--disable-app)
26e14f
			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)
26e14f
			mb_disable_static='yes'
26e14f
			;;
26e14f
		--disable-shared)
26e14f
			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)
26e14f
			mb_ccstrict='yes'
26e14f
			mb_ldstrict='yes'
26e14f
			;;
26e14f
		--ccstrict)
26e14f
			mb_ccstrict='yes'
26e14f
			;;
26e14f
		--ldstrict)
26e14f
			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)
26e14f
			mb_avoid_version='yes'
26e14f
			;;
26e14f
		--source-dir=*)
26e14f
			mb_source_dir=${arg#*=}
26e14f
			;;
26e14f
f7a506
		# compatibility
f7a506
		--enable-dependency-tracking)
f7a506
			;;
f7a506
		--disable-dependency-tracking)
f7a506
			;;
f7a506
26e14f
		*)
26e14f
			error_msg ${arg#}: "unsupported config argument."
26e14f
			exit 2
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
native_defaults
26e14f
cross_defaults
26e14f
26e14f
26e14f
26e14f
# five: config
26e14f
config_flags
26e14f
config_copy
26e14f
config_support
26e14f
config_host
26e14f
config_status
26e14f
26e14f
26e14f
# all done
26e14f
exit 0