Blame configure

7b83a9
#!/bin/sh
7b83a9
# we are no longer lazy.
7b83a9
7b83a9
# this script respects both CFLAGS and CFLAGS_CMDLINE,
7b83a9
# as well as both LDFLAGS and LDFLAGS_CMDLINE, however
7b83a9
# the latter variable of each pair should be preferred.
7b83a9
1a5f04
usage()
1a5f04
{
a52949
	cat "$mb_project_dir"/config.usage
1a5f04
	exit $?
1a5f04
}
1a5f04
7b83a9
error_msg()
7b83a9
{
551024
	echo "$@" >&2
7b83a9
}
7b83a9
f00768
warning_msg()
f00768
{
f00768
	echo "$@" >&2
f00768
}
f00768
7b83a9
7b83a9
init_vars()
7b83a9
{
7b83a9
	mb_project_dir=$(cd `dirname $0` ; pwd)
7b83a9
	mb_pwd=`pwd`
7b83a9
5daef8
	if [ -z "$mb_config" ]; then
7b83a9
		. $mb_project_dir/config.project || exit 2
7b83a9
	else
7b83a9
		. "$mb_config" || exit 2
7b83a9
	fi
7b83a9
551024
	# project
551024
	mb_nickname=$NICKNAME
44e93e
	mb_source_dir=$SOURCE_DIR
551024
7b83a9
	# dirs
7b83a9
	mb_prefix=$PREFIX
2816af
	mb_exec_prefix=$EXEC_PREFIX
7b83a9
	mb_bindir=$BINDIR
71a82d
	mb_sbindir=$SBINDIR
7b83a9
	mb_libdir=$LIBDIR
7b83a9
	mb_includedir=$INCLUDEDIR
a719b2
	mb_oldincludedir=$OLDINCLUDEDIR
7b83a9
	mb_mandir=$MANDIR
7b83a9
	mb_docdir=$DOCDIR
7b83a9
	mb_libexecdir=$LIBEXECDIR
7b83a9
a719b2
	mb_sysconfdir=$SYSCONFDIR
a719b2
	mb_sharedstatedir=$SHAREDSTATEDIR
a719b2
	mb_localstatedir=$LOCALSTATEDIR
a719b2
	mb_runstatedir=$RUNSTATEDIR
a719b2
	mb_datarootdir=$DATAROOTDIR
a719b2
	mb_datadir=$DATADIR
a719b2
	mb_infodir=$INFODIR
a719b2
	mb_localedir=$LOCALEDIR
a719b2
	mb_htmldir=$HTMLDIR
a719b2
	mb_dvidir=$DVIDIR
a719b2
	mb_pdfdir=$PDFDIR
a719b2
	mb_psdir=$PSDIR
a719b2
7b83a9
7b83a9
	# build
7b83a9
	mb_build=$BUILD
7b83a9
	mb_host=$HOST
f6d035
	mb_cchost=$CCHOST
7b83a9
	mb_target=$TARGET
7b83a9
	mb_arch=$ARCH
f97c34
	mb_compiler=$COMPILER
651d7b
	mb_toolchain=$TOOLCHAIN
7b83a9
	mb_sysroot=$SYSROOT
7b83a9
	mb_cross_compile=$CROSS_COMPILE
7b83a9
	mb_shell=$SHELL
7b83a9
7b83a9
	# switches
7b83a9
	mb_cflags=$CFLAGS
7b83a9
	mb_cflags_debug=$CFLAGS_DEBUG
7b83a9
	mb_cflags_common=$CFLAGS_COMMON
7b83a9
	mb_cflags_cmdline=$CFLAGS_CMDLINE
7b83a9
	mb_cflags_config=$CFLAGS_CONFIG
7b83a9
	mb_cflags_sysroot=$CFLAGS_SYSROOT
551024
	mb_cflags_os=$CFLAGS_OS
551024
	mb_cflags_site=$CFLAGS_SITE
7b83a9
	mb_cflags_path=$CFLAGS_PATH
551024
	mb_cflags_strict=$CFLAGS_STRICT
551024
	mb_cflags_util=$CFLAGS_UTIL
8da1ad
	mb_cflags_last=$CFLAGS_LAST
8da1ad
	mb_cflags_once=$CFLAGS_ONCE
7b83a9
7b83a9
	mb_ldflags=$LDFLAGS
7b83a9
	mb_ldflags_debug=$LDFLAGS_DEBUG
7b83a9
	mb_ldflags_common=$LDFLAGS_COMMON
7b83a9
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
7b83a9
	mb_ldflags_config=$LDFLAGS_CONFIG
7b83a9
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
7b83a9
	mb_ldflags_path=$LDFLAGS_PATH
551024
	mb_ldflags_strict=$LDFLAGS_STRICT
551024
	mb_ldflags_util=$LDFLAGS_UTIL
8da1ad
	mb_ldflags_last=$LDFLAGS_LAST
8da1ad
	mb_ldflags_once=$LDFLAGS_ONCE
7b83a9
7b83a9
	mb_pe_subsystem=$PE_SUBSYSTEM
7b83a9
	mb_pe_image_base=$PE_IMAGE_BASE
7b83a9
	mb_pe_config_defs=$PE_CONFIG_DEFS
7b83a9
7b83a9
	mb_elf_eh_frame=$ELF_EH_FRAME
7b83a9
	mb_elf_hash_style=$ELF_HASH_STYLE
7b83a9
	mb_elf_config_defs=$ELF_CONFIG_DEFS
7b83a9
7b83a9
	# overrides
7b83a9
	mb_native_cc=$NATIVE_CC
7b83a9
	mb_native_os=$NATIVE_OS
7b83a9
	mb_native_os_bits=$NATIVE_OS_BITS
7b83a9
	mb_native_os_underscore=$NATIVE_OS_UNDERSCORE
2318d6
2318d6
	mb_user_cc=$CC
2318d6
	mb_user_cpp=$CPP
2318d6
	mb_user_cxx=$CXX
7b83a9
}
7b83a9
7b83a9
7b83a9
verify_build_directory()
7b83a9
{
5daef8
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
5daef8
		if [ "$mb_require_out_of_tree" = yes ]; then
7b83a9
			error_msg "$mb_package: out-of-tree builds are required."
7b83a9
			error_msg "please invoke configure again from a clean build directory."
7b83a9
			exit 2
7b83a9
		else
7b83a9
			mb_project_dir='.'
7b83a9
		fi
7b83a9
	fi
7b83a9
}
7b83a9
7b83a9
44e93e
verify_source_directory()
44e93e
{
44e93e
	if [ -z "$mb_source_dir" ]; then
44e93e
		if [ "$mb_require_source_dir" = yes ]; then
44e93e
			error_msg "$mb_package: specifying an external source directory is required."
44e93e
			error_msg "you can set the source directory either via --source-dir=<path>,"
44e93e
			error_msg "or by setting the SOURCE_DIR variable."
44e93e
			exit 2
44e93e
		fi
44e93e
	fi
44e93e
}
44e93e
44e93e
7b83a9
common_defaults()
7b83a9
{
44e93e
	# git
44e93e
	if [ -n "$mb_source_dir" ]; then
44e93e
		if [ -d "$mb_source_dir/.git" ]; then
7e8f13
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
44e93e
		fi
44e93e
	elif [ -d "$mb_project_dir/.git" ]; then
7e8f13
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
44e93e
	fi
44e93e
551024
	# project
551024
	[ -z "$mb_nickname" ] 		&& mb_nickname=$mb_package
44e93e
	[ -z "$mb_source_dir" ] 	&& mb_source_dir=$mb_project_dir
551024
	[ -z "$mb_avoid_version" ] 	&& mb_avoid_version='no'
551024
7b83a9
	# dirs
587ad1
	[ -z "$mb_prefix" ] 		&& [ -z "$mb_prefix_set" ] \
587ad1
					&& mb_prefix='/usr/local'
587ad1
587ad1
	[ -z "$mb_exec_prefix" ] 	&& [ -z "$mb_exec_prefix_set" ]	\
587ad1
					&& mb_exec_prefix=$mb_prefix
587ad1
c60b29
	[ -z "$mb_bindir" ] 		&& mb_bindir=$mb_exec_prefix/bin
71a82d
	[ -z "$mb_sbindir" ] 		&& mb_sbindir=$mb_exec_prefix/sbin
c60b29
	[ -z "$mb_libdir" ] 		&& mb_libdir=$mb_exec_prefix/lib
c60b29
	[ -z "$mb_includedir" ]		&& mb_includedir=$mb_prefix/include
a719b2
	[ -z "$mb_oldincludedir" ]	&& mb_oldincludedir=$mb_prefix/include
c60b29
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
c60b29
	[ -z "$mb_mandir" ] 		&& mb_mandir=$mb_datarootdir/man
c60b29
	[ -z "$mb_docdir" ] 		&& mb_docdir=$mb_datarootdir/doc
c60b29
	[ -z "$mb_libexecdir" ]		&& mb_libexecdir=$mb_exec_prefix/libexec
7b83a9
a719b2
	[ -z "$mb_sysconfdir" ] 	&& mb_sysconfdir=$mb_exec_prefix/etc
a719b2
	[ -z "$mb_sharedstatedir" ] 	&& mb_sharedstatedir=$mb_prefix/com
a719b2
	[ -z "$mb_localstatedir" ] 	&& mb_localstatedir=$mb_prefix/var
a719b2
	[ -z "$mb_runstatedir" ] 	&& mb_runstatedir=$mb_localstatedir/run
a719b2
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
a719b2
	[ -z "$mb_datadir" ] 		&& mb_datadir=$mb_datarootdir
a719b2
	[ -z "$mb_infodir" ] 		&& mb_infodir=$mb_datarootdir/info
a719b2
	[ -z "$mb_localedir" ] 		&& mb_localedir=$mb_datarootdir/locale
a719b2
	[ -z "$mb_htmldir" ] 		&& mb_htmldir=$mb_docdir
a719b2
	[ -z "$mb_dvidir" ] 		&& mb_dvidir=$mb_docdir
a719b2
	[ -z "$mb_pdfdir" ] 		&& mb_pdfdir=$mb_docdir
a719b2
	[ -z "$mb_psdir" ] 		&& mb_psdir=$mb_docdir
a719b2
a719b2
7b83a9
	# build
7b83a9
	[ -z "$mb_build" ] 		&& mb_build=$mb_default_build
7b83a9
	[ -z "$mb_host" ] 		&& mb_host=$mb_default_host
f6d035
	[ -z "$mb_cchost" ] 		&& mb_cchost=$mb_default_cchost
7b83a9
	[ -z "$mb_target" ] 		&& mb_target=$mb_default_target
7b83a9
	[ -z "$mb_arch" ] 		&& mb_arch=$mb_default_arch
f97c34
	[ -z "$mb_compiler" ] 		&& mb_compiler=$mb_default_compiler
651d7b
	[ -z "$mb_toolchain" ] 		&& mb_toolchain=$mb_default_toolchain
7b83a9
	[ -z "$mb_sysroot" ] 		&& mb_sysroot=$mb_default_sysroot
7b83a9
	[ -z "$mb_cross_compile" ] 	&& mb_cross_compile=$mb_default_cross_compile
7b83a9
	[ -z "$mb_shell" ] 		&& mb_shell=$mb_default_shell
7b83a9
7b83a9
	# switches
7b83a9
	[ -z "$mb_cflags_debug" ]	&& mb_cflags_debug=$mb_default_cflags_debug
7b83a9
	[ -z "$mb_cflags_common" ]	&& mb_cflags_common=$mb_default_cflags_common
7b83a9
	[ -z "$mb_cflags_cmdline" ]	&& mb_cflags_cmdline=$mb_default_cflags_cmdline
7b83a9
	[ -z "$mb_cflags_config" ]	&& mb_cflags_config=$mb_default_cflags_config
7b83a9
	[ -z "$mb_cflags_sysroot" ]	&& mb_cflags_sysroot=$mb_default_cflags_sysroot
551024
	[ -z "$mb_cflags_os" ]		&& mb_cflags_os=$mb_default_cflags_os
551024
	[ -z "$mb_cflags_site" ]	&& mb_cflags_site=$mb_default_cflags_site
7b83a9
	[ -z "$mb_cflags_path" ]	&& mb_cflags_path=$mb_default_cflags_path
551024
	[ -z "$mb_cflags_strict" ]	&& mb_cflags_strict=$mb_default_cflags_strict
551024
	[ -z "$mb_cflags_util" ]	&& mb_cflags_util=$mb_default_cflags_util
8da1ad
	[ -z "$mb_cflags_last" ]	&& mb_cflags_last=$mb_default_cflags_last
8da1ad
	[ -z "$mb_cflags_once" ]	&& mb_cflags_once=$mb_default_cflags_once
7b83a9
7b83a9
	[ -z "$mb_ldflags_debug" ]	&& mb_ldflags_debug=$mb_default_ldflags_debug
7b83a9
	[ -z "$mb_ldflags_common" ]	&& mb_ldflags_common=$mb_default_ldflags_common
7b83a9
	[ -z "$mb_ldflags_cmdline" ]	&& mb_ldflags_cmdline=$mb_default_ldflags_cmdline
7b83a9
	[ -z "$mb_ldflags_config" ]	&& mb_ldflags_config=$mb_default_ldflags_config
7b83a9
	[ -z "$mb_ldflags_sysroot" ]	&& mb_ldflags_sysroot=$mb_default_ldflags_sysroot
7b83a9
	[ -z "$mb_ldflags_path" ]	&& mb_ldflags_path=$mb_default_ldflags_path
551024
	[ -z "$mb_ldflags_strict" ]	&& mb_ldflags_strict=$mb_default_ldflags_strict
551024
	[ -z "$mb_ldflags_util" ]	&& mb_ldflags_util=$mb_default_ldflags_util
8da1ad
	[ -z "$mb_ldflags_last" ]	&& mb_ldflags_last=$mb_default_ldflags_last
8da1ad
	[ -z "$mb_ldflags_once" ]	&& mb_ldflags_once=$mb_default_ldflags_once
7b83a9
7b83a9
	[ -z "$mb_pe_subsystem" ]	&& mb_pe_subsystem=$mb_default_pe_subsystem
7b83a9
	[ -z "$mb_pe_image_base" ]	&& mb_pe_image_base=$mb_default_pe_image_base
7b83a9
	[ -z "$mb_pe_config_defs" ]	&& mb_pe_config_defs=$mb_default_pe_config_defs
7b83a9
7b83a9
	[ -z "$mb_elf_eh_frame" ]	&& mb_elf_eh_frame=$mb_default_elf_eh_frame
7b83a9
	[ -z "$mb_elf_hash_style" ]	&& mb_elf_hash_style=$mb_default_elf_hash_style
7b83a9
	[ -z "$mb_elf_config_defs" ]	&& mb_elf_config_defs=$mb_default_elf_config_defs
7b83a9
551024
	# config
551024
	[ -z "$mb_all_static" ]		&& mb_all_static='no'
551024
	[ -z "$mb_all_shared" ]		&& mb_all_shared='no'
551024
	[ -z "$mb_disable_frontend" ]	&& mb_disable_frontend='no'
551024
	[ -z "$mb_disable_static" ]	&& mb_disable_static='no'
551024
	[ -z "$mb_disable_shared" ]	&& mb_disable_shared='no'
551024
7b83a9
	# host/target
7b83a9
	[ -z "$mb_host" ] 		&& mb_host=$mb_target
201b9a
	[ -z "$mb_target" ] 		&& mb_target=$mb_host
7b83a9
7b83a9
	# sysroot
5daef8
	if [ -n "$mb_sysroot" ]; then
5daef8
		if [ -z "$mb_cflags_sysroot" ]; then
7b83a9
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
7b83a9
		fi
7b83a9
5daef8
		if [ -z "$mb_ldflags_sysroot" ]; then
234d08
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
7b83a9
		fi
7b83a9
	fi
7b83a9
7b83a9
	# debug
5daef8
	if [ "$mb_debug" = yes ]; then
5daef8
		if [ -z "$mb_cflags_debug" ]; then
7b83a9
			mb_cflags_debug='-g3 -O0'
7b83a9
		fi
7b83a9
	fi
7b83a9
f97c34
	# compiler
5daef8
	if [ -n "$mb_compiler" ]; then
5daef8
		if [ -z "$mb_native_cc" ]; then
f97c34
			mb_native_cc=$mb_compiler
7b83a9
		fi
7b83a9
	fi
651d7b
651d7b
	# toolchain
5daef8
	if [ -z "$mb_toolchain" ]; then
651d7b
		mb_toolchain='binutils'
651d7b
	fi
975775
975775
	# fallback host recipe
5daef8
	if [ -n "$mb_host" ]; then
975775
		if ! [ -f $mb_project_dir/sysinfo/host/$mb_host.mk ]; then
975775
			if [ -z "$mb_cross_compile" ]; then
975775
				mb_cross_compile=$mb_host-
975775
			fi
975775
975775
			mb_host='any-host';
975775
		fi
975775
	fi
4b41f9
4b41f9
	# fallback compiler recipe
4b41f9
	if [ -n "$mb_compiler" ]; then
4b41f9
		if ! [ -f $mb_project_dir/sysinfo/compiler/$mb_compiler.mk ]; then
4b41f9
			mb_compiler='any-compiler'
4b41f9
		fi
4b41f9
	fi
7b83a9
}
7b83a9
7b83a9
7b83a9
native_defaults()
7b83a9
{
7b83a9
	# CC (when set, must be valid)
5daef8
	if [ -n "$CC" ]; then
7b83a9
		$CC -dM -E - < /dev/null > /dev/null || exit 2
7b83a9
	fi
7b83a9
f97c34
	# compiler
7b83a9
	[ -z "$mb_native_cc" ] && mb_native_cc=$CC
7b83a9
	[ -z "$mb_native_cc" ] && mb_native_cc='cc'
7b83a9
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
7b83a9
7b83a9
	[ -z "$mb_native_cc" ] && mb_native_cc='gcc'
7b83a9
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
7b83a9
7b83a9
	[ -z "$mb_native_cc" ] && mb_native_cc='clang'
7b83a9
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
7b83a9
4977e2
	[ -z "$mb_native_cc" ] && mb_native_cc='cparser'
4977e2
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
4977e2
5daef8
	if [ -z "$mb_native_cc" ]; then
bf2306
		echo "configure: info: could not find a working native compiler."
bf2306
		mb_native_cc='false'
7b83a9
	fi
7b83a9
5daef8
	if [ -z "$mb_compiler" ]; then
6ceb24
		$mb_native_cc -dM -E - < /dev/null | grep -q '__clang__' && mb_compiler='clang'
7b83a9
	fi
7b83a9
5daef8
	if [ -z "$mb_compiler" ]; then
6ceb24
		$mb_native_cc -dM -E - < /dev/null | grep -q '__GCC' && mb_compiler='gcc'
7b83a9
	fi
7b83a9
5daef8
	if [ -z "$mb_compiler" ]; then
6ceb24
		$mb_native_cc -dM -E - < /dev/null | grep -q "^gcc" && mb_compiler='gcc'
e606ed
	fi
e606ed
e606ed
	if [ -z "$mb_compiler" ]; then
6ceb24
		$mb_native_cc -dM -E - < /dev/null | grep -q '__CPARSER__' && mb_compiler='cparser'
4977e2
	fi
4977e2
5daef8
	if [ -z "$mb_compiler" ]; then
bf2306
		echo "configure: info: could not identify the native compiler."
bf2306
		mb_compiler='any-compiler'
7b83a9
	fi
7b83a9
7b83a9
7b83a9
	# host
5daef8
	if [ -z "$mb_host" ]; then
7b83a9
		mb_host='native'
7b83a9
	fi
7b83a9
7b83a9
13a45a
	# target
5daef8
	if [ -z "$mb_target" ]; then
13a45a
		mb_target='native'
13a45a
	fi
13a45a
13a45a
7b83a9
	# os
b9ddbf
	if [ -z "$mb_native_os" ]; then
b9ddbf
		mb_native_os=`uname | tr '[:upper:]' '[:lower:]'`
b9ddbf
	fi
7b83a9
7b83a9
	mb_native_os_sizeof_pointer=`$mb_native_cc -dM -E - < /dev/null \
3a41d7
			| awk '$2 == "__SIZEOF_POINTER__" { print $3 }'`
7b83a9
7f9f58
	mb_native_os_bits=$((8 * ${mb_native_os_sizeof_pointer:-0}))
7b83a9
7b83a9
	if [ $mb_native_os_bits = 32 ]; then
7b83a9
		mb_native_os_underscore='_'
7b83a9
	else
7b83a9
		mb_native_os_underscore=''
7b83a9
	fi
7b83a9
5daef8
	if [ -z "$mb_native_os_sizeof_pointer" ]; then
f00768
		warning_msg "config error: could not determine size of pointer on native system."
7b83a9
	fi
7b83a9
5e09a1
	# grumpily support crooked uname output
5e09a1
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
5e09a1
		mb_native_os=`echo $mb_native_os | cut -d'_' -f1`
5e09a1
	fi
5e09a1
551024
	# fallback os recipe
551024
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
551024
		mb_native_os='any-os';
551024
	fi
7b83a9
}
7b83a9
7b83a9
7b83a9
cross_defaults()
7b83a9
{
5daef8
	if [ -z "$mb_cross_compile" ] && [ "$mb_host" != native ]; then
7b83a9
		mb_cross_compile=$mb_host'-'
7b83a9
	fi
7b83a9
}
7b83a9
7b83a9
551024
config_flags()
551024
{
551024
	mb_ldflags_tmp=" $mb_ldflags "
551024
	mb_ldflags_libs=`echo "$mb_ldflags_tmp" | sed 's/ -static / /g'`
551024
551024
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
551024
		mb_ldflags="$mb_ldflags_libs"
551024
		mb_ldflags_util="$mb_ldflags_util -static"
551024
	fi
551024
551024
	# ccstrict
551024
	if [ "$mb_ccstrict" = 'yes' ]; then
551024
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
551024
	fi
551024
551024
	# ldstrict
551024
	if [ "$mb_ldstrict" = 'yes' ]; then
551024
		mb_ldflags_strict='-Wl,--no-undefined'
551024
	fi
551024
}
551024
551024
7b83a9
config_copy()
7b83a9
{
7b83a9
	sed 		-e 's^@package@^'"$mb_package"'^g' 				\
551024
			-e 's^@nickname@^'"$mb_nickname"'^g'				\
7b83a9
			-e 's^@project_dir@^'"$mb_project_dir"'^g'			\
44e93e
			-e 's^@source_dir@^'"$mb_source_dir"'^g'			\
fa9462
			-e 's^@git_reference_index@^'"$mb_git_reference_index"'^g'	\
551024
			-e 's^@custom_install_headers@^'"$mb_custom_install_headers"'^g' \
551024
			-e 's^@avoid_version@^'"$mb_avoid_version"'^g'			\
7b83a9
											\
7b83a9
			-e 's^@build@^'"$mb_build"'^g'					\
7b83a9
			-e 's^@host@^'"$mb_host"'^g'					\
7b83a9
			-e 's^@target@^'"$mb_target"'^g'				\
7b83a9
			-e 's^@arch@^'"$mb_arch"'^g'					\
f97c34
			-e 's^@compiler@^'"$mb_compiler"'^g'				\
651d7b
			-e 's^@toolchain@^'"$mb_toolchain"'^g'				\
7b83a9
			-e 's^@sysroot@^'"$mb_sysroot"'^g'				\
7b83a9
			-e 's^@cross_compile@^'"$mb_cross_compile"'^g'			\
7b83a9
			-e 's^@shell@^'"$mb_shell"'^g'					\
7b83a9
											\
7b83a9
			-e 's^@cflags@^'"$mb_cflags"'^g'				\
7b83a9
			-e 's^@cflags_debug@^'"$mb_cflags_debug"'^g'			\
7b83a9
			-e 's^@cflags_common@^'"$mb_cflags_common"'^g'			\
7b83a9
			-e 's^@cflags_cmdline@^'"$mb_cflags $mb_cflags_cmdline"'^g'	\
7b83a9
			-e 's^@cflags_config@^'"$mb_cflags_config"'^g'			\
7b83a9
			-e 's^@cflags_sysroot@^'"$mb_cflags_sysroot"'^g'		\
551024
			-e 's^@cflags_os@^'"$mb_cflags_os"'^g'				\
551024
			-e 's^@cflags_site@^'"$mb_cflags_site"'^g'			\
7b83a9
			-e 's^@cflags_path@^'"$mb_cflags_path"'^g'			\
551024
			-e 's^@cflags_strict@^'"$mb_cflags_strict"'^g'			\
551024
			-e 's^@cflags_util@^'"$mb_cflags_util"'^g'			\
8da1ad
			-e 's^@cflags_last@^'"$mb_cflags_last"'^g'			\
8da1ad
			-e 's^@cflags_once@^'"$mb_cflags_once"'^g'			\
7b83a9
											\
7b83a9
			-e 's^@ldflags@^'"$mb_ldflags"'^g'				\
7b83a9
			-e 's^@ldflags_debug@^'"$mb_ldflags_debug"'^g'			\
7b83a9
			-e 's^@ldflags_common@^'"$mb_ldflags_common"'^g'		\
7b83a9
			-e 's^@ldflags_cmdline@^'"$mb_ldflags $mb_ldflags_cmdline"'^g'	\
7b83a9
			-e 's^@ldflags_config@^'"$mb_ldflags_config"'^g'		\
7b83a9
			-e 's^@ldflags_sysroot@^'"$mb_ldflags_sysroot"'^g'		\
7b83a9
			-e 's^@ldflags_path@^'"$mb_ldflags_path"'^g'			\
551024
			-e 's^@ldflags_strict@^'"$mb_ldflags_strict"'^g'		\
551024
			-e 's^@ldflags_util@^'"$mb_ldflags_util"'^g'			\
8da1ad
			-e 's^@ldflags_last@^'"$mb_ldflags_last"'^g'			\
8da1ad
			-e 's^@ldflags_once@^'"$mb_ldflags_once"'^g'			\
7b83a9
											\
7b83a9
			-e 's^@pe_subsystem@^'"$mb_pe_subsystem"'^g'			\
7b83a9
			-e 's^@pe_image\_base@^'"$mb_pe_image_base"'^g'			\
7b83a9
			-e 's^@pe_config\_defs@^'"$mb_pe_config_defs"'^g'		\
7b83a9
											\
7b83a9
			-e 's^@elf_eh\_frame@^'"$mb_elf_eh_frame"'^g'			\
7b83a9
			-e 's^@elf_hash\_style@^'"$mb_elf_hash_style"'^g'		\
7b83a9
			-e 's^@elf_config\_defs@^'"$mb_elf_config_defs"'^g'		\
7b83a9
											\
7b83a9
			-e 's^@prefix@^'"$mb_prefix"'^g'				\
2816af
			-e 's^@exec_prefix@^'"$mb_exec_prefix"'^g'			\
7b83a9
			-e 's^@bindir@^'"$mb_bindir"'^g'				\
71a82d
			-e 's^@sbindir@^'"$mb_sbindir"'^g'				\
7b83a9
			-e 's^@libdir@^'"$mb_libdir"'^g'				\
7b83a9
			-e 's^@includedir@^'"$mb_includedir"'^g'			\
a719b2
			-e 's^@oldincludedir@^'"$mb_oldincludedir"'^g'			\
7b83a9
			-e 's^@mandir@^'"$mb_mandir"'^g'				\
7b83a9
			-e 's^@docdir@^'"$mb_docdir"'^g'				\
7b83a9
			-e 's^@libexecdir@^'"$mb_libexecdir"'^g'			\
7b83a9
											\
a719b2
			-e 's^@sysconfdir@^'"$mb_sysconfdir"'^g'			\
a719b2
			-e 's^@sharedstatedir@^'"$mb_sharedstatedir"'^g'		\
a719b2
			-e 's^@localstatedir@^'"$mb_localstatedir"'^g'			\
a719b2
			-e 's^@runstatedir@^'"$mb_runstatedir"'^g'			\
a719b2
			-e 's^@datarootdir@^'"$mb_datarootdir"'^g'			\
a719b2
			-e 's^@datadir@^'"$mb_datadir"'^g'				\
a719b2
			-e 's^@infodir@^'"$mb_infodir"'^g'				\
a719b2
			-e 's^@localedir@^'"$mb_localedir"'^g'				\
a719b2
			-e 's^@htmldir@^'"$mb_htmldir"'^g'				\
a719b2
			-e 's^@dvidir@^'"$mb_dvidir"'^g'				\
a719b2
			-e 's^@pdfdir@^'"$mb_pdfdir"'^g'				\
a719b2
			-e 's^@psdir@^'"$mb_psdir"'^g'					\
a719b2
											\
7b83a9
			-e 's^@native_cc@^'"$mb_native_cc"'^g'				\
7b83a9
			-e 's^@native_os@^'"$mb_native_os"'^g'				\
551024
			-e 's^@native_os_bits@^'"$mb_native_os_bits"'^g'		\
7b83a9
			-e 's^@native_os_underscore@^'"$mb_native_os_underscore"'^g'	\
2318d6
											\
2318d6
			-e 's^@user_cc@^'"$mb_user_cc"'^g'				\
2318d6
			-e 's^@user_cpp@^'"$mb_user_cpp"'^g'				\
2318d6
			-e 's^@user_cxx@^'"$mb_user_cxx"'^g'				\
551024
											\
551024
			-e 's^@all_static@^'"$mb_all_static"'^g'			\
551024
			-e 's^@all_shared@^'"$mb_all_shared"'^g'			\
551024
			-e 's^@disable_frontend@^'"$mb_disable_frontend"'^g'		\
551024
			-e 's^@disable_static@^'"$mb_disable_static"'^g'		\
551024
			-e 's^@disable_shared@^'"$mb_disable_shared"'^g'		\
f6d035
		$mb_project_dir/Makefile.in > $mb_pwd/Makefile.tmp || exit 2
f6d035
f6d035
	if [ -z "$mb_cchost" ]; then
f6d035
		if [ "$mb_host" = 'native' ]; then
f6d035
			mb_cchost=`make -s -f $mb_pwd/Makefile.tmp cchost`
f6d035
		else
f6d035
			mb_cchost=$mb_host
f6d035
		fi
f6d035
	fi
f6d035
f6d035
	sed -e 's^@cchost@^'"$mb_cchost"'^g' $mb_pwd/Makefile.tmp \
f6d035
	  > $mb_pwd/Makefile.host                  || exit 2
f6d035
f6d035
	rm  $mb_pwd/Makefile.tmp                   || exit 2
f6d035
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile || exit 2
7b83a9
}
7b83a9
7b83a9
551024
config_support()
551024
{
551024
	[ "$mb_disable_shared" = 'yes' ] && return 0
551024
551024
	mbt_cc=`make .display-cc`
551024
	mbt_cflags=`make .display-cflags`
551024
	mbt_source='int foo(int x){return ++x;}'
551024
	mbt_result='no'
551024
551024
	rm -f a.out
551024
	echo "$mbt_source" | "$mbt_cc" -shared -o a.out -xc -
551024
	stat a.out >/dev/null 2>&1 && mbt_result='yes'
551024
	rm -f a.out
551024
551024
	if [ "$mbt_result" = 'no' ]; then
551024
		mb_disable_shared='yes'
551024
		config_copy
551024
	fi
551024
}
551024
551024
dedbf5
config_host()
dedbf5
{
e98fba
	make -s host.tag && return 0
dedbf5
dedbf5
	error_msg "configure was able to generate a Makefile for the selected host,"
f97c34
	error_msg "however the host-targeting compiler was found to be missing"
dedbf5
	error_msg "at least one of the required headers or features."
dedbf5
	exit 2
dedbf5
}
dedbf5
7b83a9
bf13ab
config_status()
bf13ab
{
bf13ab
	printf "\n\n"
bf13ab
	make .display
bf13ab
	printf "\nconfiguration completed successfully.\n\n"
bf13ab
}
bf13ab
7b83a9
# one: init
7b83a9
init_vars
7b83a9
verify_build_directory
7b83a9
7b83a9
7b83a9
# two: args
7b83a9
for arg ; do
7b83a9
	case "$arg" in
