09157951638 / compilers / bcparser

Forked from compilers/bcparser a year ago
Clone

Blame configure

ffea9c
#!/bin/sh
ffea9c
# we are no longer lazy.
ffea9c
ffea9c
# this script respects both CFLAGS and CFLAGS_CMDLINE,
ffea9c
# as well as both LDFLAGS and LDFLAGS_CMDLINE, however
ffea9c
# the latter variable of each pair should be preferred.
ffea9c
ffea9c
usage()
ffea9c
{
ffea9c
	cat "$mb_project_dir"/config.usage
ffea9c
	exit $?
ffea9c
}
ffea9c
ffea9c
error_msg()
ffea9c
{
ffea9c
	echo "$@" >&2
ffea9c
}
ffea9c
ffea9c
ffea9c
init_vars()
ffea9c
{
ffea9c
	mb_project_dir=$(cd `dirname $0` ; pwd)
ffea9c
	mb_pwd=`pwd`
ffea9c
ffea9c
	if [ -z "$mb_config" ]; then
ffea9c
		. $mb_project_dir/config.project || exit 2
ffea9c
	else
ffea9c
		. "$mb_config" || exit 2
ffea9c
	fi
ffea9c
ffea9c
	# git
ffea9c
	if [ -d "$mb_project_dir/.git" ]; then
ffea9c
		mb_git_reference_dir="\$(PROJECT_DIR)/.git"
ffea9c
	fi
ffea9c
ffea9c
	# project
ffea9c
	mb_nickname=$NICKNAME
ffea9c
ffea9c
	# dirs
ffea9c
	mb_prefix=$PREFIX
ffea9c
	mb_exec_prefix=$EXEC_PREFIX
ffea9c
	mb_bindir=$BINDIR
ffea9c
	mb_libdir=$LIBDIR
ffea9c
	mb_includedir=$INCLUDEDIR
ffea9c
	mb_mandir=$MANDIR
ffea9c
	mb_docdir=$DOCDIR
ffea9c
	mb_libexecdir=$LIBEXECDIR
ffea9c
ffea9c
ffea9c
	# build
ffea9c
	mb_build=$BUILD
ffea9c
	mb_host=$HOST
ffea9c
	mb_target=$TARGET
ffea9c
	mb_arch=$ARCH
ffea9c
	mb_compiler=$COMPILER
ffea9c
	mb_toolchain=$TOOLCHAIN
ffea9c
	mb_sysroot=$SYSROOT
ffea9c
	mb_cross_compile=$CROSS_COMPILE
ffea9c
	mb_shell=$SHELL
ffea9c
ffea9c
	# switches
ffea9c
	mb_cflags=$CFLAGS
ffea9c
	mb_cflags_debug=$CFLAGS_DEBUG
ffea9c
	mb_cflags_common=$CFLAGS_COMMON
ffea9c
	mb_cflags_cmdline=$CFLAGS_CMDLINE
ffea9c
	mb_cflags_config=$CFLAGS_CONFIG
ffea9c
	mb_cflags_sysroot=$CFLAGS_SYSROOT
ffea9c
	mb_cflags_os=$CFLAGS_OS
ffea9c
	mb_cflags_site=$CFLAGS_SITE
ffea9c
	mb_cflags_path=$CFLAGS_PATH
ffea9c
	mb_cflags_strict=$CFLAGS_STRICT
ffea9c
	mb_cflags_util=$CFLAGS_UTIL
32aed5
	mb_cflags_last=$CFLAGS_LAST
32aed5
	mb_cflags_once=$CFLAGS_ONCE
ffea9c
ffea9c
	mb_ldflags=$LDFLAGS
ffea9c
	mb_ldflags_debug=$LDFLAGS_DEBUG
ffea9c
	mb_ldflags_common=$LDFLAGS_COMMON
ffea9c
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
ffea9c
	mb_ldflags_config=$LDFLAGS_CONFIG
ffea9c
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
ffea9c
	mb_ldflags_path=$LDFLAGS_PATH
ffea9c
	mb_ldflags_strict=$LDFLAGS_STRICT
ffea9c
	mb_ldflags_util=$LDFLAGS_UTIL
32aed5
	mb_ldflags_last=$LDFLAGS_LAST
32aed5
	mb_ldflags_once=$LDFLAGS_ONCE
ffea9c
ffea9c
	mb_pe_subsystem=$PE_SUBSYSTEM
ffea9c
	mb_pe_image_base=$PE_IMAGE_BASE
ffea9c
	mb_pe_config_defs=$PE_CONFIG_DEFS
ffea9c
ffea9c
	mb_elf_eh_frame=$ELF_EH_FRAME
ffea9c
	mb_elf_hash_style=$ELF_HASH_STYLE
ffea9c
	mb_elf_config_defs=$ELF_CONFIG_DEFS
ffea9c
ffea9c
	# overrides
ffea9c
	mb_native_cc=$NATIVE_CC
ffea9c
	mb_native_os=$NATIVE_OS
ffea9c
	mb_native_os_bits=$NATIVE_OS_BITS
ffea9c
	mb_native_os_underscore=$NATIVE_OS_UNDERSCORE
ffea9c
ffea9c
	mb_user_cc=$CC
ffea9c
	mb_user_cpp=$CPP
ffea9c
	mb_user_cxx=$CXX
ffea9c
}
ffea9c
ffea9c
ffea9c
verify_build_directory()
ffea9c
{
ffea9c
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
ffea9c
		if [ "$mb_require_out_of_tree" = yes ]; then
ffea9c
			error_msg "$mb_package: out-of-tree builds are required."
ffea9c
			error_msg "please invoke configure again from a clean build directory."
ffea9c
			exit 2
ffea9c
		else
ffea9c
			mb_project_dir='.'
ffea9c
		fi
ffea9c
	fi
ffea9c
}
ffea9c
ffea9c
ffea9c
common_defaults()
ffea9c
{
ffea9c
	# project
ffea9c
	[ -z "$mb_nickname" ] 		&& mb_nickname=$mb_package
ffea9c
	[ -z "$mb_avoid_version" ] 	&& mb_avoid_version='no'
ffea9c
ffea9c
	# dirs
ffea9c
	[ -z "$mb_prefix" ] 		&& [ -z "$mb_prefix_set" ] \
ffea9c
					&& mb_prefix='/usr/local'
ffea9c
ffea9c
	[ -z "$mb_exec_prefix" ] 	&& [ -z "$mb_exec_prefix_set" ]	\
ffea9c
					&& mb_exec_prefix=$mb_prefix
ffea9c
ffea9c
	[ -z "$mb_bindir" ] 		&& mb_bindir=$mb_exec_prefix/bin
ffea9c
	[ -z "$mb_libdir" ] 		&& mb_libdir=$mb_exec_prefix/lib
ffea9c
	[ -z "$mb_includedir" ]		&& mb_includedir=$mb_prefix/include
ffea9c
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
ffea9c
	[ -z "$mb_mandir" ] 		&& mb_mandir=$mb_datarootdir/man
ffea9c
	[ -z "$mb_docdir" ] 		&& mb_docdir=$mb_datarootdir/doc
ffea9c
	[ -z "$mb_libexecdir" ]		&& mb_libexecdir=$mb_exec_prefix/libexec
ffea9c
ffea9c
	# build
ffea9c
	[ -z "$mb_build" ] 		&& mb_build=$mb_default_build
ffea9c
	[ -z "$mb_host" ] 		&& mb_host=$mb_default_host
ffea9c
	[ -z "$mb_target" ] 		&& mb_target=$mb_default_target
ffea9c
	[ -z "$mb_arch" ] 		&& mb_arch=$mb_default_arch
ffea9c
	[ -z "$mb_compiler" ] 		&& mb_compiler=$mb_default_compiler
ffea9c
	[ -z "$mb_toolchain" ] 		&& mb_toolchain=$mb_default_toolchain
ffea9c
	[ -z "$mb_sysroot" ] 		&& mb_sysroot=$mb_default_sysroot
ffea9c
	[ -z "$mb_cross_compile" ] 	&& mb_cross_compile=$mb_default_cross_compile
ffea9c
	[ -z "$mb_shell" ] 		&& mb_shell=$mb_default_shell
ffea9c
ffea9c
	# switches
ffea9c
	[ -z "$mb_cflags_debug" ]	&& mb_cflags_debug=$mb_default_cflags_debug
ffea9c
	[ -z "$mb_cflags_common" ]	&& mb_cflags_common=$mb_default_cflags_common
ffea9c
	[ -z "$mb_cflags_cmdline" ]	&& mb_cflags_cmdline=$mb_default_cflags_cmdline
ffea9c
	[ -z "$mb_cflags_config" ]	&& mb_cflags_config=$mb_default_cflags_config
ffea9c
	[ -z "$mb_cflags_sysroot" ]	&& mb_cflags_sysroot=$mb_default_cflags_sysroot
ffea9c
	[ -z "$mb_cflags_os" ]		&& mb_cflags_os=$mb_default_cflags_os
ffea9c
	[ -z "$mb_cflags_site" ]	&& mb_cflags_site=$mb_default_cflags_site
ffea9c
	[ -z "$mb_cflags_path" ]	&& mb_cflags_path=$mb_default_cflags_path
ffea9c
	[ -z "$mb_cflags_strict" ]	&& mb_cflags_strict=$mb_default_cflags_strict
ffea9c
	[ -z "$mb_cflags_util" ]	&& mb_cflags_util=$mb_default_cflags_util
32aed5
	[ -z "$mb_cflags_last" ]	&& mb_cflags_last=$mb_default_cflags_last
32aed5
	[ -z "$mb_cflags_once" ]	&& mb_cflags_once=$mb_default_cflags_once
ffea9c
ffea9c
	[ -z "$mb_ldflags_debug" ]	&& mb_ldflags_debug=$mb_default_ldflags_debug
ffea9c
	[ -z "$mb_ldflags_common" ]	&& mb_ldflags_common=$mb_default_ldflags_common
ffea9c
	[ -z "$mb_ldflags_cmdline" ]	&& mb_ldflags_cmdline=$mb_default_ldflags_cmdline
ffea9c
	[ -z "$mb_ldflags_config" ]	&& mb_ldflags_config=$mb_default_ldflags_config
ffea9c
	[ -z "$mb_ldflags_sysroot" ]	&& mb_ldflags_sysroot=$mb_default_ldflags_sysroot
ffea9c
	[ -z "$mb_ldflags_path" ]	&& mb_ldflags_path=$mb_default_ldflags_path
ffea9c
	[ -z "$mb_ldflags_strict" ]	&& mb_ldflags_strict=$mb_default_ldflags_strict
ffea9c
	[ -z "$mb_ldflags_util" ]	&& mb_ldflags_util=$mb_default_ldflags_util
32aed5
	[ -z "$mb_ldflags_last" ]	&& mb_ldflags_last=$mb_default_ldflags_last
32aed5
	[ -z "$mb_ldflags_once" ]	&& mb_ldflags_once=$mb_default_ldflags_once
ffea9c
ffea9c
	[ -z "$mb_pe_subsystem" ]	&& mb_pe_subsystem=$mb_default_pe_subsystem
ffea9c
	[ -z "$mb_pe_image_base" ]	&& mb_pe_image_base=$mb_default_pe_image_base
ffea9c
	[ -z "$mb_pe_config_defs" ]	&& mb_pe_config_defs=$mb_default_pe_config_defs
ffea9c
ffea9c
	[ -z "$mb_elf_eh_frame" ]	&& mb_elf_eh_frame=$mb_default_elf_eh_frame
ffea9c
	[ -z "$mb_elf_hash_style" ]	&& mb_elf_hash_style=$mb_default_elf_hash_style
ffea9c
	[ -z "$mb_elf_config_defs" ]	&& mb_elf_config_defs=$mb_default_elf_config_defs
ffea9c
ffea9c
	# config
ffea9c
	[ -z "$mb_all_static" ]		&& mb_all_static='no'
ffea9c
	[ -z "$mb_all_shared" ]		&& mb_all_shared='no'
ffea9c
	[ -z "$mb_disable_frontend" ]	&& mb_disable_frontend='no'
ffea9c
	[ -z "$mb_disable_static" ]	&& mb_disable_static='no'
ffea9c
	[ -z "$mb_disable_shared" ]	&& mb_disable_shared='no'
ffea9c
ffea9c
	# host/target
ffea9c
	[ -z "$mb_host" ] 		&& mb_host=$mb_target
ffea9c
	[ -z "$mb_target" ] 		&& mb_target=$mb_host
ffea9c
ffea9c
	# sysroot
ffea9c
	if [ -n "$mb_sysroot" ]; then
ffea9c
		if [ -z "$mb_cflags_sysroot" ]; then
ffea9c
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
ffea9c
		fi
ffea9c
ffea9c
		if [ -z "$mb_ldflags_sysroot" ]; then
ffea9c
			mb_ldflags_sysroot="-Wl,--sysroot,$mb_sysroot"
ffea9c
		fi
ffea9c
	fi
ffea9c
ffea9c
	# debug
ffea9c
	if [ "$mb_debug" = yes ]; then
ffea9c
		if [ -z "$mb_cflags_debug" ]; then
ffea9c
			mb_cflags_debug='-g3 -O0'
ffea9c
		fi
ffea9c
	fi
ffea9c
ffea9c
	# compiler
ffea9c
	if [ -n "$mb_compiler" ]; then
ffea9c
		if [ -z "$mb_native_cc" ]; then
ffea9c
			mb_native_cc=$mb_compiler
ffea9c
		fi
ffea9c
	fi
ffea9c
ffea9c
	# toolchain
ffea9c
	if [ -z "$mb_toolchain" ]; then
ffea9c
		mb_toolchain='binutils'
ffea9c
	fi
ffea9c
ffea9c
	# fallback host recipe
ffea9c
	if [ -n "$mb_host" ]; then
ffea9c
		if ! [ -f $mb_project_dir/sysinfo/host/$mb_host.mk ]; then
ffea9c
			if [ -z "$mb_cross_compile" ]; then
ffea9c
				mb_cross_compile=$mb_host-
ffea9c
			fi
ffea9c
ffea9c
			mb_host='any-host';
ffea9c
		fi
ffea9c
	fi
ffea9c
ffea9c
	# fallback compiler recipe
ffea9c
	if [ -n "$mb_compiler" ]; then
ffea9c
		if ! [ -f $mb_project_dir/sysinfo/compiler/$mb_compiler.mk ]; then
ffea9c
			mb_compiler='any-compiler'
ffea9c
		fi
ffea9c
	fi
ffea9c
}
ffea9c
ffea9c
ffea9c
native_defaults()
ffea9c
{
ffea9c
	# CC (when set, must be valid)
ffea9c
	if [ -n "$CC" ]; then
ffea9c
		$CC -dM -E - < /dev/null > /dev/null || exit 2
ffea9c
	fi
ffea9c
ffea9c
	# compiler
ffea9c
	[ -z "$mb_native_cc" ] && mb_native_cc=$CC
ffea9c
	[ -z "$mb_native_cc" ] && mb_native_cc='cc'
ffea9c
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
ffea9c
ffea9c
	[ -z "$mb_native_cc" ] && mb_native_cc='gcc'
ffea9c
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
ffea9c
ffea9c
	[ -z "$mb_native_cc" ] && mb_native_cc='clang'
ffea9c
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
ffea9c
ffea9c
	[ -z "$mb_native_cc" ] && mb_native_cc='cparser'
ffea9c
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
ffea9c
ffea9c
	if [ -z "$mb_native_cc" ]; then
ffea9c
		echo "configure: info: could not find a working native compiler."
ffea9c
		mb_native_cc='false'
ffea9c
	fi
ffea9c
ffea9c
	if [ -z "$mb_compiler" ]; then
ffea9c
		$mb_native_cc -dM -E - < /dev/null | grep '__clang__' > /dev/null && mb_compiler='clang'
ffea9c
	fi
ffea9c
ffea9c
	if [ -z "$mb_compiler" ]; then
ffea9c
		$mb_native_cc -dM -E - < /dev/null | grep '__GCC' > /dev/null && mb_compiler='gcc'
ffea9c
	fi
ffea9c
ffea9c
	if [ -z "$mb_compiler" ]; then
ffea9c
		$mb_native_cc -dM -E - < /dev/null | grep '__CPARSER__' > /dev/null && mb_compiler='cparser'
ffea9c
	fi
ffea9c
ffea9c
	if [ -z "$mb_compiler" ]; then
ffea9c
		echo "configure: info: could not identify the native compiler."
ffea9c
		mb_compiler='any-compiler'
ffea9c
	fi
ffea9c
ffea9c
ffea9c
	# host
ffea9c
	if [ -z "$mb_host" ]; then
ffea9c
		mb_host='native'
ffea9c
	fi
ffea9c
ffea9c
ffea9c
	# target
ffea9c
	if [ -z "$mb_target" ]; then
ffea9c
		mb_target='native'
ffea9c
	fi
ffea9c
ffea9c
ffea9c
	# os
ffea9c
	mb_native_os=`uname | tr '[:upper:]' '[:lower:]'`
ffea9c
ffea9c
	mb_native_os_sizeof_pointer=`$mb_native_cc -dM -E - < /dev/null \
ffea9c
			| grep __SIZEOF_POINTER__  \
ffea9c
			| cut -d ' ' -f3`
ffea9c
ffea9c
	mb_native_os_bits=`expr '8' '*' '0'"$mb_native_os_sizeof_pointer"`
ffea9c
ffea9c
	if [ $mb_native_os_bits = 32 ]; then
ffea9c
		mb_native_os_underscore='_'
ffea9c
	else
ffea9c
		mb_native_os_underscore=''
ffea9c
	fi
ffea9c
ffea9c
	if [ -z "$mb_native_os_sizeof_pointer" ]; then
ffea9c
		error_msg "config error: could not determine size of pointer on native system."
ffea9c
		exit 2
ffea9c
	fi
ffea9c
ffea9c
	# fallback os recipe
ffea9c
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
ffea9c
		mb_native_os='any-os';
ffea9c
	fi
ffea9c
}
ffea9c
ffea9c
ffea9c
cross_defaults()
ffea9c
{
ffea9c
	if [ -z "$mb_cross_compile" ] && [ "$mb_host" != native ]; then
ffea9c
		mb_cross_compile=$mb_host'-'
ffea9c
	fi
ffea9c
}
ffea9c
ffea9c
ffea9c
config_flags()
ffea9c
{
ffea9c
	mb_ldflags_tmp=" $mb_ldflags "
ffea9c
	mb_ldflags_libs=`echo "$mb_ldflags_tmp" | sed 's/ -static / /g'`
ffea9c
ffea9c
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
ffea9c
		mb_ldflags="$mb_ldflags_libs"
ffea9c
		mb_ldflags_util="$mb_ldflags_util -static"
ffea9c
	fi
ffea9c
ffea9c
	# ccstrict
ffea9c
	if [ "$mb_ccstrict" = 'yes' ]; then
ffea9c
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
ffea9c
	fi
ffea9c
ffea9c
	# ldstrict
ffea9c
	if [ "$mb_ldstrict" = 'yes' ]; then
ffea9c
		mb_ldflags_strict='-Wl,--no-undefined'
ffea9c
	fi
ffea9c
}
ffea9c
ffea9c
ffea9c
config_copy()
ffea9c
{
ffea9c
	sed 		-e 's^@package@^'"$mb_package"'^g' 				\
ffea9c
			-e 's^@nickname@^'"$mb_nickname"'^g'				\
ffea9c
			-e 's^@project_dir@^'"$mb_project_dir"'^g'			\
ffea9c
			-e 's^@git_reference_dir@^'"$mb_git_reference_dir"'^g'		\
ffea9c
			-e 's^@custom_install_headers@^'"$mb_custom_install_headers"'^g' \
ffea9c
			-e 's^@avoid_version@^'"$mb_avoid_version"'^g'			\
ffea9c
											\
ffea9c
			-e 's^@build@^'"$mb_build"'^g'					\
ffea9c
			-e 's^@host@^'"$mb_host"'^g'					\
ffea9c
			-e 's^@target@^'"$mb_target"'^g'				\
ffea9c
			-e 's^@arch@^'"$mb_arch"'^g'					\
ffea9c
			-e 's^@compiler@^'"$mb_compiler"'^g'				\
ffea9c
			-e 's^@toolchain@^'"$mb_toolchain"'^g'				\
ffea9c
			-e 's^@sysroot@^'"$mb_sysroot"'^g'				\
ffea9c
			-e 's^@cross_compile@^'"$mb_cross_compile"'^g'			\
ffea9c
			-e 's^@shell@^'"$mb_shell"'^g'					\
ffea9c
											\
ffea9c
			-e 's^@cflags@^'"$mb_cflags"'^g'				\
ffea9c
			-e 's^@cflags_debug@^'"$mb_cflags_debug"'^g'			\
ffea9c
			-e 's^@cflags_common@^'"$mb_cflags_common"'^g'			\
ffea9c
			-e 's^@cflags_cmdline@^'"$mb_cflags $mb_cflags_cmdline"'^g'	\
ffea9c
			-e 's^@cflags_config@^'"$mb_cflags_config"'^g'			\
ffea9c
			-e 's^@cflags_sysroot@^'"$mb_cflags_sysroot"'^g'		\
ffea9c
			-e 's^@cflags_os@^'"$mb_cflags_os"'^g'				\
ffea9c
			-e 's^@cflags_site@^'"$mb_cflags_site"'^g'			\
ffea9c
			-e 's^@cflags_path@^'"$mb_cflags_path"'^g'			\
ffea9c
			-e 's^@cflags_strict@^'"$mb_cflags_strict"'^g'			\
ffea9c
			-e 's^@cflags_util@^'"$mb_cflags_util"'^g'			\
32aed5
			-e 's^@cflags_last@^'"$mb_cflags_last"'^g'			\
32aed5
			-e 's^@cflags_once@^'"$mb_cflags_once"'^g'			\
ffea9c
											\
ffea9c
			-e 's^@ldflags@^'"$mb_ldflags"'^g'				\
ffea9c
			-e 's^@ldflags_debug@^'"$mb_ldflags_debug"'^g'			\
ffea9c
			-e 's^@ldflags_common@^'"$mb_ldflags_common"'^g'		\
ffea9c
			-e 's^@ldflags_cmdline@^'"$mb_ldflags $mb_ldflags_cmdline"'^g'	\
ffea9c
			-e 's^@ldflags_config@^'"$mb_ldflags_config"'^g'		\
ffea9c
			-e 's^@ldflags_sysroot@^'"$mb_ldflags_sysroot"'^g'		\
ffea9c
			-e 's^@ldflags_path@^'"$mb_ldflags_path"'^g'			\
ffea9c
			-e 's^@ldflags_strict@^'"$mb_ldflags_strict"'^g'		\
ffea9c
			-e 's^@ldflags_util@^'"$mb_ldflags_util"'^g'			\
32aed5
			-e 's^@ldflags_last@^'"$mb_ldflags_last"'^g'			\
32aed5
			-e 's^@ldflags_once@^'"$mb_ldflags_once"'^g'			\
ffea9c
											\
ffea9c
			-e 's^@pe_subsystem@^'"$mb_pe_subsystem"'^g'			\
ffea9c
			-e 's^@pe_image\_base@^'"$mb_pe_image_base"'^g'			\
ffea9c
			-e 's^@pe_config\_defs@^'"$mb_pe_config_defs"'^g'		\
ffea9c
											\
ffea9c
			-e 's^@elf_eh\_frame@^'"$mb_elf_eh_frame"'^g'			\
ffea9c
			-e 's^@elf_hash\_style@^'"$mb_elf_hash_style"'^g'		\
ffea9c
			-e 's^@elf_config\_defs@^'"$mb_elf_config_defs"'^g'		\
ffea9c
											\
ffea9c
			-e 's^@prefix@^'"$mb_prefix"'^g'				\
ffea9c
			-e 's^@exec_prefix@^'"$mb_exec_prefix"'^g'			\
ffea9c
			-e 's^@bindir@^'"$mb_bindir"'^g'				\
ffea9c
			-e 's^@libdir@^'"$mb_libdir"'^g'				\
ffea9c
			-e 's^@includedir@^'"$mb_includedir"'^g'			\
ffea9c
			-e 's^@mandir@^'"$mb_mandir"'^g'				\
ffea9c
			-e 's^@docdir@^'"$mb_docdir"'^g'				\
ffea9c
			-e 's^@libexecdir@^'"$mb_libexecdir"'^g'			\
ffea9c
											\
ffea9c
			-e 's^@native_cc@^'"$mb_native_cc"'^g'				\
ffea9c
			-e 's^@native_os@^'"$mb_native_os"'^g'				\
ffea9c
			-e 's^@native_os_bits@^'"$mb_native_os_bits"'^g'		\
ffea9c
			-e 's^@native_os_underscore@^'"$mb_native_os_underscore"'^g'	\
ffea9c
											\
ffea9c
			-e 's^@user_cc@^'"$mb_user_cc"'^g'				\
ffea9c
			-e 's^@user_cpp@^'"$mb_user_cpp"'^g'				\
ffea9c
			-e 's^@user_cxx@^'"$mb_user_cxx"'^g'				\
ffea9c
											\
ffea9c
			-e 's^@all_static@^'"$mb_all_static"'^g'			\
ffea9c
			-e 's^@all_shared@^'"$mb_all_shared"'^g'			\
ffea9c
			-e 's^@disable_frontend@^'"$mb_disable_frontend"'^g'		\
ffea9c
			-e 's^@disable_static@^'"$mb_disable_static"'^g'		\
ffea9c
			-e 's^@disable_shared@^'"$mb_disable_shared"'^g'		\
ffea9c
		$mb_project_dir/Makefile.in > $mb_pwd/Makefile
ffea9c
}
ffea9c
ffea9c
ffea9c
config_support()
ffea9c
{
ffea9c
	[ "$mb_disable_shared" = 'yes' ] && return 0
ffea9c
ffea9c
	mbt_cc=`make .display-cc`
ffea9c
	mbt_cflags=`make .display-cflags`
ffea9c
	mbt_source='int foo(int x){return ++x;}'
ffea9c
	mbt_result='no'
ffea9c
ffea9c
	rm -f a.out
ffea9c
	echo "$mbt_source" | "$mbt_cc" -shared -o a.out -xc -
ffea9c
	stat a.out >/dev/null 2>&1 && mbt_result='yes'
ffea9c
	rm -f a.out
ffea9c
ffea9c
	if [ "$mbt_result" = 'no' ]; then
ffea9c
		mb_disable_shared='yes'
ffea9c
		config_copy
ffea9c
	fi
ffea9c
}
ffea9c
ffea9c
ffea9c
config_host()
ffea9c
{
ffea9c
	make -s host.tag && return 0
ffea9c
ffea9c
	error_msg "configure was able to generate a Makefile for the selected host,"
ffea9c
	error_msg "however the host-targeting compiler was found to be missing"
ffea9c
	error_msg "at least one of the required headers or features."
ffea9c
	exit 2
ffea9c
}
ffea9c
ffea9c
ffea9c
config_status()
ffea9c
{
ffea9c
	printf "\n\n"
ffea9c
	make .display
ffea9c
	printf "\nconfiguration completed successfully.\n\n"
ffea9c
}
ffea9c
ffea9c
# one: init
ffea9c
init_vars
ffea9c
verify_build_directory
ffea9c
ffea9c
ffea9c
# two: args
ffea9c
for arg ; do
ffea9c
	case "$arg" in
