Blame configure

0efa8c
#!/bin/sh
0efa8c
05441d
set -eu
05441d
6077f1
trap config_failure 1 2 EXIT
6077f1
ae1e64
# before we begin...
ae1e64
mb_path="$PATH"
ab842b
mb_script="$0"
ab842b
mb_success=no
ae1e64
0efa8c
usage()
0efa8c
{
0efa8c
	cat "$mb_project_dir"/config.usage
5c5f8e
861145
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
5c5f8e
		printf '\n\n%s%s\n' \
5c5f8e
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
5c5f8e
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
5c5f8e
5c5f8e
		printf '%s%s\n' \
5c5f8e
			"| Listed above are configure's common switches " \
5c5f8e
			"and environment variables.     |"
5c5f8e
5c5f8e
		printf '%s%s\n' \
5c5f8e
			"| Found below are project-specific variables " \
5c5f8e
			"and other customization options. |"
5c5f8e
5c5f8e
		printf '%s%s\n\n\n' \
5c5f8e
			" ___________________________________________" \
5c5f8e
			"__________________________________"
5c5f8e
5c5f8e
		cat "$mb_project_dir"/project/config/cfgdefs.usage
5c5f8e
	fi
5c5f8e
5c5f8e
	exit 0
0efa8c
}
0efa8c
0efa8c
error_msg()
0efa8c
{
0ce94d
	printf '%s\n' "$@" >&2
0efa8c
}
0efa8c
0efa8c
warning_msg()
0efa8c
{
0ce94d
	printf '%s\n' "$@" >&2
0efa8c
}
0efa8c
8be87f
output_step_prolog()
8be87f
{
8be87f
	mb_line_dots='..................................'
8be87f
	mb_line_dots="${mb_line_dots}${mb_line_dots}"
8be87f
	mb_step_desc="${mb_package} : ${1##*/} : ${2}() "
8be87f
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
9d19fd
9d19fd
	printf "configure step: ${2}()\n" >&3
8be87f
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s " "${mb_step_desc}" "${mb_line_dots}"
8be87f
}
8be87f
8be87f
output_step_epilog()
8be87f
{
8be87f
	printf 'OK.\n'
8be87f
}
8be87f
8be87f
output_script_status()
8be87f
{
8be87f
	mb_step_name="${1##*/} : ${2}"
8be87f
	mb_step_desc="${mb_package} : ${mb_step_name}"
9d19fd
9d19fd
	printf "configure info: ${2}\n" >&3
8be87f
	printf "%s\n" "${mb_step_desc}"
8be87f
}
8be87f
8be87f
output_section_break()
8be87f
{
8be87f
	printf '...\n'
8be87f
}
8be87f
b38de9
verify_safe_path()
b38de9
{
b38de9
	case "$mb_safe_path_name" in
b38de9
		-*)
b38de9
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
b38de9
			exit 2
b38de9
			;;
b38de9
b38de9
		*\ *)
b38de9
			error_msg "$mb_safe_path_desc may not contain spaces."
b38de9
			exit 2
b38de9
			;;
b38de9
	esac
