09157951638 / compilers / bcparser

Forked from compilers/bcparser a year ago
Clone

Blame configure

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