7b83a9
		--help)	usage
7b83a9
			;;
7b83a9
7b83a9
		# dirs
7b83a9
		--prefix=*)
587ad1
			mb_prefix_set=yes
7b83a9
			mb_prefix=${arg#*=}
7b83a9
			;;
2816af
		--exec-prefix=*)
587ad1
			mb_exec_prefix_set=yes
2816af
			mb_exec_prefix=${arg#*=}
2816af
			;;
7b83a9
		--bindir=*)
7b83a9
			mb_bindir=${arg#*=}
7b83a9
			;;
71a82d
		--sbindir=*)
71a82d
			mb_sbindir=${arg#*=}
71a82d
			;;
7b83a9
		--libdir=*)
7b83a9
			mb_libdir=${arg#*=}
7b83a9
			;;
7b83a9
		--includedir=*)
7b83a9
			mb_includedir=${arg#*=}
7b83a9
			;;
a719b2
		--oldincludedir=*)
a719b2
			mb_oldincludedir=${arg#*=}
a719b2
			;;
7b83a9
		--mandir=*)
7b83a9
			mb_mandir=${arg#*=}
7b83a9
			;;
7b83a9
		--libexecdir=*)
7b83a9
			mb_libexecdir=${arg#*=}
7b83a9
			;;
7b83a9
7b83a9
a719b2
		--sysconfdir=*)
