orbea / cross / slibtool

Forked from cross/slibtool 3 years ago
Clone

Blame configure

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