Blame configure

8be377
#!/bin/sh
8be377
# we are no longer lazy.
8be377
8be377
# this script respects both CFLAGS and CFLAGS_CMDLINE,
8be377
# as well as both LDFLAGS and LDFLAGS_CMDLINE, however
8be377
# the latter variable of each pair should be preferred.
8be377
8be377
usage()
8be377
{
8be377
	cat "$mb_project_dir"/config.usage
8be377
	exit $?
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
{
8be377
	mb_project_dir=$(cd `dirname $0` ; pwd)
8be377
	mb_pwd=`pwd`
8be377
8be377
	if [ -z "$mb_config" ]; then
8be377
		. $mb_project_dir/config.project || exit 2
8be377
	else
8be377
		. "$mb_config" || exit 2
8be377
	fi
8be377
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
8be377
	mb_mandir=$MANDIR
8be377
	mb_docdir=$DOCDIR
8be377
	mb_libexecdir=$LIBEXECDIR
8be377
8be377
8be377
	# build
8be377
	mb_build=$BUILD
8be377
	mb_host=$HOST
8be377
	mb_target=$TARGET
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
	mb_pe_config_defs=$PE_CONFIG_DEFS
8be377
8be377
	mb_elf_eh_frame=$ELF_EH_FRAME
8be377
	mb_elf_hash_style=$ELF_HASH_STYLE
8be377
	mb_elf_config_defs=$ELF_CONFIG_DEFS
8be377
8be377
	# overrides
8be377
	mb_native_cc=$NATIVE_CC
8be377
	mb_native_os=$NATIVE_OS
8be377
	mb_native_os_bits=$NATIVE_OS_BITS
8be377
	mb_native_os_underscore=$NATIVE_OS_UNDERSCORE
8be377
8be377
	mb_user_cc=$CC
8be377
	mb_user_cpp=$CPP
8be377
	mb_user_cxx=$CXX
8be377
}
8be377
8be377
8be377
verify_build_directory()
8be377
{
8be377
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
8be377
		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."
8be377
			exit 2
8be377
		else
8be377
			mb_project_dir='.'
8be377
		fi
8be377
	fi
8be377
}
8be377
8be377
8be377
verify_source_directory()
8be377
{
8be377
	if [ -z "$mb_source_dir" ]; then
8be377
		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."
8be377
			exit 2
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
8be377
	[ -z "$mb_nickname" ] 		&& mb_nickname=$mb_package
8be377
	[ -z "$mb_source_dir" ] 	&& mb_source_dir=$mb_project_dir
8be377
	[ -z "$mb_avoid_version" ] 	&& mb_avoid_version='no'
8be377
8be377
	# dirs
8be377
	[ -z "$mb_prefix" ] 		&& [ -z "$mb_prefix_set" ] \
8be377
					&& mb_prefix='/usr/local'
8be377
8be377
	[ -z "$mb_exec_prefix" ] 	&& [ -z "$mb_exec_prefix_set" ]	\
8be377
					&& mb_exec_prefix=$mb_prefix
8be377
8be377
	[ -z "$mb_bindir" ] 		&& mb_bindir=$mb_exec_prefix/bin
2623f6
	[ -z "$mb_sbindir" ] 		&& mb_sbindir=$mb_exec_prefix/sbin
8be377
	[ -z "$mb_libdir" ] 		&& mb_libdir=$mb_exec_prefix/lib
8be377
	[ -z "$mb_includedir" ]		&& mb_includedir=$mb_prefix/include
8be377
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
8be377
	[ -z "$mb_mandir" ] 		&& mb_mandir=$mb_datarootdir/man
8be377
	[ -z "$mb_docdir" ] 		&& mb_docdir=$mb_datarootdir/doc
8be377
	[ -z "$mb_libexecdir" ]		&& mb_libexecdir=$mb_exec_prefix/libexec
8be377
8be377
	# build
8be377
	[ -z "$mb_build" ] 		&& mb_build=$mb_default_build
8be377
	[ -z "$mb_host" ] 		&& mb_host=$mb_default_host
8be377
	[ -z "$mb_target" ] 		&& mb_target=$mb_default_target
8be377
	[ -z "$mb_arch" ] 		&& mb_arch=$mb_default_arch
8be377
	[ -z "$mb_compiler" ] 		&& mb_compiler=$mb_default_compiler
8be377
	[ -z "$mb_toolchain" ] 		&& mb_toolchain=$mb_default_toolchain
8be377
	[ -z "$mb_sysroot" ] 		&& mb_sysroot=$mb_default_sysroot
8be377
	[ -z "$mb_cross_compile" ] 	&& mb_cross_compile=$mb_default_cross_compile
8be377
	[ -z "$mb_shell" ] 		&& mb_shell=$mb_default_shell
8be377
8be377
	# switches
8be377
	[ -z "$mb_cflags_debug" ]	&& mb_cflags_debug=$mb_default_cflags_debug
8be377
	[ -z "$mb_cflags_common" ]	&& mb_cflags_common=$mb_default_cflags_common
8be377
	[ -z "$mb_cflags_cmdline" ]	&& mb_cflags_cmdline=$mb_default_cflags_cmdline
8be377
	[ -z "$mb_cflags_config" ]	&& mb_cflags_config=$mb_default_cflags_config
8be377
	[ -z "$mb_cflags_sysroot" ]	&& mb_cflags_sysroot=$mb_default_cflags_sysroot
8be377
	[ -z "$mb_cflags_os" ]		&& mb_cflags_os=$mb_default_cflags_os
8be377
	[ -z "$mb_cflags_site" ]	&& mb_cflags_site=$mb_default_cflags_site
8be377
	[ -z "$mb_cflags_path" ]	&& mb_cflags_path=$mb_default_cflags_path
8be377
	[ -z "$mb_cflags_strict" ]	&& mb_cflags_strict=$mb_default_cflags_strict
8be377
	[ -z "$mb_cflags_util" ]	&& mb_cflags_util=$mb_default_cflags_util
8be377
	[ -z "$mb_cflags_last" ]	&& mb_cflags_last=$mb_default_cflags_last
8be377
	[ -z "$mb_cflags_once" ]	&& mb_cflags_once=$mb_default_cflags_once
8be377
8be377
	[ -z "$mb_ldflags_debug" ]	&& mb_ldflags_debug=$mb_default_ldflags_debug
8be377
	[ -z "$mb_ldflags_common" ]	&& mb_ldflags_common=$mb_default_ldflags_common
8be377
	[ -z "$mb_ldflags_cmdline" ]	&& mb_ldflags_cmdline=$mb_default_ldflags_cmdline
8be377
	[ -z "$mb_ldflags_config" ]	&& mb_ldflags_config=$mb_default_ldflags_config
8be377
	[ -z "$mb_ldflags_sysroot" ]	&& mb_ldflags_sysroot=$mb_default_ldflags_sysroot
8be377
	[ -z "$mb_ldflags_path" ]	&& mb_ldflags_path=$mb_default_ldflags_path
8be377
	[ -z "$mb_ldflags_strict" ]	&& mb_ldflags_strict=$mb_default_ldflags_strict
8be377
	[ -z "$mb_ldflags_util" ]	&& mb_ldflags_util=$mb_default_ldflags_util
8be377
	[ -z "$mb_ldflags_last" ]	&& mb_ldflags_last=$mb_default_ldflags_last
8be377
	[ -z "$mb_ldflags_once" ]	&& mb_ldflags_once=$mb_default_ldflags_once
8be377
8be377
	[ -z "$mb_pe_subsystem" ]	&& mb_pe_subsystem=$mb_default_pe_subsystem
8be377
	[ -z "$mb_pe_image_base" ]	&& mb_pe_image_base=$mb_default_pe_image_base
8be377
	[ -z "$mb_pe_config_defs" ]	&& mb_pe_config_defs=$mb_default_pe_config_defs
8be377
8be377
	[ -z "$mb_elf_eh_frame" ]	&& mb_elf_eh_frame=$mb_default_elf_eh_frame
8be377
	[ -z "$mb_elf_hash_style" ]	&& mb_elf_hash_style=$mb_default_elf_hash_style
8be377
	[ -z "$mb_elf_config_defs" ]	&& mb_elf_config_defs=$mb_default_elf_config_defs
8be377
8be377
	# config
8be377
	[ -z "$mb_all_static" ]		&& mb_all_static='no'
8be377
	[ -z "$mb_all_shared" ]		&& mb_all_shared='no'
8be377
	[ -z "$mb_disable_frontend" ]	&& mb_disable_frontend='no'
8be377
	[ -z "$mb_disable_static" ]	&& mb_disable_static='no'
8be377
	[ -z "$mb_disable_shared" ]	&& mb_disable_shared='no'
8be377
8be377
	# host/target
8be377
	[ -z "$mb_host" ] 		&& mb_host=$mb_target
8be377
	[ -z "$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
8be377
	if [ "$mb_debug" = yes ]; then
8be377
		if [ -z "$mb_cflags_debug" ]; then
8be377
			mb_cflags_debug='-g3 -O0'
8be377
		fi
8be377
	fi
8be377
8be377
	# compiler
8be377
	if [ -n "$mb_compiler" ]; then
8be377
		if [ -z "$mb_native_cc" ]; then
8be377
			mb_native_cc=$mb_compiler
8be377
		fi
8be377
	fi
8be377
8be377
	# toolchain
8be377
	if [ -z "$mb_toolchain" ]; then
8be377
		mb_toolchain='binutils'
8be377
	fi
8be377
8be377
	# fallback host recipe
8be377
	if [ -n "$mb_host" ]; then
8be377
		if ! [ -f $mb_project_dir/sysinfo/host/$mb_host.mk ]; then
8be377
			if [ -z "$mb_cross_compile" ]; then
8be377
				mb_cross_compile=$mb_host-
8be377
			fi
8be377
8be377
			mb_host='any-host';
8be377
		fi
8be377
	fi
8be377
8be377
	# fallback compiler recipe
8be377
	if [ -n "$mb_compiler" ]; then
8be377
		if ! [ -f $mb_project_dir/sysinfo/compiler/$mb_compiler.mk ]; then
8be377
			mb_compiler='any-compiler'
8be377
		fi
8be377
	fi
8be377
}
8be377
8be377
8be377
native_defaults()
8be377
{
8be377
	# CC (when set, must be valid)
8be377
	if [ -n "$CC" ]; then
8be377
		$CC -dM -E - < /dev/null > /dev/null || exit 2
8be377
	fi
8be377
8be377
	# compiler
8be377
	[ -z "$mb_native_cc" ] && mb_native_cc=$CC
8be377
	[ -z "$mb_native_cc" ] && mb_native_cc='cc'
8be377
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
8be377
8be377
	[ -z "$mb_native_cc" ] && mb_native_cc='gcc'
8be377
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
8be377
8be377
	[ -z "$mb_native_cc" ] && mb_native_cc='clang'
8be377
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
8be377
8be377
	[ -z "$mb_native_cc" ] && mb_native_cc='cparser'
8be377
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
8be377
8be377
	if [ -z "$mb_native_cc" ]; then
8be377
		echo "configure: info: could not find a working native compiler."
8be377
		mb_native_cc='false'
8be377
	fi
8be377
8be377
	if [ -z "$mb_compiler" ]; then
8be377
		$mb_native_cc -dM -E - < /dev/null | grep -q '__clang__' && mb_compiler='clang'
8be377
	fi
8be377
8be377
	if [ -z "$mb_compiler" ]; then
8be377
		$mb_native_cc -dM -E - < /dev/null | grep -q '__GCC' && mb_compiler='gcc'
8be377
	fi
8be377
8be377
	if [ -z "$mb_compiler" ]; then
8be377
		$mb_native_cc -dM -E - < /dev/null | grep -q "^gcc" && mb_compiler='gcc'
8be377
	fi
8be377
8be377
	if [ -z "$mb_compiler" ]; then
8be377
		$mb_native_cc -dM -E - < /dev/null | grep -q '__CPARSER__' && mb_compiler='cparser'
8be377
	fi
8be377
8be377
	if [ -z "$mb_compiler" ]; then
8be377
		echo "configure: info: could not identify the native compiler."
8be377
		mb_compiler='any-compiler'
8be377
	fi
8be377
8be377
8be377
	# host
8be377
	if [ -z "$mb_host" ]; then
8be377
		mb_host='native'
8be377
	fi
8be377
8be377
8be377
	# target
8be377
	if [ -z "$mb_target" ]; then
8be377
		mb_target='native'
8be377
	fi
8be377
8be377
8be377
	# os
e8c4ea
	if [ -z "$mb_native_os" ]; then
e8c4ea
		mb_native_os=`uname | tr '[:upper:]' '[:lower:]'`
e8c4ea
	fi
8be377
8be377
	mb_native_os_sizeof_pointer=`$mb_native_cc -dM -E - < /dev/null \
8be377
			| awk '$2 == "__SIZEOF_POINTER__" { print $3 }'`
8be377
8be377
	mb_native_os_bits=$((8 * ${mb_native_os_sizeof_pointer:-0}))
8be377
8be377
	if [ $mb_native_os_bits = 32 ]; then
8be377
		mb_native_os_underscore='_'
8be377
	else
8be377
		mb_native_os_underscore=''
8be377
	fi
8be377
8be377
	if [ -z "$mb_native_os_sizeof_pointer" ]; then
8be377
		warning_msg "config error: could not determine size of pointer on native system."
8be377
	fi
8be377
ada89b
	# grumpily support crooked uname output
ada89b
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
ada89b
		mb_native_os=`echo $mb_native_os | cut -d'_' -f1`
ada89b
	fi
ada89b
8be377
	# fallback os recipe
8be377
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
8be377
		mb_native_os='any-os';
8be377
	fi
8be377
}
8be377
8be377
8be377
cross_defaults()
8be377
{
8be377
	if [ -z "$mb_cross_compile" ] && [ "$mb_host" != native ]; then
8be377
		mb_cross_compile=$mb_host'-'
8be377
	fi
8be377
}
8be377
8be377
8be377
config_flags()
8be377
{
8be377
	mb_ldflags_tmp=" $mb_ldflags "
8be377
	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
8be377
	if [ "$mb_ccstrict" = 'yes' ]; then
8be377
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
8be377
	fi
8be377
8be377
	# ldstrict
8be377
	if [ "$mb_ldstrict" = 'yes' ]; then
8be377
		mb_ldflags_strict='-Wl,--no-undefined'
8be377
	fi
8be377
}
8be377
8be377
8be377
config_copy()
8be377
{
8be377
	sed 		-e 's^@package@^'"$mb_package"'^g' 				\
8be377
			-e 's^@nickname@^'"$mb_nickname"'^g'				\
8be377
			-e 's^@project_dir@^'"$mb_project_dir"'^g'			\
8be377
			-e 's^@source_dir@^'"$mb_source_dir"'^g'			\
8be377
			-e 's^@git_reference_index@^'"$mb_git_reference_index"'^g'	\
8be377
			-e 's^@custom_install_headers@^'"$mb_custom_install_headers"'^g' \
8be377
			-e 's^@avoid_version@^'"$mb_avoid_version"'^g'			\
8be377
											\
8be377
			-e 's^@build@^'"$mb_build"'^g'					\
8be377
			-e 's^@host@^'"$mb_host"'^g'					\
8be377
			-e 's^@target@^'"$mb_target"'^g'				\
8be377
			-e 's^@arch@^'"$mb_arch"'^g'					\
8be377
			-e 's^@compiler@^'"$mb_compiler"'^g'				\
8be377
			-e 's^@toolchain@^'"$mb_toolchain"'^g'				\
8be377
			-e 's^@sysroot@^'"$mb_sysroot"'^g'				\
8be377
			-e 's^@cross_compile@^'"$mb_cross_compile"'^g'			\
8be377
			-e 's^@shell@^'"$mb_shell"'^g'					\
8be377
											\
8be377
			-e 's^@cflags@^'"$mb_cflags"'^g'				\
8be377
			-e 's^@cflags_debug@^'"$mb_cflags_debug"'^g'			\
8be377
			-e 's^@cflags_common@^'"$mb_cflags_common"'^g'			\
8be377
			-e 's^@cflags_cmdline@^'"$mb_cflags $mb_cflags_cmdline"'^g'	\
8be377
			-e 's^@cflags_config@^'"$mb_cflags_config"'^g'			\
8be377
			-e 's^@cflags_sysroot@^'"$mb_cflags_sysroot"'^g'		\
8be377
			-e 's^@cflags_os@^'"$mb_cflags_os"'^g'				\
8be377
			-e 's^@cflags_site@^'"$mb_cflags_site"'^g'			\
8be377
			-e 's^@cflags_path@^'"$mb_cflags_path"'^g'			\
8be377
			-e 's^@cflags_strict@^'"$mb_cflags_strict"'^g'			\
8be377
			-e 's^@cflags_util@^'"$mb_cflags_util"'^g'			\
8be377
			-e 's^@cflags_last@^'"$mb_cflags_last"'^g'			\
8be377
			-e 's^@cflags_once@^'"$mb_cflags_once"'^g'			\
8be377
											\
8be377
			-e 's^@ldflags@^'"$mb_ldflags"'^g'				\
8be377
			-e 's^@ldflags_debug@^'"$mb_ldflags_debug"'^g'			\
8be377
			-e 's^@ldflags_common@^'"$mb_ldflags_common"'^g'		\
8be377
			-e 's^@ldflags_cmdline@^'"$mb_ldflags $mb_ldflags_cmdline"'^g'	\
8be377
			-e 's^@ldflags_config@^'"$mb_ldflags_config"'^g'		\
8be377
			-e 's^@ldflags_sysroot@^'"$mb_ldflags_sysroot"'^g'		\
8be377
			-e 's^@ldflags_path@^'"$mb_ldflags_path"'^g'			\
8be377
			-e 's^@ldflags_strict@^'"$mb_ldflags_strict"'^g'		\
8be377
			-e 's^@ldflags_util@^'"$mb_ldflags_util"'^g'			\
8be377
			-e 's^@ldflags_last@^'"$mb_ldflags_last"'^g'			\
8be377
			-e 's^@ldflags_once@^'"$mb_ldflags_once"'^g'			\
8be377
											\
8be377
			-e 's^@pe_subsystem@^'"$mb_pe_subsystem"'^g'			\
8be377
			-e 's^@pe_image\_base@^'"$mb_pe_image_base"'^g'			\
8be377
			-e 's^@pe_config\_defs@^'"$mb_pe_config_defs"'^g'		\
8be377
											\
8be377
			-e 's^@elf_eh\_frame@^'"$mb_elf_eh_frame"'^g'			\
8be377
			-e 's^@elf_hash\_style@^'"$mb_elf_hash_style"'^g'		\
8be377
			-e 's^@elf_config\_defs@^'"$mb_elf_config_defs"'^g'		\
8be377
											\
8be377
			-e 's^@prefix@^'"$mb_prefix"'^g'				\
8be377
			-e 's^@exec_prefix@^'"$mb_exec_prefix"'^g'			\
8be377
			-e 's^@bindir@^'"$mb_bindir"'^g'				\
2623f6
			-e 's^@sbindir@^'"$mb_sbindir"'^g'				\
8be377
			-e 's^@libdir@^'"$mb_libdir"'^g'				\
8be377
			-e 's^@includedir@^'"$mb_includedir"'^g'			\
8be377
			-e 's^@mandir@^'"$mb_mandir"'^g'				\
8be377
			-e 's^@docdir@^'"$mb_docdir"'^g'				\
8be377
			-e 's^@libexecdir@^'"$mb_libexecdir"'^g'			\
8be377
											\
8be377
			-e 's^@native_cc@^'"$mb_native_cc"'^g'				\
8be377
			-e 's^@native_os@^'"$mb_native_os"'^g'				\
8be377
			-e 's^@native_os_bits@^'"$mb_native_os_bits"'^g'		\
8be377
			-e 's^@native_os_underscore@^'"$mb_native_os_underscore"'^g'	\
8be377
											\
8be377
			-e 's^@user_cc@^'"$mb_user_cc"'^g'				\
8be377
			-e 's^@user_cpp@^'"$mb_user_cpp"'^g'				\
8be377
			-e 's^@user_cxx@^'"$mb_user_cxx"'^g'				\
8be377
											\
8be377
			-e 's^@all_static@^'"$mb_all_static"'^g'			\
8be377
			-e 's^@all_shared@^'"$mb_all_shared"'^g'			\
8be377
			-e 's^@disable_frontend@^'"$mb_disable_frontend"'^g'		\
8be377
			-e 's^@disable_static@^'"$mb_disable_static"'^g'		\
8be377
			-e 's^@disable_shared@^'"$mb_disable_shared"'^g'		\
8be377
		$mb_project_dir/Makefile.in > $mb_pwd/Makefile
8be377
}
8be377
8be377
8be377
config_support()
8be377
{
8be377
	[ "$mb_disable_shared" = 'yes' ] && return 0
8be377
8be377
	mbt_cc=`make .display-cc`
8be377
	mbt_cflags=`make .display-cflags`
8be377
	mbt_source='int foo(int x){return ++x;}'
8be377
	mbt_result='no'
8be377
8be377
	rm -f a.out
8be377
	echo "$mbt_source" | "$mbt_cc" -shared -o a.out -xc -
8be377
	stat a.out >/dev/null 2>&1 && mbt_result='yes'
8be377
	rm -f a.out
8be377
8be377
	if [ "$mbt_result" = 'no' ]; then
8be377
		mb_disable_shared='yes'
8be377
		config_copy
8be377
	fi
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
8be377
# one: init
8be377
init_vars
8be377
verify_build_directory
8be377
8be377
8be377
# two: args
8be377
for arg ; do
8be377
	case "$arg" in
8be377
		--help)	usage
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=*)
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
			;;
8be377
		--mandir=*)