b38de9
}
0efa8c
9d19fd
init_log()
9d19fd
{
9d19fd
	exec 3> config.log
9d19fd
9d19fd
	printf "This is config.log, generated by sofort's configure script.\n\n" >&3
9d19fd
	printf '$ %s' "$mb_script" >&3
9d19fd
9d19fd
	for arg in $mb_args; do
9d19fd
		printf ' %s' "$arg" >&3
9d19fd
	done
9d19fd
9d19fd
	printf '\n\n' >&3
9d19fd
}
9d19fd
0efa8c
init_vars()
0efa8c
{
b4eb41
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
565fd4
	mb_pwd=$(pwd -P)
0efa8c
b38de9
	mb_safe_path_desc='project directory'
b38de9
	mb_safe_path_name="$mb_project_dir"
b38de9
	verify_safe_path
b38de9
b38de9
	mb_safe_path_desc='working directory'
b38de9
	mb_safe_path_name="$mb_pwd"
b38de9
	verify_safe_path
b38de9
136232
	mb_custom_cfgdefs_args=''
136232
	mb_custom_cfgdefs_space=''
136232
4b0eaf
	sfrt_impl_dir=$mb_project_dir/sofort
4b0eaf
	sfrt_config_dir=$sfrt_impl_dir/config
4b0eaf
	sfrt_core_dir=$sfrt_impl_dir/core
4b0eaf
	sfrt_config_vars=$sfrt_config_dir/config.vars
4b0eaf
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
4b0eaf
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
4b0eaf
a19dda
	mb_make_vars=$(< "$sfrt_config_vars" \
a19dda
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
a85c9f
a19dda
	mb_impl_vars=$(< "$sfrt_config_vars" \
a19dda
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
8d95af
a19dda
	mb_proj_vars=$(< "$sfrt_config_vars" \
a19dda
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
8d95af
a19dda
	mb_flag_vars=$(< "$sfrt_flag_vars" \
a19dda
		grep -v -e '^#' -e '^$')
8d95af
8d95af
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
8d95af
0f630f
	for mb_var in $(printf '%s' "$mb_vars") ; do
a85c9f
		mb_expr=$mb_var='${'$mb_var':-}'
a85c9f
		eval "$mb_expr"
a85c9f
	done
a85c9f
ac2c20
	# ccenv
ac2c20
	. $mb_project_dir/sofort/ccenv/ccenv.sh
ac2c20
520032
	if ! [ -L ./ccenv ]; then
ac2c20
		if [ -d ./ccenv ]; then
ac2c20
			rm -f ./ccenv/host.mk
ac2c20
			rm -f ./ccenv/native.mk
ac2c20
			rmdir ./ccenv
ac2c20
		fi
ac2c20
	fi
ac2c20
ac2c20
	# config.project
0efa8c
	if [ -z "$mb_config" ]; then
b49863
		. $mb_project_dir/config.project
0efa8c
	else
b49863
		. "$mb_config"
0efa8c
	fi
0efa8c
8be87f
	# step prolog
8be87f
	output_step_prolog ${mb_script} 'init_vars'
8be87f
0efa8c
	# project
0efa8c
	mb_nickname=$NICKNAME
a88b38
	mb_source_dir=$SOURCE_DIR
0efa8c
0efa8c
	# dirs
0efa8c
	mb_prefix=$PREFIX
0efa8c
	mb_exec_prefix=$EXEC_PREFIX
0efa8c
	mb_bindir=$BINDIR
d1de9e
	mb_sbindir=$SBINDIR
0efa8c
	mb_libdir=$LIBDIR
0efa8c
	mb_includedir=$INCLUDEDIR
96a3a1
	mb_oldincludedir=$OLDINCLUDEDIR
0efa8c
	mb_mandir=$MANDIR
0efa8c
	mb_docdir=$DOCDIR
0efa8c
	mb_libexecdir=$LIBEXECDIR
0efa8c
96a3a1
	mb_sysconfdir=$SYSCONFDIR
96a3a1
	mb_sharedstatedir=$SHAREDSTATEDIR
96a3a1
	mb_localstatedir=$LOCALSTATEDIR
96a3a1
	mb_runstatedir=$RUNSTATEDIR
96a3a1
	mb_datarootdir=$DATAROOTDIR
96a3a1
	mb_datadir=$DATADIR
96a3a1
	mb_infodir=$INFODIR
96a3a1
	mb_localedir=$LOCALEDIR
96a3a1
	mb_htmldir=$HTMLDIR
96a3a1
	mb_dvidir=$DVIDIR
96a3a1
	mb_pdfdir=$PDFDIR
96a3a1
	mb_psdir=$PSDIR
96a3a1
0efa8c
0efa8c
	# build
0efa8c
	mb_build=$BUILD
980929
	mb_cchost=$CCHOST
9bb8c7
	mb_cfghost=$CFGHOST
0efa8c
	mb_arch=$ARCH
0efa8c
	mb_compiler=$COMPILER
0efa8c
	mb_toolchain=$TOOLCHAIN
0efa8c
	mb_sysroot=$SYSROOT
0efa8c
	mb_cross_compile=$CROSS_COMPILE
0efa8c
	mb_shell=$SHELL
0efa8c
0efa8c
	# switches
0efa8c
	mb_cflags=$CFLAGS
0efa8c
	mb_cflags_debug=$CFLAGS_DEBUG
0efa8c
	mb_cflags_common=$CFLAGS_COMMON
0efa8c
	mb_cflags_cmdline=$CFLAGS_CMDLINE
0efa8c
	mb_cflags_config=$CFLAGS_CONFIG
0efa8c
	mb_cflags_sysroot=$CFLAGS_SYSROOT
0efa8c
	mb_cflags_os=$CFLAGS_OS
0efa8c
	mb_cflags_site=$CFLAGS_SITE
0efa8c
	mb_cflags_path=$CFLAGS_PATH
0efa8c
	mb_cflags_strict=$CFLAGS_STRICT
0efa8c
	mb_cflags_util=$CFLAGS_UTIL
0efa8c
	mb_cflags_last=$CFLAGS_LAST
0efa8c
	mb_cflags_once=$CFLAGS_ONCE
0efa8c
0efa8c
	mb_ldflags=$LDFLAGS
0efa8c
	mb_ldflags_debug=$LDFLAGS_DEBUG
0efa8c
	mb_ldflags_common=$LDFLAGS_COMMON
0efa8c
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
0efa8c
	mb_ldflags_config=$LDFLAGS_CONFIG
0efa8c
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
0efa8c
	mb_ldflags_path=$LDFLAGS_PATH
0efa8c
	mb_ldflags_strict=$LDFLAGS_STRICT
0efa8c
	mb_ldflags_util=$LDFLAGS_UTIL
0efa8c
	mb_ldflags_last=$LDFLAGS_LAST
0efa8c
	mb_ldflags_once=$LDFLAGS_ONCE
0efa8c
0efa8c
	mb_pe_subsystem=$PE_SUBSYSTEM
0efa8c
	mb_pe_image_base=$PE_IMAGE_BASE
0efa8c
0efa8c
	# overrides
0efa8c
	mb_user_cc=$CC
0efa8c
	mb_user_cpp=$CPP
0efa8c
	mb_user_cxx=$CXX
ac2c20
ac2c20
	mb_native_cc=$NATIVE_CC
ac2c20
	mb_native_cpp=$NATIVE_CPP
ac2c20
	mb_native_cxx=$NATIVE_CXX
ac2c20
ac2c20
	mb_native_host=$NATIVE_HOST
ac2c20
	mb_native_cfghost=$NATIVE_CFGHOST
ac2c20
	mb_native_cflags=$NATIVE_CFLAGS
ac2c20
	mb_native_ldflags=$NATIVE_LDFLAGS
ef618e
ef618e
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
ef618e
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
8be87f
8be87f
	# step epilog
8be87f
	output_step_epilog
0efa8c
}
0efa8c
0efa8c
0efa8c
verify_build_directory()
0efa8c
{
8be87f
	output_step_prolog ${mb_script} 'verify_build_directory'
8be87f
0efa8c
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
861145
		if [ _$mb_require_out_of_tree = _yes ]; then
0efa8c
			error_msg "$mb_package: out-of-tree builds are required."
0efa8c
			error_msg "please invoke configure again from a clean build directory."
b49863
			exit 1
0efa8c
		else
0efa8c
			mb_project_dir='.'
0efa8c
		fi
0efa8c
	fi
6077f1
6077f1
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
8be87f
8be87f
	output_step_epilog
0efa8c
}
0efa8c
0efa8c
a88b38
verify_source_directory()
a88b38
{
8be87f
	output_step_prolog ${mb_script} 'verify_source_directory'
8be87f
a88b38
	if [ -z "$mb_source_dir" ]; then
861145
		if [ _$mb_require_source_dir = _yes ]; then
a88b38
			error_msg "$mb_package: specifying an external source directory is required."
a88b38
			error_msg "you can set the source directory either via --source-dir=<path>,"
a88b38
			error_msg "or by setting the SOURCE_DIR variable."
b49863
			exit 1
a88b38
		fi
a88b38
	fi
8be87f
8be87f
	output_step_epilog
a88b38
}
a88b38
a88b38
0efa8c
common_defaults()
0efa8c
{
8be87f
	# step prolog
8be87f
	output_step_prolog ${mb_script} 'common_defaults'
8be87f
19239b
	# project-specific config definitions
19239b
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
19239b
		cat $sfrt_cfgdefs_in > cfgdefs.mk
19239b
	else
19239b
		printf '%s %s\n\n' \
19239b
				'# this project does not include' \
19239b
				'a custom config step.'           \
19239b
			> cfgdefs.mk
19239b
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
19239b
19239b
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
19239b
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
19239b
		fi
19239b
	fi
19239b
19239b
	# user build-time overrides
19239b
	touch usrdefs.mk
19239b
a88b38
	# git
a88b38
	if [ -n "$mb_source_dir" ]; then
a88b38
		if [ -d "$mb_source_dir/.git" ]; then
6f0572
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
a88b38
		fi
a88b38
	elif [ -d "$mb_project_dir/.git" ]; then
6f0572
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
a88b38
	fi
a88b38
0efa8c
	# project
cdc99d
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
cdc99d
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
cdc99d
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
0efa8c
2725e3
	# pkgconfig
cdc99d
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
cdc99d
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
cdc99d
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
cdc99d
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
cdc99d
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
cdc99d
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
cdc99d
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
cdc99d
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
2725e3
0efa8c
	# dirs
cdc99d
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
cdc99d
					|| mb_prefix='/usr/local'
cdc99d
cdc99d
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
cdc99d
					|| mb_exec_prefix=$mb_prefix
cdc99d
cdc99d
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
cdc99d
					|| [ -n "$mb_bindir_basename" ] \
cdc99d
					|| mb_bindir=$mb_exec_prefix/bin
cdc99d
cdc99d
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
cdc99d
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
cdc99d
cdc99d
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
cdc99d
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
cdc99d
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
cdc99d
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
cdc99d
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
cdc99d
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
cdc99d
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc
cdc99d
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
cdc99d
cdc99d
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
cdc99d
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
cdc99d
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
cdc99d
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
cdc99d
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
cdc99d
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
cdc99d
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
cdc99d
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
cdc99d
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
cdc99d
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
cdc99d
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
cdc99d
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
96a3a1
0efa8c
	# switches
cdc99d
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
cdc99d
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
cdc99d
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
cdc99d
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
cdc99d
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
cdc99d
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
cdc99d
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
cdc99d
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
cdc99d
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
cdc99d
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
cdc99d
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
cdc99d
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
cdc99d
cdc99d
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
cdc99d
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
cdc99d
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
cdc99d
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
cdc99d
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
cdc99d
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
cdc99d
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
cdc99d
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
cdc99d
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
cdc99d
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
0efa8c
5bd9e7
	# native switches
cdc99d
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
cdc99d
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
5bd9e7
0efa8c
	# config
cdc99d
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
cdc99d
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
cdc99d
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
cdc99d
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
cdc99d
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
0efa8c
0efa8c
	# host/target
cdc99d
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
cdc99d
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
0efa8c
0efa8c
	# sysroot
0efa8c
	if [ -n "$mb_sysroot" ]; then
0efa8c
		if [ -z "$mb_cflags_sysroot" ]; then
0efa8c
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
0efa8c
		fi
0efa8c
0efa8c
		if [ -z "$mb_ldflags_sysroot" ]; then
754ddd
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
0efa8c
		fi
0efa8c
	fi
0efa8c
0efa8c
	# debug
861145
	if [ _$mb_debug = _yes ]; then
0efa8c
		if [ -z "$mb_cflags_debug" ]; then
0efa8c
			mb_cflags_debug='-g3 -O0'
0efa8c
		fi
0efa8c
	fi
a626b8
cfc74e
	# shell
cfc74e
	if [ -z "$mb_shell" ]; then
cfc74e
		mb_shell='/bin/sh'
cfc74e
	fi
cfc74e
a626b8
	# inherited cflags & ldflags
a626b8
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
a626b8
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
8be87f
8be87f
	# step epilog
8be87f
	output_step_epilog
0efa8c
}
0efa8c
0efa8c
0efa8c
config_flags()
0efa8c
{
8be87f
	# step prolog
8be87f
	output_step_prolog ${mb_script} 'config_flags'
8be87f
0efa8c
	mb_ldflags_tmp=" $mb_ldflags "
06ecb4
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
0efa8c
0efa8c
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
0efa8c
		mb_ldflags="$mb_ldflags_libs"
0efa8c
		mb_ldflags_util="$mb_ldflags_util -static"
0efa8c
	fi
0efa8c
0efa8c
	# ccstrict
861145
	if [ _$mb_ccstrict = _yes ]; then
0efa8c
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
0efa8c
	fi
0efa8c
0efa8c
	# ldstrict
861145
	if [ _$mb_ldstrict = _yes ]; then
0efa8c
		mb_ldflags_strict='-Wl,--no-undefined'
0efa8c
	fi
8be87f
8be87f
	# step epilog
8be87f
	output_step_epilog
0efa8c
}
0efa8c
0efa8c
0efa8c
config_copy()
0efa8c
{
8be87f
	output_step_prolog ${mb_script} 'config_copy'
8be87f
4b0eaf
	mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \
8d95af
			| grep -v '^#')
8d95af
8d95af
	mb_sed_substs=" \
0f630f
		$(for __var in $(printf '%s' "$mb_vars"); do   \
8d95af
			printf '%s"$%s"%s' "-e 's^@$__var@^'" \
8d95af
				"mb_$__var" "'^g' ";           \
8d95af
		done)"
8d95af
8d95af
	eval sed $mb_sed_substs \
8d95af
		$mb_project_dir/Makefile.in    \
42e92c
			| sed -e 's/[[:blank:]]*$//g' \
8d95af
			> $mb_pwd/Makefile.tmp
8be87f
8be87f
	output_step_epilog
ac2c20
}
980929
4a690a
ac2c20
config_ccenv()
ac2c20
{
ac2c20
	mkdir -p ./ccenv
ac2c20
	touch ./ccenv/host.mk
ac2c20
	touch ./ccenv/native.mk
5c5f8e
8be87f
	output_section_break
ac2c20
	ccenv_set_host_variables
8be87f
8be87f
	output_section_break
ac2c20
	ccenv_set_native_variables
1514cb
8be87f
	output_section_break
1514cb
	config_copy
ac2c20
}
5c5f8e
5c5f8e
config_custom()
5c5f8e
{
861145
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
8be87f
		output_section_break
8be87f
		output_script_status ${mb_script} \
9d19fd
			'invoking project-specific cfgdefs.sh'
8be87f
136232
		eval . $mb_project_dir/project/config/cfgdefs.sh \
136232
			"$mb_custom_cfgdefs_args"
8be87f
8be87f
		output_section_break
5c5f8e
		config_copy
5c5f8e
	fi
980929
861145
	if [ _$mb_use_custom_usrdefs = _yes ]; then
8be87f
		output_section_break
8be87f
		output_script_status ${mb_scirpt} \
9d19fd
			'invoking project-specific usrdefs.sh'
8be87f
5c5f8e
		. $mb_project_dir/project/usrdefs.sh
8be87f
		output_section_break
5c5f8e
	fi
5c5f8e
}
5c5f8e
5c5f8e
5c5f8e
config_cfghost()
5c5f8e
{
8be87f
	output_step_prolog ${mb_script} 'config_cfghost'
8be87f
9bb8c7
	if [ -z "$mb_cfghost" ]; then
9bb8c7
		mb_cfghost=$mb_cchost
9bb8c7
	fi
9bb8c7
9bb8c7
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
9bb8c7
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
b49863
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
980929
b49863
	rm  $mb_pwd/Makefile.tmp
b49863
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile
8be87f
8be87f
	output_step_epilog
0efa8c
}
0efa8c
0efa8c
0efa8c
config_host()
0efa8c
{
8be87f
	output_step_prolog ${mb_script} 'config_host'
8be87f
8be87f
	make -s host.tag             \
8be87f
		&& output_step_epilog \
8be87f
		&& return 0
0efa8c
0efa8c
	error_msg "configure was able to generate a Makefile for the selected host,"
0efa8c
	error_msg "however the host-targeting compiler was found to be missing"
0efa8c
	error_msg "at least one of the required headers or features."
0efa8c
	exit 2
0efa8c
}
0efa8c
0efa8c
0efa8c
config_status()
0efa8c
{
8be87f
	output_script_status ${mb_script} \
8be87f
		'configuration completed successfully.'
8be87f
	printf '\n'
0efa8c
}
0efa8c
6077f1
6077f1
config_failure()
6077f1
{
2f6cf5
	if [ _$mb_success = _yes ]; then
2f6cf5
		return 0
2f6cf5
	fi
2f6cf5
9d19fd
	printf 'configure info: exiting due to an error.\n' >&3
9d19fd
6077f1
	if [ -f Makefile ]; then
6077f1
		mb_error='failed to use the generated Makefile.'
6077f1
		printf '\n%s: error: %s\n' "${0}" "$mb_error" >&2
6077f1
		mv Makefile Makefile.failed
6077f1
	fi
6077f1
6077f1
	exit 2
6077f1
}
6077f1
6077f1
6077f1
config_success()
6077f1
{
6077f1
	trap '' EXIT
2f6cf5
	mb_success=yes
6077f1
	exit 0
6077f1
}
6077f1
6077f1
0efa8c
# one: init
9d19fd
mb_args=
9d19fd
mb_args_space=
9d19fd
9d19fd
for arg ; do
9d19fd
	mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
9d19fd
	mb_args="$mb_args$mb_args_space$mb_escaped_arg"
9d19fd
	mb_args_space=' '
9d19fd
done
9d19fd
9d19fd
init_log
0efa8c
init_vars
0efa8c
verify_build_directory
0efa8c
0efa8c
0efa8c
# two: args
0efa8c
for arg ; do
0efa8c
	case "$arg" in
ac2c20
		--help)
ac2c20
			usage
ac2c20
			;;
ac2c20
		--help=ccenv)
