Blame configure

f46039
#!/bin/sh
f46039
# we are no longer lazy.
f46039
f46039
# this script respects both CFLAGS and CFLAGS_CMDLINE,
f46039
# as well as both LDFLAGS and LDFLAGS_CMDLINE, however
f46039
# the latter variable of each pair should be preferred.
f46039
f46039
usage()
f46039
{
4aae4b
	cat "$mb_project_dir"/config.usage
3d5a30
3d5a30
	if [ $mb_use_custom_cfgdefs = 'yes' ]; then
3d5a30
		printf '\n\n%s%s\n' \
3d5a30
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
3d5a30
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
3d5a30
3d5a30
		printf '%s%s\n' \
3d5a30
			"| Listed above are configure's common switches " \
3d5a30
			"and environment variables.     |"
3d5a30
3d5a30
		printf '%s%s\n' \
3d5a30
			"| Found below are project-specific variables " \
3d5a30
			"and other customization options. |"
3d5a30
3d5a30
		printf '%s%s\n\n\n' \
3d5a30
			" ___________________________________________" \
3d5a30
			"__________________________________"
3d5a30
3d5a30
		cat "$mb_project_dir"/project/config/cfgdefs.usage
3d5a30
	fi
3d5a30
3d5a30
	exit 0
f46039
}
f46039
f46039
error_msg()
f46039
{
316443
	echo "$@" >&2
f46039
}
f46039
a96414
warning_msg()
a96414
{
a96414
	echo "$@" >&2
a96414
}
a96414
f46039
f46039
init_vars()
f46039
{
a1d114
	mb_project_dir=$(cd "$(dirname $0)" ; pwd)
f46039
	mb_pwd=`pwd`
f46039
8574ac
	mb_custom_cfgdefs_args=''
8574ac
	mb_custom_cfgdefs_space=''
8574ac
f7f42e
	if [ -z "$mb_config" ]; then
f46039
		. $mb_project_dir/config.project || exit 2
f46039
	else
f46039
		. "$mb_config" || exit 2
f46039
	fi
f46039
78fd02
	# project
78fd02
	mb_nickname=$NICKNAME
11deae
	mb_source_dir=$SOURCE_DIR
78fd02
f46039
	# dirs
f46039
	mb_prefix=$PREFIX
b6d1b5
	mb_exec_prefix=$EXEC_PREFIX
f46039
	mb_bindir=$BINDIR
cb6e77
	mb_sbindir=$SBINDIR
f46039
	mb_libdir=$LIBDIR
f46039
	mb_includedir=$INCLUDEDIR
227174
	mb_oldincludedir=$OLDINCLUDEDIR
f46039
	mb_mandir=$MANDIR
f46039
	mb_docdir=$DOCDIR
f46039
	mb_libexecdir=$LIBEXECDIR
f46039
227174
	mb_sysconfdir=$SYSCONFDIR
227174
	mb_sharedstatedir=$SHAREDSTATEDIR
227174
	mb_localstatedir=$LOCALSTATEDIR
227174
	mb_runstatedir=$RUNSTATEDIR
227174
	mb_datarootdir=$DATAROOTDIR
227174
	mb_datadir=$DATADIR
227174
	mb_infodir=$INFODIR
227174
	mb_localedir=$LOCALEDIR
227174
	mb_htmldir=$HTMLDIR
227174
	mb_dvidir=$DVIDIR
227174
	mb_pdfdir=$PDFDIR
227174
	mb_psdir=$PSDIR
227174
f46039
f46039
	# build
f46039
	mb_build=$BUILD
f46039
	mb_host=$HOST
c2225d
	mb_cchost=$CCHOST
95d491
	mb_cfghost=$CFGHOST
f46039
	mb_target=$TARGET
f46039
	mb_arch=$ARCH
e83fbe
	mb_compiler=$COMPILER
46d732
	mb_toolchain=$TOOLCHAIN
f46039
	mb_sysroot=$SYSROOT
f46039
	mb_cross_compile=$CROSS_COMPILE
f46039
	mb_shell=$SHELL
f46039
f46039
	# switches
f46039
	mb_cflags=$CFLAGS
f46039
	mb_cflags_debug=$CFLAGS_DEBUG
f46039
	mb_cflags_common=$CFLAGS_COMMON
f46039
	mb_cflags_cmdline=$CFLAGS_CMDLINE
f46039
	mb_cflags_config=$CFLAGS_CONFIG
f46039
	mb_cflags_sysroot=$CFLAGS_SYSROOT
e6d235
	mb_cflags_os=$CFLAGS_OS
e6d235
	mb_cflags_site=$CFLAGS_SITE
f46039
	mb_cflags_path=$CFLAGS_PATH
616138
	mb_cflags_strict=$CFLAGS_STRICT
a5b647
	mb_cflags_util=$CFLAGS_UTIL
1ec01b
	mb_cflags_last=$CFLAGS_LAST
1ec01b
	mb_cflags_once=$CFLAGS_ONCE
f46039
f46039
	mb_ldflags=$LDFLAGS
f46039
	mb_ldflags_debug=$LDFLAGS_DEBUG
f46039
	mb_ldflags_common=$LDFLAGS_COMMON
f46039
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
f46039
	mb_ldflags_config=$LDFLAGS_CONFIG
f46039
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
f46039
	mb_ldflags_path=$LDFLAGS_PATH
616138
	mb_ldflags_strict=$LDFLAGS_STRICT
a5b647
	mb_ldflags_util=$LDFLAGS_UTIL
1ec01b
	mb_ldflags_last=$LDFLAGS_LAST
1ec01b
	mb_ldflags_once=$LDFLAGS_ONCE
f46039
f46039
	mb_pe_subsystem=$PE_SUBSYSTEM
f46039
	mb_pe_image_base=$PE_IMAGE_BASE
f46039
	mb_pe_config_defs=$PE_CONFIG_DEFS
f46039
f46039
	mb_elf_eh_frame=$ELF_EH_FRAME
f46039
	mb_elf_hash_style=$ELF_HASH_STYLE
f46039
	mb_elf_config_defs=$ELF_CONFIG_DEFS
f46039
f46039
	# overrides
f46039
	mb_native_cc=$NATIVE_CC
63d3bb
	mb_native_cc_host=$NATIVE_CC_HOST
63d3bb
f46039
	mb_native_os=$NATIVE_OS
f46039
	mb_native_os_bits=$NATIVE_OS_BITS
f46039
	mb_native_os_underscore=$NATIVE_OS_UNDERSCORE
f46039
f46039
	mb_user_cc=$CC
f46039
	mb_user_cpp=$CPP
f46039
	mb_user_cxx=$CXX
f46039
}
f46039
f46039
f46039
verify_build_directory()
f46039
{
f7f42e
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
f7f42e
		if [ "$mb_require_out_of_tree" = yes ]; then
f46039
			error_msg "$mb_package: out-of-tree builds are required."
f46039
			error_msg "please invoke configure again from a clean build directory."
f46039
			exit 2
f46039
		else
f46039
			mb_project_dir='.'
f46039
		fi
f46039
	fi
f46039
}
f46039
f46039
11deae
verify_source_directory()
11deae
{
11deae
	if [ -z "$mb_source_dir" ]; then
11deae
		if [ "$mb_require_source_dir" = yes ]; then
11deae
			error_msg "$mb_package: specifying an external source directory is required."
11deae
			error_msg "you can set the source directory either via --source-dir=<path>,"
11deae
			error_msg "or by setting the SOURCE_DIR variable."
11deae
			exit 2
11deae
		fi
11deae
	fi
11deae
}
11deae
11deae
f46039
common_defaults()
f46039
{
11deae
	# git
11deae
	if [ -n "$mb_source_dir" ]; then
11deae
		if [ -d "$mb_source_dir/.git" ]; then
bb38c3
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
11deae
		fi
11deae
	elif [ -d "$mb_project_dir/.git" ]; then
bb38c3
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
11deae
	fi
11deae
78fd02
	# project
78fd02
	[ -z "$mb_nickname" ] 		&& mb_nickname=$mb_package
11deae
	[ -z "$mb_source_dir" ] 	&& mb_source_dir=$mb_project_dir
6c7287
	[ -z "$mb_avoid_version" ] 	&& mb_avoid_version='no'
78fd02
32da4e
	# pkgconfig
32da4e
	[ -z "$mb_pkgname" ]		&& mb_pkgname="$mb_default_pkgname"
32da4e
	[ -z "$mb_pkgdesc" ]		&& mb_pkgdesc="$mb_default_pkgdesc"
32da4e
	[ -z "$mb_pkgusrc" ]		&& mb_pkgusrc="$mb_default_pkgusrc"
32da4e
	[ -z "$mb_pkgrepo" ]		&& mb_pkgrepo="$mb_default_pkgrepo"
32da4e
	[ -z "$mb_pkgpsrc" ]		&& mb_pkgpsrc="$mb_default_pkgpsrc"
32da4e
	[ -z "$mb_pkgdurl" ]		&& mb_pkgdurl="$mb_default_pkgdurl"
32da4e
	[ -z "$mb_pkgdefs" ]		&& mb_pkgdefs="$mb_default_pkgdefs"
32da4e
	[ -z "$mb_pkglibs" ]		&& mb_pkglibs="$mb_default_pkglibs"
32da4e
f46039
	# dirs
6162f0
	[ -z "$mb_prefix" ] 		&& [ -z "$mb_prefix_set" ] \
6162f0
					&& mb_prefix='/usr/local'
6162f0
6162f0
	[ -z "$mb_exec_prefix" ] 	&& [ -z "$mb_exec_prefix_set" ]	\
6162f0
					&& mb_exec_prefix=$mb_prefix
6162f0
117361
	[ -z "$mb_bindir" ] 		&& [ -z "$mb_bindir_set" ] \
117361
					&& [ -z "$mb_bindir_basename" ] \
117361
					&& mb_bindir=$mb_exec_prefix/bin
117361
117361
	[ -z "$mb_bindir" ] 		&& [ -z "$mb_bindir_set" ] \
117361
					&& mb_bindir=$mb_exec_prefix/$mb_bindir_basename
117361
cb6e77
	[ -z "$mb_sbindir" ] 		&& mb_sbindir=$mb_exec_prefix/sbin
93cc8f
	[ -z "$mb_libdir" ] 		&& mb_libdir=$mb_exec_prefix/lib
93cc8f
	[ -z "$mb_includedir" ]		&& mb_includedir=$mb_prefix/include
227174
	[ -z "$mb_oldincludedir" ]	&& mb_oldincludedir=$mb_prefix/include
93cc8f
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
93cc8f
	[ -z "$mb_mandir" ] 		&& mb_mandir=$mb_datarootdir/man
93cc8f
	[ -z "$mb_docdir" ] 		&& mb_docdir=$mb_datarootdir/doc
93cc8f
	[ -z "$mb_libexecdir" ]		&& mb_libexecdir=$mb_exec_prefix/libexec
f46039
227174
	[ -z "$mb_sysconfdir" ] 	&& mb_sysconfdir=$mb_exec_prefix/etc
227174
	[ -z "$mb_sharedstatedir" ] 	&& mb_sharedstatedir=$mb_prefix/com
227174
	[ -z "$mb_localstatedir" ] 	&& mb_localstatedir=$mb_prefix/var
227174
	[ -z "$mb_runstatedir" ] 	&& mb_runstatedir=$mb_localstatedir/run
227174
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
227174
	[ -z "$mb_datadir" ] 		&& mb_datadir=$mb_datarootdir
227174
	[ -z "$mb_infodir" ] 		&& mb_infodir=$mb_datarootdir/info
227174
	[ -z "$mb_localedir" ] 		&& mb_localedir=$mb_datarootdir/locale
227174
	[ -z "$mb_htmldir" ] 		&& mb_htmldir=$mb_docdir
227174
	[ -z "$mb_dvidir" ] 		&& mb_dvidir=$mb_docdir
227174
	[ -z "$mb_pdfdir" ] 		&& mb_pdfdir=$mb_docdir
227174
	[ -z "$mb_psdir" ] 		&& mb_psdir=$mb_docdir
227174
227174
f46039
	# build
f46039
	[ -z "$mb_build" ] 		&& mb_build=$mb_default_build
f46039
	[ -z "$mb_host" ] 		&& mb_host=$mb_default_host
c2225d
	[ -z "$mb_cchost" ] 		&& mb_cchost=$mb_default_cchost
95d491
	[ -z "$mb_cfghost" ] 		&& mb_cfghost=$mb_default_cfghost
f46039
	[ -z "$mb_target" ] 		&& mb_target=$mb_default_target
f46039
	[ -z "$mb_arch" ] 		&& mb_arch=$mb_default_arch
e83fbe
	[ -z "$mb_compiler" ] 		&& mb_compiler=$mb_default_compiler
46d732
	[ -z "$mb_toolchain" ] 		&& mb_toolchain=$mb_default_toolchain
f46039
	[ -z "$mb_sysroot" ] 		&& mb_sysroot=$mb_default_sysroot
f46039
	[ -z "$mb_cross_compile" ] 	&& mb_cross_compile=$mb_default_cross_compile
f46039
	[ -z "$mb_shell" ] 		&& mb_shell=$mb_default_shell
f46039
f46039
	# switches
f46039
	[ -z "$mb_cflags_debug" ]	&& mb_cflags_debug=$mb_default_cflags_debug
f46039
	[ -z "$mb_cflags_common" ]	&& mb_cflags_common=$mb_default_cflags_common
f46039
	[ -z "$mb_cflags_cmdline" ]	&& mb_cflags_cmdline=$mb_default_cflags_cmdline
f46039
	[ -z "$mb_cflags_config" ]	&& mb_cflags_config=$mb_default_cflags_config
f46039
	[ -z "$mb_cflags_sysroot" ]	&& mb_cflags_sysroot=$mb_default_cflags_sysroot
e6d235
	[ -z "$mb_cflags_os" ]		&& mb_cflags_os=$mb_default_cflags_os
e6d235
	[ -z "$mb_cflags_site" ]	&& mb_cflags_site=$mb_default_cflags_site
f46039
	[ -z "$mb_cflags_path" ]	&& mb_cflags_path=$mb_default_cflags_path
616138
	[ -z "$mb_cflags_strict" ]	&& mb_cflags_strict=$mb_default_cflags_strict
a5b647
	[ -z "$mb_cflags_util" ]	&& mb_cflags_util=$mb_default_cflags_util
1ec01b
	[ -z "$mb_cflags_last" ]	&& mb_cflags_last=$mb_default_cflags_last
1ec01b
	[ -z "$mb_cflags_once" ]	&& mb_cflags_once=$mb_default_cflags_once
f46039
f46039
	[ -z "$mb_ldflags_debug" ]	&& mb_ldflags_debug=$mb_default_ldflags_debug
f46039
	[ -z "$mb_ldflags_common" ]	&& mb_ldflags_common=$mb_default_ldflags_common
f46039
	[ -z "$mb_ldflags_cmdline" ]	&& mb_ldflags_cmdline=$mb_default_ldflags_cmdline
f46039
	[ -z "$mb_ldflags_config" ]	&& mb_ldflags_config=$mb_default_ldflags_config
f46039
	[ -z "$mb_ldflags_sysroot" ]	&& mb_ldflags_sysroot=$mb_default_ldflags_sysroot
f46039
	[ -z "$mb_ldflags_path" ]	&& mb_ldflags_path=$mb_default_ldflags_path
616138
	[ -z "$mb_ldflags_strict" ]	&& mb_ldflags_strict=$mb_default_ldflags_strict
a5b647
	[ -z "$mb_ldflags_util" ]	&& mb_ldflags_util=$mb_default_ldflags_util
1ec01b
	[ -z "$mb_ldflags_last" ]	&& mb_ldflags_last=$mb_default_ldflags_last
1ec01b
	[ -z "$mb_ldflags_once" ]	&& mb_ldflags_once=$mb_default_ldflags_once
f46039
f46039
	[ -z "$mb_pe_subsystem" ]	&& mb_pe_subsystem=$mb_default_pe_subsystem
f46039
	[ -z "$mb_pe_image_base" ]	&& mb_pe_image_base=$mb_default_pe_image_base
f46039
	[ -z "$mb_pe_config_defs" ]	&& mb_pe_config_defs=$mb_default_pe_config_defs
f46039
f46039
	[ -z "$mb_elf_eh_frame" ]	&& mb_elf_eh_frame=$mb_default_elf_eh_frame
f46039
	[ -z "$mb_elf_hash_style" ]	&& mb_elf_hash_style=$mb_default_elf_hash_style
f46039
	[ -z "$mb_elf_config_defs" ]	&& mb_elf_config_defs=$mb_default_elf_config_defs
f46039
d13ab7
	# config
d13ab7
	[ -z "$mb_all_static" ]		&& mb_all_static='no'
d13ab7
	[ -z "$mb_all_shared" ]		&& mb_all_shared='no'
a51e37
	[ -z "$mb_disable_frontend" ]	&& mb_disable_frontend='no'
d13ab7
	[ -z "$mb_disable_static" ]	&& mb_disable_static='no'
d13ab7
	[ -z "$mb_disable_shared" ]	&& mb_disable_shared='no'
d13ab7
f46039
	# host/target
f46039
	[ -z "$mb_host" ] 		&& mb_host=$mb_target
f46039
	[ -z "$mb_target" ] 		&& mb_target=$mb_host
f46039
f46039
	# sysroot
f7f42e
	if [ -n "$mb_sysroot" ]; then
f7f42e
		if [ -z "$mb_cflags_sysroot" ]; then
f46039
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
f46039
		fi
f46039
f7f42e
		if [ -z "$mb_ldflags_sysroot" ]; then
de3f7f
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
f46039
		fi
f46039
	fi
f46039
f46039
	# debug
f7f42e
	if [ "$mb_debug" = yes ]; then
f7f42e
		if [ -z "$mb_cflags_debug" ]; then
f46039
			mb_cflags_debug='-g3 -O0'
f46039
		fi
f46039
	fi
f46039
46d732
	# toolchain
f7f42e
	if [ -z "$mb_toolchain" ]; then
46d732
		mb_toolchain='binutils'
46d732
	fi
dc909f
dc909f
	# fallback host recipe
f7f42e
	if [ -n "$mb_host" ]; then
dc909f
		if ! [ -f $mb_project_dir/sysinfo/host/$mb_host.mk ]; then
dc909f
			if [ -z "$mb_cross_compile" ]; then
dc909f
				mb_cross_compile=$mb_host-
dc909f
			fi
dc909f
dc909f
			mb_host='any-host';
dc909f
		fi
dc909f
	fi
cf5571
cf5571
	# fallback compiler recipe
cf5571
	if [ -n "$mb_compiler" ]; then
cf5571
		if ! [ -f $mb_project_dir/sysinfo/compiler/$mb_compiler.mk ]; then
cf5571
			mb_compiler='any-compiler'
cf5571
		fi
cf5571
	fi
f46039
}
f46039
f46039
f46039
native_defaults()
f46039
{
f46039
	# CC (when set, must be valid)
f7f42e
	if [ -n "$CC" ]; then
f46039
		$CC -dM -E - < /dev/null > /dev/null || exit 2
f46039
	fi
f46039
e83fbe
	# compiler
f46039
	[ -z "$mb_native_cc" ] && mb_native_cc='cc'
f46039
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
f46039
f46039
	[ -z "$mb_native_cc" ] && mb_native_cc='gcc'
f46039
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
f46039
f46039
	[ -z "$mb_native_cc" ] && mb_native_cc='clang'
f46039
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
f46039
f46039
	[ -z "$mb_native_cc" ] && mb_native_cc='cparser'
f46039
	$mb_native_cc -dM -E - < /dev/null > /dev/null 2>/dev/null || mb_native_cc=
f46039
f7f42e
	if [ -z "$mb_native_cc" ]; then
3c8a63
		echo "configure: info: could not find a working native compiler."
3c8a63
		mb_native_cc='false'
f46039
	fi
f46039
63d3bb
	if [ -z "$mb_native_cc_host" ]; then
63d3bb
		mb_native_cc_host=$($mb_project_dir/sysinfo/host/host.sh --compiler=$mb_native_cc)
63d3bb
	fi
63d3bb
f7f42e
	if [ -z "$mb_compiler" ]; then
10b769
		$mb_native_cc -dM -E - < /dev/null | grep -q '__clang__' && mb_compiler='clang'
f46039
	fi
f46039
f7f42e
	if [ -z "$mb_compiler" ]; then
10b769
		$mb_native_cc -dM -E - < /dev/null | grep -q '__GCC' && mb_compiler='gcc'
f46039
	fi
f46039
f7f42e
	if [ -z "$mb_compiler" ]; then
10b769
		$mb_native_cc -dM -E - < /dev/null | grep -q "^gcc" && mb_compiler='gcc'
765f1f
	fi
765f1f
765f1f
	if [ -z "$mb_compiler" ]; then
10b769
		$mb_native_cc -dM -E - < /dev/null | grep -q '__CPARSER__' && mb_compiler='cparser'
f46039
	fi
f46039
f7f42e
	if [ -z "$mb_compiler" ]; then
3c8a63
		echo "configure: info: could not identify the native compiler."
3c8a63
		mb_compiler='any-compiler'
f46039
	fi
f46039
f46039
f46039
	# host
f7f42e
	if [ -z "$mb_host" ]; then
f46039
		mb_host='native'
f46039
	fi
f46039
f46039
f46039
	# target
f7f42e
	if [ -z "$mb_target" ]; then
f46039
		mb_target='native'
f46039
	fi
f46039
f46039
f46039
	# os
0bd690
	if [ -z "$mb_native_os" ]; then
0bd690
		mb_native_os=`uname | tr '[:upper:]' '[:lower:]'`
0bd690
	fi
f46039
f46039
	mb_native_os_sizeof_pointer=`$mb_native_cc -dM -E - < /dev/null \
c28d93
			| awk '$2 == "__SIZEOF_POINTER__" { print $3 }'`
f46039
eac00b
	mb_native_os_bits=$((8 * ${mb_native_os_sizeof_pointer:-0}))
f46039
f46039
	if [ $mb_native_os_bits = 32 ]; then
f46039
		mb_native_os_underscore='_'
f46039
	else
f46039
		mb_native_os_underscore=''
f46039
	fi
f46039
f7f42e
	if [ -z "$mb_native_os_sizeof_pointer" ]; then
a96414
		warning_msg "config error: could not determine size of pointer on native system."
f46039
	fi
9bf58e
b2a106
	# grumpily support crooked uname output
b2a106
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
b2a106
		mb_native_os=`echo $mb_native_os | cut -d'_' -f1`
b2a106
	fi
b2a106
9bf58e
	# fallback os recipe
9bf58e
	if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then
9bf58e
		mb_native_os='any-os';
9bf58e
	fi
f46039
}
f46039
f46039
f46039
cross_defaults()
f46039
{
f7f42e
	if [ -z "$mb_cross_compile" ] && [ "$mb_host" != native ]; then
f46039
		mb_cross_compile=$mb_host'-'
f46039
	fi
f46039
}
f46039
f46039
324cf1
config_flags()
324cf1
{
324cf1
	mb_ldflags_tmp=" $mb_ldflags "
324cf1
	mb_ldflags_libs=`echo "$mb_ldflags_tmp" | sed 's/ -static / /g'`
324cf1
324cf1
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
324cf1
		mb_ldflags="$mb_ldflags_libs"
324cf1
		mb_ldflags_util="$mb_ldflags_util -static"
324cf1
	fi
616138
616138
	# ccstrict
616138
	if [ "$mb_ccstrict" = 'yes' ]; then
616138
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
616138
	fi
616138
616138
	# ldstrict
616138
	if [ "$mb_ldstrict" = 'yes' ]; then
616138
		mb_ldflags_strict='-Wl,--no-undefined'
616138
	fi
324cf1
}
324cf1
324cf1
f46039
config_copy()
f46039
{
f46039
	sed 		-e 's^@package@^'"$mb_package"'^g' 				\
78fd02
			-e 's^@nickname@^'"$mb_nickname"'^g'				\
f46039
			-e 's^@project_dir@^'"$mb_project_dir"'^g'			\
11deae
			-e 's^@source_dir@^'"$mb_source_dir"'^g'			\
269f6f
			-e 's^@git_reference_index@^'"$mb_git_reference_index"'^g'	\
8dc59e
			-e 's^@custom_install_headers@^'"$mb_custom_install_headers"'^g' \
6c7287
			-e 's^@avoid_version@^'"$mb_avoid_version"'^g'			\
f46039
											\
32da4e
			-e 's^@pkgname@^'"$mb_pkgname"'^g'				\
32da4e
			-e 's^@pkgdesc@^'"$mb_pkgdesc"'^g'				\
32da4e
			-e 's^@pkgusrc@^'"$mb_pkgusrc"'^g'				\
32da4e
			-e 's^@pkgrepo@^'"$mb_pkgrepo"'^g'				\
32da4e
			-e 's^@pkgpsrc@^'"$mb_pkgpsrc"'^g'				\
32da4e
			-e 's^@pkgdurl@^'"$mb_pkgdurl"'^g'				\
32da4e
			-e 's^@pkgdefs@^'"$mb_pkgdefs"'^g'				\
32da4e
			-e 's^@pkglibs@^'"$mb_pkglibs"'^g'				\
32da4e
											\
f46039
			-e 's^@build@^'"$mb_build"'^g'					\
f46039
			-e 's^@host@^'"$mb_host"'^g'					\
f46039
			-e 's^@target@^'"$mb_target"'^g'				\
f46039
			-e 's^@arch@^'"$mb_arch"'^g'					\
e83fbe
			-e 's^@compiler@^'"$mb_compiler"'^g'				\
46d732
			-e 's^@toolchain@^'"$mb_toolchain"'^g'				\
f46039
			-e 's^@sysroot@^'"$mb_sysroot"'^g'				\
f46039
			-e 's^@cross_compile@^'"$mb_cross_compile"'^g'			\
f46039
			-e 's^@shell@^'"$mb_shell"'^g'					\
f46039
											\
f46039
			-e 's^@cflags@^'"$mb_cflags"'^g'				\
f46039
			-e 's^@cflags_debug@^'"$mb_cflags_debug"'^g'			\
f46039
			-e 's^@cflags_common@^'"$mb_cflags_common"'^g'			\
f46039
			-e 's^@cflags_cmdline@^'"$mb_cflags $mb_cflags_cmdline"'^g'	\
f46039
			-e 's^@cflags_config@^'"$mb_cflags_config"'^g'			\
f46039
			-e 's^@cflags_sysroot@^'"$mb_cflags_sysroot"'^g'		\
e6d235
			-e 's^@cflags_os@^'"$mb_cflags_os"'^g'				\
e6d235
			-e 's^@cflags_site@^'"$mb_cflags_site"'^g'			\
f46039
			-e 's^@cflags_path@^'"$mb_cflags_path"'^g'			\
616138
			-e 's^@cflags_strict@^'"$mb_cflags_strict"'^g'			\
a5b647
			-e 's^@cflags_util@^'"$mb_cflags_util"'^g'			\
1ec01b
			-e 's^@cflags_last@^'"$mb_cflags_last"'^g'			\
1ec01b
			-e 's^@cflags_once@^'"$mb_cflags_once"'^g'			\
f46039
											\
f46039
			-e 's^@ldflags@^'"$mb_ldflags"'^g'				\
f46039
			-e 's^@ldflags_debug@^'"$mb_ldflags_debug"'^g'			\
f46039
			-e 's^@ldflags_common@^'"$mb_ldflags_common"'^g'		\
f46039
			-e 's^@ldflags_cmdline@^'"$mb_ldflags $mb_ldflags_cmdline"'^g'	\
f46039
			-e 's^@ldflags_config@^'"$mb_ldflags_config"'^g'		\
f46039
			-e 's^@ldflags_sysroot@^'"$mb_ldflags_sysroot"'^g'		\
f46039
			-e 's^@ldflags_path@^'"$mb_ldflags_path"'^g'			\
616138
			-e 's^@ldflags_strict@^'"$mb_ldflags_strict"'^g'		\
a5b647
			-e 's^@ldflags_util@^'"$mb_ldflags_util"'^g'			\
1ec01b
			-e 's^@ldflags_last@^'"$mb_ldflags_last"'^g'			\
1ec01b
			-e 's^@ldflags_once@^'"$mb_ldflags_once"'^g'			\
f46039
											\
f46039
			-e 's^@pe_subsystem@^'"$mb_pe_subsystem"'^g'			\
f46039
			-e 's^@pe_image\_base@^'"$mb_pe_image_base"'^g'			\
f46039
			-e 's^@pe_config\_defs@^'"$mb_pe_config_defs"'^g'		\
f46039
											\
f46039
			-e 's^@elf_eh\_frame@^'"$mb_elf_eh_frame"'^g'			\
f46039
			-e 's^@elf_hash\_style@^'"$mb_elf_hash_style"'^g'		\
f46039
			-e 's^@elf_config\_defs@^'"$mb_elf_config_defs"'^g'		\
f46039
											\
f46039
			-e 's^@prefix@^'"$mb_prefix"'^g'				\
b6d1b5
			-e 's^@exec_prefix@^'"$mb_exec_prefix"'^g'			\
f46039
			-e 's^@bindir@^'"$mb_bindir"'^g'				\
cb6e77
			-e 's^@sbindir@^'"$mb_sbindir"'^g'				\
f46039
			-e 's^@libdir@^'"$mb_libdir"'^g'				\
f46039
			-e 's^@includedir@^'"$mb_includedir"'^g'			\
227174
			-e 's^@oldincludedir@^'"$mb_oldincludedir"'^g'			\
f46039
			-e 's^@mandir@^'"$mb_mandir"'^g'				\
f46039
			-e 's^@docdir@^'"$mb_docdir"'^g'				\
f46039
			-e 's^@libexecdir@^'"$mb_libexecdir"'^g'			\
f46039
											\
227174
			-e 's^@sysconfdir@^'"$mb_sysconfdir"'^g'			\
227174
			-e 's^@sharedstatedir@^'"$mb_sharedstatedir"'^g'		\
227174
			-e 's^@localstatedir@^'"$mb_localstatedir"'^g'			\
227174
			-e 's^@runstatedir@^'"$mb_runstatedir"'^g'			\
227174
			-e 's^@datarootdir@^'"$mb_datarootdir"'^g'			\
227174
			-e 's^@datadir@^'"$mb_datadir"'^g'				\
227174
			-e 's^@infodir@^'"$mb_infodir"'^g'				\
227174
			-e 's^@localedir@^'"$mb_localedir"'^g'				\
227174
			-e 's^@htmldir@^'"$mb_htmldir"'^g'				\
227174
			-e 's^@dvidir@^'"$mb_dvidir"'^g'				\
227174
			-e 's^@pdfdir@^'"$mb_pdfdir"'^g'				\
227174
			-e 's^@psdir@^'"$mb_psdir"'^g'					\
227174
											\
f46039
			-e 's^@native_cc@^'"$mb_native_cc"'^g'				\
63d3bb
			-e 's^@native_cc_host@^'"$mb_native_cc_host"'^g'		\
63d3bb
											\
f46039
			-e 's^@native_os@^'"$mb_native_os"'^g'				\
f46039
			-e 's^@native_os_bits@^'"$mb_native_os_bits"'^g'		\
f46039
			-e 's^@native_os_underscore@^'"$mb_native_os_underscore"'^g'	\
f46039
											\
f46039
			-e 's^@user_cc@^'"$mb_user_cc"'^g'				\
f46039
			-e 's^@user_cpp@^'"$mb_user_cpp"'^g'				\
f46039
			-e 's^@user_cxx@^'"$mb_user_cxx"'^g'				\
d13ab7
											\
d13ab7
			-e 's^@all_static@^'"$mb_all_static"'^g'			\
d13ab7
			-e 's^@all_shared@^'"$mb_all_shared"'^g'			\
a51e37
			-e 's^@disable_frontend@^'"$mb_disable_frontend"'^g'		\
d13ab7
			-e 's^@disable_static@^'"$mb_disable_static"'^g'		\
d13ab7
			-e 's^@disable_shared@^'"$mb_disable_shared"'^g'		\
3d5a30
											\
3d5a30
			-e 's^@use_custom_cfgdefs@^'"$mb_use_custom_cfgdefs"'^g'	\
3d5a30
			-e 's^@use_custom_usrdefs@^'"$mb_use_custom_usrdefs"'^g'	\
c2225d
		$mb_project_dir/Makefile.in > $mb_pwd/Makefile.tmp || exit 2
c2225d
3d5a30
	if [ $mb_use_custom_cfgdefs = 'yes' ]; then
3d5a30
		touch cfgdefs.mk
3d5a30
	fi
3d5a30
3d5a30
	if [ $mb_use_custom_usrdefs = 'yes' ]; then
3d5a30
		touch usrdefs.mk
3d5a30
	fi
3d5a30
c2225d
	if [ -z "$mb_cchost" ]; then
c2225d
		if [ "$mb_host" = 'native' ]; then
c2225d
			mb_cchost=`make -s -f $mb_pwd/Makefile.tmp cchost`
c2225d
		else
c2225d
			mb_cchost=$mb_host
c2225d
		fi
c2225d
	fi
3d5a30
}
3d5a30
3d5a30
3d5a30
config_custom()
3d5a30
{
3d5a30
	if [ $mb_use_custom_cfgdefs = 'yes' ]; then
8574ac
		eval . $mb_project_dir/project/config/cfgdefs.sh \
8574ac
			"$mb_custom_cfgdefs_args"
3d5a30
		config_copy
3d5a30
	fi
c2225d
3d5a30
	if [ $mb_use_custom_usrdefs = 'yes' ]; then
3d5a30
		. $mb_project_dir/project/usrdefs.sh
3d5a30
	fi
3d5a30
}
3d5a30
3d5a30
3d5a30
config_cfghost()
3d5a30
{
95d491
	if [ -z "$mb_cfghost" ]; then
95d491
		mb_cfghost=$mb_cchost
95d491
	fi
95d491
95d491
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
95d491
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
95d491
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host || exit 2
c2225d
c2225d
	rm  $mb_pwd/Makefile.tmp                   || exit 2
c2225d
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile || exit 2
f46039
}
f46039
f46039
97381d
config_support()
97381d
{
97381d
	[ "$mb_disable_shared" = 'yes' ] && return 0
97381d
97381d
	mbt_cc=`make .display-cc`
97381d
	mbt_cflags=`make .display-cflags`
97381d
	mbt_source='int foo(int x){return ++x;}'
97381d
	mbt_result='no'
97381d
97381d
	rm -f a.out
97381d
	echo "$mbt_source" | "$mbt_cc" -shared -o a.out -xc -
97381d
	stat a.out >/dev/null 2>&1 && mbt_result='yes'
97381d
	rm -f a.out
97381d
97381d
	if [ "$mbt_result" = 'no' ]; then
97381d
		mb_disable_shared='yes'
97381d
		config_copy
97381d
	fi
97381d
}
97381d
97381d
f46039
config_host()
f46039
{
52d75a
	make -s host.tag && return 0
f46039
f46039
	error_msg "configure was able to generate a Makefile for the selected host,"
e83fbe
	error_msg "however the host-targeting compiler was found to be missing"
f46039
	error_msg "at least one of the required headers or features."
f46039
	exit 2
f46039
}
f46039
f46039
f46039
config_status()
f46039
{
f46039
	printf "\n\n"
f46039
	make .display
f46039
	printf "\nconfiguration completed successfully.\n\n"
f46039
}
f46039
f46039
# one: init
f46039
init_vars
f46039
verify_build_directory
f46039
f46039
f46039
# two: args
f46039
for arg ; do
f46039
	case "$arg" in