ffea9c
		--help)	usage
ffea9c
			;;
ffea9c
ffea9c
		# dirs
ffea9c
		--prefix=*)
ffea9c
			mb_prefix_set=yes
ffea9c
			mb_prefix=${arg#*=}
ffea9c
			;;
ffea9c
		--exec-prefix=*)
ffea9c
			mb_exec_prefix_set=yes
ffea9c
			mb_exec_prefix=${arg#*=}
ffea9c
			;;
ffea9c
		--bindir=*)
ffea9c
			mb_bindir=${arg#*=}
ffea9c
			;;
ffea9c
		--libdir=*)
ffea9c
			mb_libdir=${arg#*=}
ffea9c
			;;
ffea9c
		--includedir=*)
ffea9c
			mb_includedir=${arg#*=}
ffea9c
			;;
ffea9c
		--mandir=*)
ffea9c
			mb_mandir=${arg#*=}
ffea9c
			;;
ffea9c
		--libexecdir=*)
ffea9c
			mb_libexecdir=${arg#*=}
ffea9c
			;;
ffea9c
ffea9c
ffea9c
		# build
ffea9c
		--build=*)
ffea9c
			mb_build=${arg#*=}
ffea9c
			;;
ffea9c
		--host=*)
ffea9c
			mb_host=${arg#*=}
ffea9c
			;;
ffea9c
		--target=*)