a719b2
			mb_sysconfdir=${arg#*=}
a719b2
			;;
a719b2
		--sharedstatedir=*)
a719b2
			mb_sharedstatedir=${arg#*=}
a719b2
			;;
a719b2
		--localstatedir=*)
a719b2
			mb_localstatedir=${arg#*=}
a719b2
			;;
a719b2
		--runstatedir=*)
a719b2
			mb_runstatedir=${arg#*=}
a719b2
			;;
a719b2
		--datarootdir=*)
a719b2
			mb_datarootdir=${arg#*=}
a719b2
			;;
a719b2
		--datadir=*)
a719b2
			mb_datadir=${arg#*=}
a719b2
			;;
a719b2
		--infodir=*)
a719b2
			mb_infodir=${arg#*=}
a719b2
			;;
a719b2
		--localedir=*)
a719b2
			mb_localedir=${arg#*=}
a719b2
			;;
a719b2
		--htmldir=*)
a719b2
			mb_htmldir=${arg#*=}
a719b2
			;;
a719b2
		--dvidir=*)
a719b2
			mb_dvidir=${arg#*=}
a719b2
			;;
a719b2
		--pdfdir=*)
a719b2
			mb_pdfdir=${arg#*=}
a719b2
			;;
a719b2
		--psdir=*)