f46039
		--help)	usage
f46039
			;;
f46039
f46039
		# dirs
f46039
		--prefix=*)
6162f0
			mb_prefix_set=yes
f46039
			mb_prefix=${arg#*=}
f46039
			;;
b6d1b5
		--exec-prefix=*)
6162f0
			mb_exec_prefix_set=yes
b6d1b5
			mb_exec_prefix=${arg#*=}
b6d1b5
			;;
f46039
		--bindir=*)
117361
			mb_bindir_set=yes
f46039
			mb_bindir=${arg#*=}
f46039
			;;
cb6e77
		--sbindir=*)
cb6e77
			mb_sbindir=${arg#*=}
cb6e77
			;;
f46039
		--libdir=*)
f46039
			mb_libdir=${arg#*=}
f46039
			;;
f46039
		--includedir=*)
f46039
			mb_includedir=${arg#*=}
f46039
			;;
227174
		--oldincludedir=*)
227174
			mb_oldincludedir=${arg#*=}
227174
			;;
f46039
		--mandir=*)
f46039
			mb_mandir=${arg#*=}
f46039
			;;
f46039
		--libexecdir=*)
f46039
			mb_libexecdir=${arg#*=}
f46039
			;;
f46039
f46039
227174
		--sysconfdir=*)
227174
			mb_sysconfdir=${arg#*=}
227174
			;;
227174
		--sharedstatedir=*)