8be377
			mb_mandir=${arg#*=}
8be377
			;;
8be377
		--libexecdir=*)
8be377
			mb_libexecdir=${arg#*=}
8be377
			;;
8be377
8be377
8be377
		# build
8be377
		--build=*)
8be377
			mb_build=${arg#*=}
8be377
			;;
8be377
		--host=*)
8be377
			mb_host=${arg#*=}
8be377
			;;
8be377
		--target=*)
8be377
			mb_target=${arg#*=}
8be377
			;;
8be377
		--arch=*)
8be377
			mb_arch=${arg#*=}
8be377
			;;
8be377
		--compiler=*)
8be377
			mb_compiler=${arg#*=}
8be377
			;;
8be377
		--toolchain=*)
8be377
			mb_toolchain=${arg#*=}
8be377
			;;
8be377
		--sysroot=*)
8be377
			mb_sysroot=${arg#*=}
8be377
			;;
8be377
		--cross-compile=*)
8be377
			mb_cross_compile=${arg#*=}
8be377
			;;
8be377
		--shell=*)
8be377
			mb_shell=${arg#*=}
8be377
			;;
8be377
		--debug)
8be377
			mb_debug='yes'
8be377
			;;
8be377
8be377
		# config
8be377
		--all-static)
8be377
			mb_all_static='yes'