ac2c20
			ccenv_usage
ac2c20
			;;
ac2c20
ac2c20
		# ccenv
ac2c20
		--cross-compile=*)
ac2c20
			mb_cross_compile=${arg#*=}
ac2c20
			;;
ac2c20
		--compiler=*)
ac2c20
			mb_compiler=${arg#*=}
ac2c20
			;;
ac2c20
		--toolchain=*)
ac2c20
			mb_toolchain=${arg#*=}
ac2c20
			;;
ac2c20
		--zealous)
ac2c20
			mb_agnostic=yes
ac2c20
			mb_zealous=
ac2c20
			;;
ac2c20
		--zealous=*)
ac2c20
			mb_zealous=${arg#*=}
ac2c20
			;;
ac2c20
		--ccenv=*)
ac2c20
			mb_ccenv=${arg#*=}
0efa8c
			;;
0efa8c
0efa8c
		# dirs
0efa8c
		--prefix=*)
0efa8c
			mb_prefix_set=yes
0efa8c
			mb_prefix=${arg#*=}
0efa8c
			;;
0efa8c
		--exec-prefix=*)
0efa8c
			mb_exec_prefix_set=yes
0efa8c
			mb_exec_prefix=${arg#*=}
0efa8c
			;;
0efa8c
		--bindir=*)