ffea9c
			mb_target=${arg#*=}
ffea9c
			;;
ffea9c
		--arch=*)
ffea9c
			mb_arch=${arg#*=}
ffea9c
			;;
ffea9c
		--compiler=*)
ffea9c
			mb_compiler=${arg#*=}
ffea9c
			;;
ffea9c
		--toolchain=*)
ffea9c
			mb_toolchain=${arg#*=}
ffea9c
			;;
ffea9c
		--sysroot=*)
ffea9c
			mb_sysroot=${arg#*=}
ffea9c
			;;
ffea9c
		--cross-compile=*)
ffea9c
			mb_cross_compile=${arg#*=}
ffea9c
			;;
ffea9c
		--shell=*)
ffea9c
			mb_shell=${arg#*=}
ffea9c
			;;
ffea9c
		--debug)
ffea9c
			mb_debug='yes'
ffea9c
			;;
ffea9c
ffea9c
		# config
ffea9c
		--all-static)
ffea9c
			mb_all_static='yes'
ffea9c
			;;
ffea9c
		--all-shared)
ffea9c
			mb_all_shared='yes'
ffea9c
			;;
ffea9c
		--disable-frontend)
ffea9c
			mb_disable_frontend='yes'
ffea9c
			;;
ffea9c
		--disable-app)
