Blame configure

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