e67d6f
			mb_bindir_set=yes
0efa8c
			mb_bindir=${arg#*=}
0efa8c
			;;
d1de9e
		--sbindir=*)
d1de9e
			mb_sbindir=${arg#*=}
d1de9e
			;;
0efa8c
		--libdir=*)
0efa8c
			mb_libdir=${arg#*=}
0efa8c
			;;
0efa8c
		--includedir=*)
0efa8c
			mb_includedir=${arg#*=}
0efa8c
			;;
96a3a1
		--oldincludedir=*)
96a3a1
			mb_oldincludedir=${arg#*=}
96a3a1
			;;
0efa8c
		--mandir=*)
0efa8c
			mb_mandir=${arg#*=}
0efa8c
			;;
0efa8c
		--libexecdir=*)
0efa8c
			mb_libexecdir=${arg#*=}
0efa8c
			;;
0efa8c
0efa8c
96a3a1
		--sysconfdir=*)
96a3a1
			mb_sysconfdir=${arg#*=}
96a3a1
			;;
96a3a1
		--sharedstatedir=*)
96a3a1
			mb_sharedstatedir=${arg#*=}
96a3a1
			;;
96a3a1
		--localstatedir=*)
96a3a1
			mb_localstatedir=${arg#*=}
96a3a1
			;;
96a3a1
		--runstatedir=*)
