Blame configure

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