227174
			mb_sharedstatedir=${arg#*=}
227174
			;;
227174
		--localstatedir=*)
227174
			mb_localstatedir=${arg#*=}
227174
			;;
227174
		--runstatedir=*)
227174
			mb_runstatedir=${arg#*=}
227174
			;;
227174
		--datarootdir=*)
227174
			mb_datarootdir=${arg#*=}
227174
			;;
227174
		--datadir=*)
227174
			mb_datadir=${arg#*=}
227174
			;;
227174
		--infodir=*)
227174
			mb_infodir=${arg#*=}
227174
			;;
227174
		--localedir=*)
227174
			mb_localedir=${arg#*=}
227174
			;;
227174
		--htmldir=*)
227174
			mb_htmldir=${arg#*=}
227174
			;;
227174
		--dvidir=*)
227174
			mb_dvidir=${arg#*=}
227174
			;;
227174
		--pdfdir=*)
227174
			mb_pdfdir=${arg#*=}
227174
			;;
227174
		--psdir=*)
227174
			mb_psdir=${arg#*=}
227174
			;;
227174
227174
f46039
		# build
f46039
		--build=*)
f46039
			mb_build=${arg#*=}
f46039
			;;
f46039
		--host=*)
f46039
			mb_host=${arg#*=}
f46039
			;;
c2225d
		--cchost=*)