96a3a1
			mb_runstatedir=${arg#*=}
96a3a1
			;;
96a3a1
		--datarootdir=*)
96a3a1
			mb_datarootdir=${arg#*=}
96a3a1
			;;
96a3a1
		--datadir=*)
96a3a1
			mb_datadir=${arg#*=}
96a3a1
			;;
96a3a1
		--infodir=*)
96a3a1
			mb_infodir=${arg#*=}
96a3a1
			;;
96a3a1
		--localedir=*)
96a3a1
			mb_localedir=${arg#*=}
96a3a1
			;;
96a3a1
		--htmldir=*)
96a3a1
			mb_htmldir=${arg#*=}
96a3a1
			;;
96a3a1
		--dvidir=*)
96a3a1
			mb_dvidir=${arg#*=}
96a3a1
			;;
96a3a1
		--pdfdir=*)
96a3a1
			mb_pdfdir=${arg#*=}
96a3a1
			;;
96a3a1
		--psdir=*)
96a3a1
			mb_psdir=${arg#*=}
96a3a1
			;;
96a3a1
96a3a1
0efa8c
		# build
0efa8c
		--build=*)
0efa8c
			mb_build=${arg#*=}
0efa8c
			;;
0efa8c
		--host=*)
0efa8c
			mb_host=${arg#*=}
0efa8c
			;;
980929
		--cchost=*)