a719b2
			mb_psdir=${arg#*=}
a719b2
			;;
a719b2
a719b2
7b83a9
		# build
7b83a9
		--build=*)
7b83a9
			mb_build=${arg#*=}
7b83a9
			;;
7b83a9
		--host=*)
7b83a9
			mb_host=${arg#*=}
7b83a9
			;;
f6d035
		--cchost=*)
f6d035
			mb_cchost=${arg#*=}
f6d035
			;;
7b83a9
		--target=*)
7b83a9
			mb_target=${arg#*=}
7b83a9
			;;
7b83a9
		--arch=*)
7b83a9
			mb_arch=${arg#*=}
7b83a9
			;;
f97c34
		--compiler=*)
f97c34
			mb_compiler=${arg#*=}
7b83a9
			;;
651d7b
		--toolchain=*)
651d7b
			mb_toolchain=${arg#*=}
651d7b
			;;
7b83a9
		--sysroot=*)
7b83a9
			mb_sysroot=${arg#*=}
7b83a9
			;;
7b83a9
		--cross-compile=*)
7b83a9
			mb_cross_compile=${arg#*=}
7b83a9
			;;
7b83a9
		--shell=*)
7b83a9
			mb_shell=${arg#*=}
7b83a9
			;;
7b83a9
		--debug)