c2225d
			mb_cchost=${arg#*=}
c2225d
			;;
95d491
		--cfghost=*)
95d491
			mb_cfghost=${arg#*=}
95d491
			;;
f46039
		--target=*)
f46039
			mb_target=${arg#*=}
f46039
			;;
f46039
		--arch=*)
f46039
			mb_arch=${arg#*=}
f46039
			;;
e83fbe
		--compiler=*)
e83fbe
			mb_compiler=${arg#*=}
f46039
			;;
46d732
		--toolchain=*)
46d732
			mb_toolchain=${arg#*=}
46d732
			;;
f46039
		--sysroot=*)
f46039
			mb_sysroot=${arg#*=}
f46039
			;;
f46039
		--cross-compile=*)
f46039
			mb_cross_compile=${arg#*=}
f46039
			;;
f46039
		--shell=*)
f46039
			mb_shell=${arg#*=}
f46039
			;;
f46039
		--debug)
f46039
			mb_debug='yes'
f46039
			;;
78fd02
d13ab7
		# config
d13ab7
		--all-static)
d13ab7
			mb_all_static='yes'
d13ab7
			;;
d13ab7
		--all-shared)
d13ab7
			mb_all_shared='yes'
d13ab7
			;;
a51e37
		--disable-frontend)
a51e37
			mb_disable_frontend='yes'