ffea9c
			mb_disable_frontend='yes'
ffea9c
			;;
ffea9c
		--enable-frontend)
ffea9c
			mb_disable_frontend='no'
ffea9c
			;;
ffea9c
		--enable-app)
ffea9c
			mb_disable_frontend='no'
ffea9c
			;;
ffea9c
		--disable-static)
ffea9c
			mb_disable_static='yes'
ffea9c
			;;
ffea9c
		--disable-shared)
ffea9c
			mb_disable_shared='yes'
ffea9c
			;;
ffea9c
		--enable-static)
ffea9c
			mb_disable_static='no'
ffea9c
			;;
ffea9c
		--enable-shared)
ffea9c
			mb_disable_shared='no'
ffea9c
			;;
ffea9c
ffea9c
		# convenience
ffea9c
		--strict)
ffea9c
			mb_ccstrict='yes'
ffea9c
			mb_ldstrict='yes'
ffea9c
			;;
ffea9c
		--ccstrict)
ffea9c
			mb_ccstrict='yes'
ffea9c
			;;
ffea9c
		--ldstrict)
ffea9c
			mb_ldstrict='yes'
ffea9c
			;;
ffea9c
ffea9c
		# project
ffea9c
		--nickname=*)
ffea9c
			mb_nickname=${arg#*=}
ffea9c
			;;
ffea9c
		--avoid-version)
ffea9c
			mb_avoid_version='yes'
ffea9c
			;;
ffea9c
ffea9c
		*)
ffea9c
			error_msg ${arg#}: "unsupported config argument."
ffea9c
			exit 2
ffea9c
			;;
ffea9c
	esac
ffea9c
done
ffea9c
ffea9c
ffea9c
ffea9c
# three: defaults
ffea9c
common_defaults
ffea9c
native_defaults
ffea9c
cross_defaults
ffea9c
ffea9c
ffea9c
ffea9c
# four: config
ffea9c
config_flags
ffea9c
config_copy
ffea9c
config_support
ffea9c
config_host
ffea9c
config_status
ffea9c
ffea9c
ffea9c
# all done
ffea9c
exit 0