7b83a9
			mb_debug='yes'
7b83a9
			;;
551024
551024
		# config
551024
		--all-static)
551024
			mb_all_static='yes'
551024
			;;
551024
		--all-shared)
551024
			mb_all_shared='yes'
551024
			;;
551024
		--disable-frontend)
551024
			mb_disable_frontend='yes'
551024
			;;
551024
		--disable-app)
551024
			mb_disable_frontend='yes'
551024
			;;
551024
		--enable-frontend)
551024
			mb_disable_frontend='no'
551024
			;;
551024
		--enable-app)
551024
			mb_disable_frontend='no'
551024
			;;
551024
		--disable-static)
551024
			mb_disable_static='yes'
551024
			;;
551024
		--disable-shared)
551024
			mb_disable_shared='yes'
551024
			;;
551024
		--enable-static)
551024
			mb_disable_static='no'
551024
			;;
551024
		--enable-shared)
551024
			mb_disable_shared='no'
551024
			;;
551024
551024
		# convenience
551024
		--strict)
551024
			mb_ccstrict='yes'
551024
			mb_ldstrict='yes'
551024
			;;
551024
		--ccstrict)
551024
			mb_ccstrict='yes'
551024
			;;
551024
		--ldstrict)
551024
			mb_ldstrict='yes'