a51e37
			;;
a51e37
		--disable-app)
a51e37
			mb_disable_frontend='yes'
a51e37
			;;
a51e37
		--enable-frontend)
a51e37
			mb_disable_frontend='no'
a51e37
			;;
a51e37
		--enable-app)
a51e37
			mb_disable_frontend='no'
a51e37
			;;
d13ab7
		--disable-static)
d13ab7
			mb_disable_static='yes'
d13ab7
			;;
d13ab7
		--disable-shared)
d13ab7
			mb_disable_shared='yes'
d13ab7
			;;
d13ab7
		--enable-static)
d13ab7
			mb_disable_static='no'
d13ab7
			;;
d13ab7
		--enable-shared)
d13ab7
			mb_disable_shared='no'
d13ab7
			;;
d13ab7
616138
		# convenience
616138
		--strict)
616138
			mb_ccstrict='yes'
616138
			mb_ldstrict='yes'
616138
			;;
616138
		--ccstrict)
616138
			mb_ccstrict='yes'
616138
			;;
616138
		--ldstrict)
616138
			mb_ldstrict='yes'
616138
			;;
616138
78fd02
		# project
78fd02
		--nickname=*)
78fd02
			mb_nickname=${arg#*=}
78fd02
			;;
1cd8e4
		--program-prefix=*)