980929
			mb_cchost=${arg#*=}
980929
			;;
9bb8c7
		--cfghost=*)
9bb8c7
			mb_cfghost=${arg#*=}
9bb8c7
			;;
0efa8c
		--target=*)
0efa8c
			mb_target=${arg#*=}
0efa8c
			;;
0efa8c
		--arch=*)
0efa8c
			mb_arch=${arg#*=}
0efa8c
			;;
0efa8c
		--sysroot=*)
0efa8c
			mb_sysroot=${arg#*=}
0efa8c
			;;
0efa8c
		--shell=*)
0efa8c
			mb_shell=${arg#*=}
0efa8c
			;;
0efa8c
		--debug)
861145
			mb_debug=yes
0efa8c
			;;
0efa8c
0efa8c
		# config
0efa8c
		--all-static)
861145
			mb_all_static=yes
38f04f
			mb_all_shared=no
0efa8c
			;;
0efa8c
		--all-shared)
861145
			mb_all_shared=yes
38f04f
			mb_all_static=no
0efa8c
			;;
0efa8c
		--disable-frontend)
861145
			mb_disable_frontend=yes
0efa8c
			;;
0efa8c
		--disable-app)
861145
			mb_disable_frontend=yes
0efa8c
			;;
0efa8c
		--enable-frontend)