8be377
			;;
8be377
		--all-shared)
8be377
			mb_all_shared='yes'
8be377
			;;
8be377
		--disable-frontend)
8be377
			mb_disable_frontend='yes'
8be377
			;;
8be377
		--disable-app)
8be377
			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)
8be377
			mb_disable_static='yes'
8be377
			;;
8be377
		--disable-shared)
8be377
			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)
8be377
			mb_ccstrict='yes'
8be377
			mb_ldstrict='yes'
8be377
			;;
8be377
		--ccstrict)
8be377
			mb_ccstrict='yes'
8be377
			;;
8be377
		--ldstrict)
8be377
			mb_ldstrict='yes'
8be377
			;;
8be377
8be377
		# project
8be377
		--nickname=*)
8be377
			mb_nickname=${arg#*=}
8be377
			;;
8be377
		--avoid-version)
8be377
			mb_avoid_version='yes'
8be377
			;;
8be377
		--source-dir=*)
8be377
			mb_source_dir=${arg#*=}
8be377
			;;
8be377
8be377
		*)
8be377
			error_msg ${arg#}: "unsupported config argument."
8be377
			exit 2
8be377
			;;
8be377
	esac
8be377
done
8be377
8be377
8be377
8be377
# three: validation
8be377
verify_source_directory
8be377
8be377
8be377
8be377
# four: defaults
8be377
common_defaults
8be377
native_defaults
8be377
cross_defaults
8be377
8be377
8be377
8be377
# five: config
8be377
config_flags
8be377
config_copy
8be377
config_support
8be377
config_host
8be377
config_status
8be377
8be377
8be377
# all done
8be377
exit 0