1cd8e4
			mb_program_prefix=${arg#*=}
1cd8e4
			;;
6c7287
		--avoid-version)
6c7287
			mb_avoid_version='yes'
6c7287
			;;
11deae
		--source-dir=*)
11deae
			mb_source_dir=${arg#*=}
11deae
			;;
78fd02
32da4e
		# pkgconfig
32da4e
		--pkgname=*)
32da4e
			mb_pkgname=${arg#*=}
32da4e
			;;
32da4e
32da4e
		--pkgdesc=*)
32da4e
			mb_pkgdesc=${arg#*=}
32da4e
			;;
32da4e
32da4e
		--pkgusrc=*)
32da4e
			mb_pkgusrc=${arg#*=}
32da4e
			;;
32da4e
32da4e
		--pkgrepo=*)
32da4e
			mb_pkgrepo=${arg#*=}
32da4e
			;;
32da4e
32da4e
		--pkgpsrc=*)
32da4e
			mb_pkgpsrc=${arg#*=}
32da4e
			;;
32da4e
32da4e
		--pkgdurl=*)
32da4e
			mb_pkgdurl=${arg#*=}
32da4e
			;;
32da4e
32da4e
		--pkgdefs=*)
32da4e
			mb_pkgdefs=${arg#*=}
32da4e
			;;
32da4e
32da4e
		--pkglibs=*)