0efa8c
			mb_disable_frontend='no'
0efa8c
			;;
0efa8c
		--enable-app)
0efa8c
			mb_disable_frontend='no'
0efa8c
			;;
0efa8c
		--disable-static)
861145
			mb_disable_static=yes
0efa8c
			;;
0efa8c
		--disable-shared)
861145
			mb_disable_shared=yes
0efa8c
			;;
0efa8c
		--enable-static)
0efa8c
			mb_disable_static='no'
0efa8c
			;;
0efa8c
		--enable-shared)
0efa8c
			mb_disable_shared='no'
0efa8c
			;;
0efa8c
0efa8c
		# convenience
0efa8c
		--strict)
861145
			mb_ccstrict=yes
861145
			mb_ldstrict=yes
0efa8c
			;;
0efa8c
		--ccstrict)
861145
			mb_ccstrict=yes
0efa8c
			;;
0efa8c
		--ldstrict)
861145
			mb_ldstrict=yes
0efa8c
			;;
0efa8c
0efa8c
		# project
0efa8c
		--nickname=*)
0efa8c
			mb_nickname=${arg#*=}
0efa8c
			;;
742f22
		--program-prefix=*)
742f22
			mb_program_prefix=${arg#*=}
742f22
			;;
0efa8c
		--avoid-version)