551024
			;;
551024
551024
		# project
551024
		--nickname=*)
551024
			mb_nickname=${arg#*=}
551024
			;;
fd1008
		--program-prefix=*)
fd1008
			mb_program_prefix=${arg#*=}
fd1008
			;;
551024
		--avoid-version)
551024
			mb_avoid_version='yes'
551024
			;;
44e93e
		--source-dir=*)
44e93e
			mb_source_dir=${arg#*=}
44e93e
			;;
551024
567637
		# compatibility
567637
		--enable-dependency-tracking)
567637
			;;
567637
		--disable-dependency-tracking)
567637
			;;
567637
7b83a9
		*)
7b83a9
			error_msg ${arg#}: "unsupported config argument."
7b83a9
			exit 2
7b83a9
			;;
7b83a9
	esac
7b83a9
done
7b83a9
7b83a9
7b83a9
44e93e
# three: validation
44e93e
verify_source_directory
44e93e
fd1008
if ! [ -z "$mb_program_prefix" ]; then
fd1008
	error_msg "--program-prefix is not yet fully support (must be null)."
fd1008
fi
fd1008
44e93e
44e93e
44e93e
# four: defaults
7b83a9
common_defaults
7b83a9
native_defaults
7b83a9
cross_defaults
7b83a9
7b83a9
7b83a9
44e93e
# five: config
551024
config_flags
7b83a9
config_copy
551024
config_support
dedbf5
config_host
bf13ab
config_status
7b83a9
7b83a9
7b83a9
# all done
7b83a9
exit 0