Blame configure

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