861145
			mb_avoid_version=yes
0efa8c
			;;
a88b38
		--source-dir=*)
a88b38
			mb_source_dir=${arg#*=}
a88b38
			;;
0f6e85
		--srcdir=*)
0f6e85
			mb_source_dir=${arg#*=}
0f6e85
			;;
0efa8c
2725e3
		# pkgconfig
2725e3
		--pkgname=*)
2725e3
			mb_pkgname=${arg#*=}
2725e3
			;;
2725e3
2725e3
		--pkgdesc=*)
2725e3
			mb_pkgdesc=${arg#*=}
2725e3
			;;
2725e3
2725e3
		--pkgusrc=*)
2725e3
			mb_pkgusrc=${arg#*=}
2725e3
			;;
2725e3
2725e3
		--pkgrepo=*)
2725e3
			mb_pkgrepo=${arg#*=}
2725e3
			;;
2725e3
2725e3
		--pkgpsrc=*)
2725e3
			mb_pkgpsrc=${arg#*=}
2725e3
			;;
2725e3
2725e3
		--pkgdurl=*)
2725e3
			mb_pkgdurl=${arg#*=}
2725e3
			;;
2725e3
2725e3
		--pkgdefs=*)
2725e3
			mb_pkgdefs=${arg#*=}
2725e3
			;;
2725e3
2725e3
		--pkglibs=*)
2725e3
			mb_pkglibs=${arg#*=}
2725e3
			;;
2725e3
2b3dd2
		# compatibility
2b3dd2
		--enable-dependency-tracking)
2b3dd2
			;;
2b3dd2
		--disable-dependency-tracking)
2b3dd2
			;;
2b3dd2
0efa8c
		*)
861145
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
136232
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
136232
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
136232
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
136232
				mb_custom_cfgdefs_space=' '
5c5f8e
			else
5c5f8e
				error_msg ${arg#}: "unsupported config argument."
5c5f8e
				exit 2
5c5f8e
			fi
0efa8c
			;;
0efa8c
	esac
b38de9
b38de9
	mb_safe_path_desc='source directory'
b38de9
	mb_safe_path_name="$mb_source_dir"
b38de9
	verify_safe_path
0efa8c
done
0efa8c
0efa8c
0efa8c
a88b38
# three: validation
a88b38
verify_source_directory
a88b38
742f22
if ! [ -z "$mb_program_prefix" ]; then
742f22
	error_msg "--program-prefix is not yet fully support (must be null)."
742f22
fi
742f22
a88b38
a88b38
a88b38
# four: defaults
0efa8c
common_defaults
0efa8c
0efa8c
a88b38
# five: config
0efa8c
config_flags
0efa8c
config_copy
ac2c20
config_ccenv
5c5f8e
config_custom
5c5f8e
config_cfghost
0efa8c
config_host
0efa8c
config_status
0efa8c
0efa8c
0efa8c
# all done
6077f1
config_success