32da4e
			mb_pkglibs=${arg#*=}
32da4e
			;;
32da4e
ec21bf
		# compatibility
ec21bf
		--enable-dependency-tracking)
ec21bf
			;;
ec21bf
		--disable-dependency-tracking)
ec21bf
			;;
ec21bf
f46039
		*)
3d5a30
			if [ $mb_use_custom_cfgdefs = 'yes' ]; then
8574ac
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
8574ac
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
8574ac
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
8574ac
				mb_custom_cfgdefs_space=' '
3d5a30
			else
3d5a30
				error_msg ${arg#}: "unsupported config argument."
3d5a30
				exit 2
3d5a30
			fi
f46039
			;;
f46039
	esac
f46039
done
f46039
f46039
f46039
11deae
# three: validation
11deae
verify_source_directory
11deae
1cd8e4
if ! [ -z "$mb_program_prefix" ]; then
1cd8e4
	error_msg "--program-prefix is not yet fully support (must be null)."
1cd8e4
fi
1cd8e4
11deae
11deae
11deae
# four: defaults
f46039
common_defaults
f46039
native_defaults
f46039
cross_defaults
f46039
f46039
f46039
11deae
# five: config
324cf1
config_flags
f46039
config_copy
3d5a30
config_custom
3d5a30
config_cfghost
97381d
config_support
f46039
config_host
f46039
config_status
f46039
f46039
f46039
# all done
f46039
exit 0