Blame configure

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