Blame configure

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