Blame configure

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