Blame configure

18eb48
#!/bin/sh
18eb48
12fcaa
# project-agnostic ./configure script, written by hand.
12fcaa
# this file is covered by COPYING.SOFORT.
12fcaa
9874a2
set -eu
9874a2
55b867
trap config_failure 1 2 EXIT
55b867
d10d65
# before we begin...
d10d65
mb_path="$PATH"
a02d05
mb_script="$0"
a02d05
mb_success=no
d10d65
200877
usage()
200877
{
5bb867
	cat "$mb_project_dir"/config.usage
4b7770
a1d4c2
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
4b7770
		printf '\n\n%s%s\n' \
4b7770
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
4b7770
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
4b7770
4b7770
		printf '%s%s\n' \
4b7770
			"| Listed above are configure's common switches " \
4b7770
			"and environment variables.     |"
4b7770
4b7770
		printf '%s%s\n' \
4b7770
			"| Found below are project-specific variables " \
4b7770
			"and other customization options. |"
4b7770
4b7770
		printf '%s%s\n\n\n' \
4b7770
			" ___________________________________________" \
4b7770
			"__________________________________"
4b7770
4b7770
		cat "$mb_project_dir"/project/config/cfgdefs.usage
4b7770
	fi
4b7770
4b7770
	exit 0
200877
}
200877
18eb48
error_msg()
18eb48
{
c49ce8
	printf '%s\n' "$@" >&2
18eb48
}
18eb48
7e6ea3
warning_msg()
7e6ea3
{
c49ce8
	printf '%s\n' "$@" >&2
7e6ea3
}
7e6ea3
487309
output_step_prolog()
487309
{
e6e220
	mb_line_dots='.................................'
e6e220
	mb_line_dots="${mb_line_dots}.${mb_line_dots}"
74e357
	mb_step_desc="${mb_package} : ${1##*/} : ${2}  "
487309
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
0d8567
74e357
	printf "configure step: ${2}\n" >&3
e6e220
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s  " "${mb_step_desc}" "${mb_line_dots}"
487309
}
487309
487309
output_step_epilog()
487309
{
487309
	printf 'OK.\n'
487309
}
487309
487309
output_script_status()
487309
{
487309
	mb_step_name="${1##*/} : ${2}"
487309
	mb_step_desc="${mb_package} : ${mb_step_name}"
0d8567
0d8567
	printf "configure info: ${2}\n" >&3
487309
	printf "%s\n" "${mb_step_desc}"
487309
}
487309
487309
output_section_break()
487309
{
f520d8
	printf ' ..\n'
487309
}
487309
85c731
verify_safe_path()
85c731
{
85c731
	case "$mb_safe_path_name" in
85c731
		-*)
85c731
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
85c731
			exit 2
85c731
			;;
85c731
85c731
		*\ *)
85c731
			error_msg "$mb_safe_path_desc may not contain spaces."
85c731
			exit 2
85c731
			;;
85c731
	esac
85c731
}
18eb48
0d8567
init_log()
0d8567
{
0d8567
	exec 3> config.log
0d8567
0d8567
	printf "This is config.log, generated by sofort's configure script.\n\n" >&3
0d8567
	printf '$ %s' "$mb_script" >&3
0d8567
}
0d8567
18eb48
init_vars()
18eb48
{
59778c
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
a834c1
	mb_pwd=$(pwd -P)
18eb48
85c731
	mb_safe_path_desc='project directory'
85c731
	mb_safe_path_name="$mb_project_dir"
85c731
	verify_safe_path
85c731
85c731
	mb_safe_path_desc='working directory'
85c731
	mb_safe_path_name="$mb_pwd"
85c731
	verify_safe_path
85c731
548e0e
	mb_custom_cfgdefs_args=''
548e0e
	mb_custom_cfgdefs_space=''
548e0e
1ca6f1
	mb_srcinfo='$(PROJECT_DIR)/project/srcdist/srcinfo.in'
1ca6f1
	mb_srcsite='localhost'
1ca6f1
1ca6f1
	mb_pgprkey='!!VARIABLE_NOT_SET!!'
1ca6f1
	mb_pgpskey='!!VARIABLE_NOT_SET!!'
1ca6f1
3542e2
	sfrt_impl_dir=$mb_project_dir/sofort
3542e2
	sfrt_config_dir=$sfrt_impl_dir/config
3542e2
	sfrt_core_dir=$sfrt_impl_dir/core
3542e2
	sfrt_config_vars=$sfrt_config_dir/config.vars
3542e2
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
beafec
	sfrt_opt_vars=$sfrt_config_dir/opt.vars
3542e2
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
3542e2
642e5f
	mb_make_vars=$(< "$sfrt_config_vars" \
642e5f
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
07222c
642e5f
	mb_impl_vars=$(< "$sfrt_config_vars" \
642e5f
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
3041d9
642e5f
	mb_proj_vars=$(< "$sfrt_config_vars" \
642e5f
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
3041d9
642e5f
	mb_flag_vars=$(< "$sfrt_flag_vars" \
642e5f
		grep -v -e '^#' -e '^$')
3041d9
3041d9
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
3041d9
aecab0
	for mb_var in $(printf '%s' "$mb_vars") ; do
07222c
		mb_expr=$mb_var='${'$mb_var':-}'
07222c
		eval "$mb_expr"
07222c
	done
07222c
6ebae8
	# cfgtest
6ebae8
	. $mb_project_dir/sofort/cfgtest/cfgtest.sh
6ebae8
eb4330
	# ccenv
eb4330
	. $mb_project_dir/sofort/ccenv/ccenv.sh
eb4330
8c2d93
	if ! [ -L ./ccenv ]; then
eb4330
		if [ -d ./ccenv ]; then
eb4330
			rm -f ./ccenv/host.mk
eb4330
			rm -f ./ccenv/native.mk
eb4330
			rmdir ./ccenv
eb4330
		fi
eb4330
	fi
eb4330
eb4330
	# config.project
e0479c
	if [ -z "$mb_config" ]; then
a7027b
		mb_config="$mb_project_dir/config.project"
a7027b
	fi
a7027b
a7027b
	. "$mb_config"
a7027b
808994
	# config.project make preferences
808994
	if [ -z "${MAKE}" ]; then
808994
		MAKE="$mb_make"
808994
	fi
808994
808994
	if [ -z "${MAKEMODE}" ]; then
808994
		MAKEMODE="$mb_makemode"
808994
	fi
808994
f43bd8
f43bd8
	if [ -z "$mb_makefile" ]; then
f43bd8
		mb_makefile='Makefile'
f43bd8
	fi
f43bd8
a1f8d4
	# pkgconf (host)
a1f8d4
	if [ -z "${PKGCONF}" ]; then
a1f8d4
		PKGCONF="$mb_pkgconf"
a1f8d4
	fi
a1f8d4
a1f8d4
	if [ -z "${PKGCONF}" ]; then
a1f8d4
		PKGCONF="${PKGCONFIG}"
a1f8d4
	fi
a1f8d4
a1f8d4
	# pkgconf (native)
a1f8d4
	if [ -z "${NATIVE_PKGCONF}" ]; then
a1f8d4
		NATIVE_PKGCONF="$mb_native_pkgconf"
a1f8d4
	fi
a1f8d4
a1f8d4
	if [ -z "${NATIVE_PKGCONF}" ]; then
a1f8d4
		NATIVE_PKGCONF="${NATIVE_PKGCONFIG}"
a1f8d4
	fi
a1f8d4
d4fa84
	# project-specific initialization
d4fa84
	if [ _$mb_use_custom_cfginit = _yes ]; then
d4fa84
		. "$mb_project_dir/project/config/cfginit.sh"
d4fa84
	fi
d4fa84
a7027b
	# package
a7027b
	if [ -z "$mb_package" ]; then
a7027b
		error_msg "$mb_script: incomplete information in $mb_config."
a7027b
		error_msg "$mb_script: \$mb_package not set."
a7027b
		exit 1
18eb48
	fi
18eb48
ff60a0
	if [ -z "${NICKNAME}" ]; then
ff60a0
		NICKNAME="$mb_nickname"
ff60a0
	fi
ff60a0
0d8353
	# srcinfo
0d8353
	if [ -n "$SOURCE_DIR" ]; then
0d8353
		mb_source_dir_set=yes
0d8353
	fi
0d8353
ec019b
	# cchost
ec019b
	if [ -n "$CCHOST" ]; then
ec019b
		mb_cchost_set=yes
ec019b
	fi
ec019b
487309
	# step prolog
487309
	output_step_prolog ${mb_script} 'init_vars'
487309
9c558e
	# project
9c558e
	mb_nickname=$NICKNAME
60bad4
	mb_source_dir=$SOURCE_DIR
9c558e
18eb48
	# dirs
18eb48
	mb_prefix=$PREFIX
39ef0f
	mb_exec_prefix=$EXEC_PREFIX
18eb48
	mb_bindir=$BINDIR
85e3de
	mb_sbindir=$SBINDIR
18eb48
	mb_libdir=$LIBDIR
18eb48
	mb_includedir=$INCLUDEDIR
669023
	mb_oldincludedir=$OLDINCLUDEDIR
18eb48
	mb_mandir=$MANDIR
18eb48
	mb_docdir=$DOCDIR
18eb48
	mb_libexecdir=$LIBEXECDIR
18eb48
669023
	mb_sysconfdir=$SYSCONFDIR
669023
	mb_sharedstatedir=$SHAREDSTATEDIR
669023
	mb_localstatedir=$LOCALSTATEDIR
669023
	mb_runstatedir=$RUNSTATEDIR
669023
	mb_datarootdir=$DATAROOTDIR
669023
	mb_datadir=$DATADIR
669023
	mb_infodir=$INFODIR
669023
	mb_localedir=$LOCALEDIR
669023
	mb_htmldir=$HTMLDIR
669023
	mb_dvidir=$DVIDIR
669023
	mb_pdfdir=$PDFDIR
669023
	mb_psdir=$PSDIR
669023
c86657
	# make
c86657
	mb_make=$MAKE
18df6e
	mb_makemode=$MAKEMODE
18eb48
18eb48
	# build
18eb48
	mb_build=$BUILD
55d3a8
	mb_cchost=$CCHOST
99366d
	mb_cfghost=$CFGHOST
18eb48
	mb_arch=$ARCH
f08094
	mb_compiler=$COMPILER
722b8c
	mb_toolchain=$TOOLCHAIN
18eb48
	mb_sysroot=$SYSROOT
18eb48
	mb_cross_compile=$CROSS_COMPILE
18eb48
	mb_shell=$SHELL
18eb48
a1f8d4
	# pkgconf
a1f8d4
	mb_pkgconf=$PKGCONF
a1f8d4
18eb48
	# switches
18eb48
	mb_cflags=$CFLAGS
18eb48
	mb_cflags_debug=$CFLAGS_DEBUG
18eb48
	mb_cflags_common=$CFLAGS_COMMON
18eb48
	mb_cflags_cmdline=$CFLAGS_CMDLINE
18eb48
	mb_cflags_config=$CFLAGS_CONFIG
18eb48
	mb_cflags_sysroot=$CFLAGS_SYSROOT
9c558e
	mb_cflags_os=$CFLAGS_OS
9c558e
	mb_cflags_site=$CFLAGS_SITE
18eb48
	mb_cflags_path=$CFLAGS_PATH
9c558e
	mb_cflags_strict=$CFLAGS_STRICT
9c558e
	mb_cflags_util=$CFLAGS_UTIL
4ad4ce
	mb_cflags_last=$CFLAGS_LAST
4ad4ce
	mb_cflags_once=$CFLAGS_ONCE
18eb48
18eb48
	mb_ldflags=$LDFLAGS
18eb48
	mb_ldflags_debug=$LDFLAGS_DEBUG
18eb48
	mb_ldflags_common=$LDFLAGS_COMMON
18eb48
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
18eb48
	mb_ldflags_config=$LDFLAGS_CONFIG
18eb48
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
18eb48
	mb_ldflags_path=$LDFLAGS_PATH
9c558e
	mb_ldflags_strict=$LDFLAGS_STRICT
9c558e
	mb_ldflags_util=$LDFLAGS_UTIL
4ad4ce
	mb_ldflags_last=$LDFLAGS_LAST
4ad4ce
	mb_ldflags_once=$LDFLAGS_ONCE
18eb48
18eb48
	mb_pe_subsystem=$PE_SUBSYSTEM
18eb48
	mb_pe_image_base=$PE_IMAGE_BASE
18eb48
18eb48
	# overrides
e1fef7
	mb_user_cc=$CC
e1fef7
	mb_user_cpp=$CPP
e1fef7
	mb_user_cxx=$CXX
eb4330
eb4330
	mb_native_cc=$NATIVE_CC
eb4330
	mb_native_cpp=$NATIVE_CPP
eb4330
	mb_native_cxx=$NATIVE_CXX
eb4330
eb4330
	mb_native_host=$NATIVE_HOST
eb4330
	mb_native_cfghost=$NATIVE_CFGHOST
eb4330
	mb_native_cflags=$NATIVE_CFLAGS
eb4330
	mb_native_ldflags=$NATIVE_LDFLAGS
6598d3
a1f8d4
	mb_native_pkgconf=$NATIVE_PKGCONF
a1f8d4
6598d3
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
6598d3
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
487309
487309
	# step epilog
487309
	output_step_epilog
18eb48
}
18eb48
18eb48
18eb48
verify_build_directory()
18eb48
{
487309
	output_step_prolog ${mb_script} 'verify_build_directory'
487309
e0479c
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
a1d4c2
		if [ _$mb_require_out_of_tree = _yes ]; then
18eb48
			error_msg "$mb_package: out-of-tree builds are required."
18eb48
			error_msg "please invoke configure again from a clean build directory."
24e83f
			exit 1
18eb48
		else
18eb48
			mb_project_dir='.'
18eb48
		fi
18eb48
	fi
55b867
e8a782
	if [ -f "$mb_pwd/Makefile.common" ]; then
e8a782
		error_msg
e8a782
		error_msg "$mb_package: the file-name Makefile.common is reserved for bootstrapping projects."
e8a782
		error_msg "$mb_package: please remove or rename the file manually and then re-run configure."
e8a782
		exit 1
e8a782
	fi
e8a782
f43bd8
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed $mb_makefile
487309
487309
	output_step_epilog
18eb48
}
18eb48
18eb48
60bad4
verify_source_directory()
60bad4
{
487309
	output_step_prolog ${mb_script} 'verify_source_directory'
487309
07415f
	if [ _"$mb_source_dir" != _${mb_source_dir##* } ]; then
07415f
		error_msg "source directory path contains spaces, aborting."
07415f
		exit 1
07415f
	fi
07415f
07415f
	eval mb_source_dir=$(printf '%s' "$mb_source_dir")
07415f
60bad4
	if [ -z "$mb_source_dir" ]; then
a1d4c2
		if [ _$mb_require_source_dir = _yes ]; then
60bad4
			error_msg "$mb_package: specifying an external source directory is required."
60bad4
			error_msg "you can set the source directory either via --source-dir=<path>,"
60bad4
			error_msg "or by setting the SOURCE_DIR variable."
24e83f
			exit 1
60bad4
		fi
60bad4
	fi
487309
487309
	output_step_epilog
60bad4
}
60bad4
60bad4
0d8353
verify_source_info()
0d8353
{
0d8353
	output_step_prolog ${mb_script} 'verify_source_info'
0d8353
0d8353
	if [ "${mb_source_dir_set:-}" = yes ]; then
0d8353
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ] || [ -n "$mb_srcball" ]; then
0d8353
			error_msg "$mb_package: conflicting arguments: --rawball/--modball/--srcball arguments"
0d8353
			error_msg "may not be used together with an explicit source-dir argument or variable."
0d8353
			exit 1
0d8353
		fi
0d8353
	fi
0d8353
0d8353
	if [ -n "$mb_srcball" ]; then
0d8353
		eval mb_srcball=$(printf '%s' "$mb_srcball")
0d8353
0d8353
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ]; then
0d8353
			error_msg "$mb_package: conflicting arguments: --rawball and/or --modball arguments"
0d8353
			error_msg "may not be used together with an explicitly --srcball argument."
0d8353
			exit 1
0d8353
		fi
0d8353
0d8353
		if [ -z "$mb_srcball_sha256" ]; then
0d8353
			error_msg "$mb_package: --srcball-sha256 must be provided"
0d8353
			error_msg "in conjunction with --srcball."
0d8353
			exit 1
0d8353
		fi
0d8353
0d8353
		mb_srcball_sha256_test=$(sha256sum "$mb_srcball")
0d8353
		mb_srcball_sha256_test="${mb_srcball_sha256_test%% *}"
0d8353
0d8353
		if [ "$mb_srcball_sha256_test" != "$mb_srcball_sha256" ]; then
0d8353
			error_msg "$mb_package: sha256 signature of srcball $mb_srcball does not match!"
0d8353
			exit 1
0d8353
		fi
0d8353
0d8353
		mb_srcball_topdir=$(xz -c -d "$mb_srcball" | pax | sed -n '1,1p')
0d8353
		mb_source_dir="./srctree/$mb_package/${mb_srcball_topdir%/}"
0d8353
0d8353
		mb_srcball_dirname=$(cd -- "${mb_srcball%/*}" ; pwd -P)
0d8353
		mb_srcball_basename=${mb_srcball##*/}
0d8353
		mb_srcball="$mb_srcball_dirname/$mb_srcball_basename"
0d8353
0d8353
		mkdir -p "./srctree/$mb_package"
0d8353
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_srcball" | pax -r)
0d8353
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
0d8353
	fi
0d8353
0d8353
	if [ -z "$mb_rawball" ] && [ -n "$mb_modball" ]; then
0d8353
		error_msg "$mb_package: conflicting arguments: --modball argument may only be used"
0d8353
		error_msg "together with an explicit --rawball argument."
0d8353
		exit 1
0d8353
	fi
0d8353
0d8353
	if [ -n "$mb_modball" ]; then
0d8353
		eval mb_modball=$(printf '%s' "$mb_modball")
0d8353
0d8353
		if [ -z "$mb_modball_sha256" ]; then
0d8353
			error_msg "$mb_package: --modball-sha256 must be provided"
0d8353
			error_msg "in conjunction with --modball."
0d8353
			exit 1
0d8353
		fi
0d8353
0d8353
		mb_modball_sha256_test=$(sha256sum "$mb_modball")
0d8353
		mb_modball_sha256_test="${mb_modball_sha256_test%% *}"
0d8353
0d8353
		if [ "$mb_modball_sha256_test" != "$mb_modball_sha256" ]; then
0d8353
			error_msg "$mb_package: sha256 signature of modball $mb_modball does not match!"
0d8353
			exit 1
0d8353
		fi
0d8353
	fi
0d8353
0d8353
	if [ -n "$mb_rawball" ]; then
0d8353
		eval mb_rawball=$(printf '%s' "$mb_rawball")
0d8353
0d8353
		if [ -z "$mb_rawball_sha256" ]; then
0d8353
			error_msg "$mb_package: --rawball-sha256 must be provided."
0d8353
			error_msg "in conjunction with --rawball."
0d8353
			exit 1
0d8353
		fi
0d8353
0d8353
		mb_rawball_sha256_test=$(sha256sum "$mb_rawball")
0d8353
		mb_rawball_sha256_test="${mb_rawball_sha256_test%% *}"
0d8353
0d8353
		if [ "$mb_rawball_sha256_test" != "$mb_rawball_sha256" ]; then
0d8353
			error_msg "$mb_package: sha256 signature of rawball $mb_rawball does not match!"
0d8353
			exit 1
0d8353
		fi
0d8353
0d8353
		mb_rawball_topdir=$(xz -c -d "$mb_rawball" | pax | sed -n '1,1p')
0d8353
		mb_source_dir="./srctree/$mb_package/${mb_rawball_topdir%/}"
0d8353
0d8353
		mb_rawball_dirname=$(cd -- "${mb_rawball%/*}" ; pwd -P)
0d8353
		mb_rawball_basename=${mb_rawball##*/}
0d8353
		mb_rawball="$mb_rawball_dirname/$mb_rawball_basename"
0d8353
0d8353
		mkdir -p "./srctree/$mb_package"
0d8353
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_rawball" | pax -r)
0d8353
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
0d8353
	fi
0d8353
0d8353
	if [ -n "$mb_modball" ]; then
0d8353
		mb_modball_dirname=$(cd -- "${mb_modball%/*}" ; pwd -P)
0d8353
		mb_modball_basename=${mb_modball##*/}
0d8353
		mb_modball="$mb_modball_dirname/$mb_modball_basename"
0d8353
0d8353
		mb_modball_topdir="./modtree/$mb_package/$mb_modball_sha256"
0d8353
		mkdir -p "$mb_modball_topdir"
0d8353
		mb_modball_topdir=$(cd -- $mb_modball_topdir; pwd -P)
0d8353
		mb_dummy=$(cd -- "$mb_modball_topdir"; xz -c -d "$mb_modball" | pax -r)
0d8353
0d8353
		if [ -d "$mb_modball_topdir/overlay" ]; then
0d8353
			mb_dummy=$(cd -- "$mb_modball_topdir/overlay"; \
0d8353
				cp -p -P -R . "$mb_source_dir")
0d8353
		fi
0d8353
0d8353
		if [ -d "$mb_modball_topdir/patches" ]; then
0d8353
			mb_dummy=$(cd -- "$mb_source_dir";                        \
0d8353
				for p in $mb_modball_topdir/patches/*.patch; do  \
0d8353
					patch -p1 < $p;                         \
0d8353
				done);
0d8353
		fi
0d8353
	fi
0d8353
0d8353
	output_step_epilog
0d8353
}
0d8353
0d8353
18eb48
common_defaults()
18eb48
{
487309
	# step prolog
487309
	output_step_prolog ${mb_script} 'common_defaults'
487309
84292b
	# project-specific config definitions
84292b
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
84292b
		cat $sfrt_cfgdefs_in > cfgdefs.mk
84292b
	else
84292b
		printf '%s %s\n\n' \
84292b
				'# this project does not include' \
84292b
				'a custom config step.'           \
84292b
			> cfgdefs.mk
84292b
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
84292b
84292b
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
84292b
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
84292b
		fi
84292b
	fi
84292b
84292b
	# user build-time overrides
84292b
	touch usrdefs.mk
84292b
60bad4
	# git
60bad4
	if [ -n "$mb_source_dir" ]; then
60bad4
		if [ -d "$mb_source_dir/.git" ]; then
b14273
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
60bad4
		fi
60bad4
	elif [ -d "$mb_project_dir/.git" ]; then
b14273
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
60bad4
	fi
60bad4
9c558e
	# project
50b2f3
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
50b2f3
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
50b2f3
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
9c558e
f9df4a
	# pkgconfig
50b2f3
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
50b2f3
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
50b2f3
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
50b2f3
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
50b2f3
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
50b2f3
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
7dd90c
	[ -n "$mb_pkgbugs" ]		|| mb_pkgbugs="$mb_default_pkgbugs"
7dd90c
	[ -n "$mb_pkghome" ]		|| mb_pkghome="$mb_default_pkghome"
50b2f3
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
50b2f3
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
f9df4a
0d8353
	# srcinfo
0d8353
	[ -n "$mb_rawball" ]		|| mb_rawball="$mb_default_rawball"
0d8353
	[ -n "$mb_rawball_url" ]	|| mb_rawball_url="$mb_default_rawball_url"
0d8353
	[ -n "$mb_rawball_sha256" ]	|| mb_rawball_sha256="$mb_default_rawball_sha256"
0d8353
	[ -n "$mb_modball" ]		|| mb_modball="$mb_default_modball"
0d8353
	[ -n "$mb_modball_url" ]	|| mb_modball_url="$mb_default_modball_url"
0d8353
	[ -n "$mb_modball_sha256" ]	|| mb_modball_sha256="$mb_default_modball_sha256"
0d8353
	[ -n "$mb_srcball" ]		|| mb_srcball="$mb_default_srcball"
0d8353
	[ -n "$mb_srcball_url" ]	|| mb_srcball_url="$mb_default_srcball_url"
0d8353
	[ -n "$mb_srcball_sha256" ]	|| mb_srcball_sha256="$mb_default_srcball_sha256"
0d8353
18eb48
	# dirs
50b2f3
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
50b2f3
					|| mb_prefix='/usr/local'
50b2f3
50b2f3
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
50b2f3
					|| mb_exec_prefix=$mb_prefix
50b2f3
50b2f3
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
50b2f3
					|| [ -n "$mb_bindir_basename" ] \
50b2f3
					|| mb_bindir=$mb_exec_prefix/bin
50b2f3
50b2f3
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
50b2f3
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
50b2f3
50b2f3
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
50b2f3
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
50b2f3
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
50b2f3
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
50b2f3
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
50b2f3
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
ad9796
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc/'$(PACKAGE)'
50b2f3
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
50b2f3
50b2f3
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
50b2f3
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
50b2f3
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
50b2f3
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
50b2f3
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
50b2f3
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
50b2f3
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
50b2f3
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
50b2f3
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
50b2f3
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
50b2f3
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
50b2f3
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
669023
18eb48
	# switches
50b2f3
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
50b2f3
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
50b2f3
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
50b2f3
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
50b2f3
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
50b2f3
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
50b2f3
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
50b2f3
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
50b2f3
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
50b2f3
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
50b2f3
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
50b2f3
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
50b2f3
50b2f3
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
50b2f3
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
50b2f3
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
50b2f3
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
50b2f3
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
50b2f3
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
50b2f3
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
50b2f3
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
50b2f3
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
50b2f3
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
18eb48
90cda7
	# native switches
50b2f3
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
50b2f3
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
90cda7
9c558e
	# config
50b2f3
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
50b2f3
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
50b2f3
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
50b2f3
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
50b2f3
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
9c558e
18eb48
	# host/target
50b2f3
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
50b2f3
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
18eb48
18eb48
	# sysroot
e0479c
	if [ -n "$mb_sysroot" ]; then
e0479c
		if [ -z "$mb_cflags_sysroot" ]; then
f91c90
			mb_cflags_sysroot='$(_CFLAGS_SYSROOT)'
18eb48
		fi
18eb48
e0479c
		if [ -z "$mb_ldflags_sysroot" ]; then
f91c90
			mb_ldflags_sysroot='$(_LDFLAGS_SYSROOT)'
18eb48
		fi
18eb48
	fi
18eb48
18eb48
	# debug
a1d4c2
	if [ _$mb_debug = _yes ]; then
e0479c
		if [ -z "$mb_cflags_debug" ]; then
99b05b
			mb_cflags_debug='$(_CFLAGS_g3) $(_CFLAGS_O0)'
18eb48
		fi
18eb48
	fi
d08441
c86657
	# make
c86657
	if [ -z "$mb_make" ]; then
c86657
		mb_make='make'
c86657
	fi
c86657
18df6e
	if [ -z "$mb_makemode" ]; then
18df6e
		mb_makemode='posix'
da5659
da5659
		printf '%s\n%s\n%s\n\n%s\n\n'        \
da5659
				'ifeq (a,b)'          \
da5659
				'VAR = val'            \
da5659
				'endif'                 \
da5659
				'all:'                   \
da5659
			| ${mb_make} -s -f - 2>/dev/null  \
da5659
		&& mb_makemode='modern'
da5659
18df6e
	fi
18df6e
4048e9
	# shell
4048e9
	if [ -z "$mb_shell" ]; then
4048e9
		mb_shell='/bin/sh'
4048e9
	fi
4048e9
d08441
	# inherited cflags & ldflags
d08441
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
d08441
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
487309
487309
	# step epilog
487309
	output_step_epilog
18eb48
}
18eb48
18eb48
9c558e
config_flags()
9c558e
{
487309
	# step prolog
487309
	output_step_prolog ${mb_script} 'config_flags'
487309
9c558e
	mb_ldflags_tmp=" $mb_ldflags "
e1c1ac
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
9c558e
9c558e
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
9c558e
		mb_ldflags="$mb_ldflags_libs"
9c558e
		mb_ldflags_util="$mb_ldflags_util -static"
9c558e
	fi
9c558e
9c558e
	# ccstrict
a1d4c2
	if [ _$mb_ccstrict = _yes ]; then
fd2fb7
		mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef)'
9c558e
	fi
9c558e
9c558e
	# ldstrict
a1d4c2
	if [ _$mb_ldstrict = _yes ]; then
fd2fb7
		mb_ldflags_strict='$(_CFLAGS_Wl___no_undefined)'
9c558e
	fi
487309
487309
	# step epilog
487309
	output_step_epilog
9c558e
}
9c558e
9c558e
beafec
config_opts()
beafec
{
beafec
	if [ "$mb_avoid_version" = 'yes' ]; then
beafec
		mb_version_opt='none'
beafec
	else
beafec
		mb_version_opt='used'
beafec
	fi
9626c8
9626c8
	if [ "$mb_custom_install_headers" = 'yes' ]; then
9626c8
		mb_install_headers_opt='custom'
9626c8
	else
9626c8
		mb_install_headers_opt='default'
9626c8
	fi
9626c8
9626c8
	if [ "$mb_disable_static" = 'yes' ]; then
9626c8
		mb_static_library_opt='disabled'
9626c8
	else
9626c8
		mb_static_library_opt='enabled'
9626c8
	fi
9626c8
9626c8
	if [ "$mb_disable_shared" = 'yes' ]; then
9626c8
		mb_shared_library_opt='disabled'
9626c8
	else
9626c8
		mb_shared_library_opt='enabled'
9626c8
	fi
9626c8
9626c8
	if [ "$mb_disable_frontend" = 'yes' ]; then
9626c8
		mb_app_frontend_opt='disabled'
9626c8
	else
9626c8
		mb_app_frontend_opt='enabled'
9626c8
	fi
9626c8
9626c8
	if [ "$mb_all_static" = 'yes' ]; then
9626c8
		mb_app_linking_opt='all_static'
9626c8
9626c8
	elif [ "$mb_all_shared" = 'yes' ]; then
9626c8
		mb_app_linking_opt='all_shared'
9626c8
9626c8
	else
9626c8
		mb_app_linking_opt='default'
9626c8
	fi
beafec
}
beafec
18eb48
config_copy()
18eb48
{
487309
	output_step_prolog ${mb_script} 'config_copy'
487309
99e2c8
	mb_var_defs=
99e2c8
	mb_sed_substs=
af85b7
	mb_template="${1:-$mb_project_dir/Makefile.in}"
99e2c8
beafec
	mb_vars=$(cut -d'=' -f1 "$sfrt_config_vars" "$sfrt_opt_vars" \
99e2c8
		| grep -v '^#');
99e2c8
99e2c8
	for __var in $(printf '%s' "$mb_vars"); do
99e2c8
		mb_sed_subst=$(printf '%s %s%s%s'  \
99e2c8
				'-e' "'s^@$__var@"  \
99e2c8
				"^___${__var}___"    \
99e2c8
				"^g'")
99e2c8
99e2c8
		mb_sed_substs="$mb_sed_substs $mb_sed_subst"
99e2c8
99e2c8
		mb_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "mb_${__var}")
99e2c8
		eval mb_var_defs='"$mb_var_defs "$mb_var_def'
99e2c8
	done
99e2c8
af85b7
	eval sed $mb_sed_substs $mb_template         \
af85b7
			| eval m4 $mb_var_defs -      \
af85b7
			| sed -e 's/[[:blank:]]*$//g'  \
99e2c8
		> $mb_pwd/Makefile.tmp
487309
487309
	output_step_epilog
eb4330
}
55d3a8
831445
eb4330
config_ccenv()
eb4330
{
eb4330
	mkdir -p ./ccenv
eb4330
	touch ./ccenv/host.mk
eb4330
	touch ./ccenv/native.mk
4b7770
487309
	output_section_break
eb4330
	ccenv_set_host_variables
487309
487309
	output_section_break
eb4330
	ccenv_set_native_variables
447f5b
c6ae3d
	# implicit --sysroot for use with pkgconf and friends
c6ae3d
	if [ -z "$mb_sysroot" ]; then
c6ae3d
		mb_sysroot="$ccenv_host_sysroot"
c6ae3d
	fi
c6ae3d
23b819
	# require --sysroot when cross-compiling
c6ae3d
	if [ "$mb_cchost" != "$mb_native_cchost" ]                   \
c6ae3d
			&& [ "$ccenv_host_cc" != "$ccenv_native_cc" ] \
c6ae3d
			&& [ -z "$mb_sysroot" ]; then
762572
		mb_pretty=$(printf "%-${#mb_package}s" '')
762572
762572
		error_msg ' !!'
762572
		error_msg "$mb_package: host machine:    $mb_cchost"
762572
		error_msg "$mb_package: host compiler:   $ccenv_host_cc"
762572
762572
		error_msg ' !!'
762572
		error_msg "$mb_package: native machine:  $mb_native_cchost"
762572
		error_msg "$mb_package: native compiler: $ccenv_native_cc"
762572
762572
		error_msg ' !!'
762572
		error_msg "$mb_package: detected host machine and native machine differ, assuming cross-compilation."
762572
762572
		error_msg ' !!'
762572
		error_msg "$mb_package: native compilation mode can be forced via --cchost=$mb_native_cchost"
762572
		error_msg "${mb_pretty}  or otherwise by setting the NATIVE_CC environment variable to '$ccenv_host_cc',"
762572
		error_msg "${mb_pretty}  however that should almost never be necessary; then again,"
762572
		error_msg "${mb_pretty}  forcing native mode when cross-building is strictly prohibited."
762572
23b819
		error_msg ' !!'
762572
		error_msg "$mb_package: error: --sysroot is required when cross-compiling."
23b819
		exit 2
23b819
	fi
23b819
0ffeb6
	# add the library directory to the linker library path
0ffeb6
	if [ "$mb_cchost" = "$mb_native_cchost" ]; then
0ffeb6
		mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
0ffeb6
	else
0ffeb6
		case "$mb_libdir" in
0ffeb6
			/*)
0ffeb6
				mb_ldflags_last="$mb_ldflags_last -L$mb_sysroot/.$mb_libdir"
0ffeb6
				;;
0ffeb6
			*)
0ffeb6
				mb_ldflags_last="$mb_ldflags_last -L$mb_libdir"
0ffeb6
		esac
0ffeb6
	fi
0ffeb6
23b819
	# re-generate Makefile.tmp
487309
	output_section_break
447f5b
	config_copy
23b819
eb4330
}
4b7770
b55028
config_custom_cfgdefs()
b55028
{
b55028
	. $mb_project_dir/project/config/cfgdefs.sh
b55028
}
b55028
4b7770
config_custom()
4b7770
{
a1d4c2
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
487309
		output_section_break
487309
		output_script_status ${mb_script} \
0d8567
			'invoking project-specific cfgdefs.sh'
487309
b55028
		eval config_custom_cfgdefs "$mb_custom_cfgdefs_args"
487309
487309
		output_section_break
5713c5
5713c5
		if [ -f "$mb_project_dir/project/config/Makefile.in" ]; then
5713c5
			config_copy "$mb_project_dir/project/config/Makefile.in"
5713c5
			mv $mb_pwd/Makefile.tmp Makefile
5713c5
		fi
5713c5
4b7770
		config_copy
4b7770
	fi
55d3a8
a1d4c2
	if [ _$mb_use_custom_usrdefs = _yes ]; then
487309
		output_section_break
487309
		output_script_status ${mb_scirpt} \
0d8567
			'invoking project-specific usrdefs.sh'
487309
4b7770
		. $mb_project_dir/project/usrdefs.sh
487309
		output_section_break
4b7770
	fi
4b7770
}
4b7770
4b7770
4b7770
config_cfghost()
4b7770
{
487309
	output_step_prolog ${mb_script} 'config_cfghost'
487309
99366d
	if [ -z "$mb_cfghost" ]; then
99366d
		mb_cfghost=$mb_cchost
99366d
	fi
99366d
99366d
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
99366d
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
24e83f
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
55d3a8
24e83f
	rm  $mb_pwd/Makefile.tmp
f43bd8
	mv  $mb_pwd/Makefile.host $mb_pwd/$mb_makefile
487309
487309
	output_step_epilog
18eb48
}
18eb48
18eb48
eb7107
config_host()
eb7107
{
789c9e
	# init
487309
	output_step_prolog ${mb_script} 'config_host'
487309
789c9e
	mb_cfghost_cc="$ccenv_host_cc"
789c9e
	mb_cfghost_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
789c9e
789c9e
	mb_cfghost_cflags=$(${mb_make} -n -f "$mb_makefile" \
789c9e
		.cflags-host)
789c9e
789c9e
	mb_cfghost_cflags="${mb_cfghost_cflags#*: }"
789c9e
34d735
	if [ "$mb_cc_environment" = 'freestanding' ]; then
210bb1
		if [ -z "mb_cc_underscore" ]; then
210bb1
			mb_cfghost_start_fn='_start'
210bb1
		else
210bb1
			mb_cfghost_start_fn='start'
210bb1
		fi
210bb1
210bb1
		printf 'int %s(void){return 0;}' "$mb_cfghost_start_fn" \
210bb1
			> "$mb_cfghost_tmpname"
210bb1
210bb1
		mb_cfghost_cflags="$mb_cfghost_cflags -ffreestanding"
210bb1
		mb_cfghost_cflags="$mb_cfghost_cflags -nostdlib"
210bb1
	else
210bb1
		printf 'int main(void){return 0;}' \
210bb1
			> "$mb_cfghost_tmpname"
210bb1
	fi
789c9e
789c9e
	# log
789c9e
	printf '\n' >&3
789c9e
789c9e
	printf '%s\n'                                         \
789c9e
		'#'                                           \
789c9e
		'# verify that that following combination of' \
789c9e
		'# host compiler and host cflags is working.' \
789c9e
		'#'                                           \
789c9e
		>&3
789c9e
789c9e
	printf '\n%s' "$mb_cfghost_cc $ccenv_tmpname -o a.out" >&3
789c9e
e4539c
	for mb_cfghost_cflag in $(printf '%s' "$mb_cfghost_cflags"); do
789c9e
		printf ' \\\n\t%s' "$mb_cfghost_cflag" >&3
789c9e
	done
789c9e
789c9e
	printf '\n\n' >&3
789c9e
789c9e
	# execute
789c9e
	if eval $mb_cfghost_cc "$ccenv_tmpname" -o a.out    \
789c9e
			$(printf '%s' "$mb_cfghost_cflags") \
789c9e
			2>&3; then
789c9e
		rm a.out
789c9e
		rm $mb_cfghost_tmpname
789c9e
		mb_cfghost_ret=0
789c9e
	else
789c9e
		mb_cfghost_ret=1
789c9e
	fi
789c9e
789c9e
	if [ $mb_cfghost_ret = 0 ]; then
789c9e
		output_step_epilog
789c9e
		return 0
789c9e
	fi
eb7107
f43bd8
	# should never happen
789c9e
	error_msg
eb7107
	error_msg "configure was able to generate a Makefile for the selected host,"
f08094
	error_msg "however the host-targeting compiler was found to be missing"
eb7107
	error_msg "at least one of the required headers or features."
eb7107
	exit 2
eb7107
}
eb7107
18eb48
d4fa84
config_fini()
d4fa84
{
d4fa84
	# project-specific post-configuration steps
d4fa84
	if [ _$mb_use_custom_cfgfini = _yes ]; then
d4fa84
		. "$mb_project_dir/project/config/cfgfini.sh"
d4fa84
	fi
d4fa84
}
d4fa84
d4fa84
1df9f4
config_status()
1df9f4
{
487309
	output_script_status ${mb_script} \
487309
		'configuration completed successfully.'
487309
	printf '\n'
1df9f4
}
1df9f4
55b867
55b867
config_failure()
55b867
{
1fd4bd
	if [ _$mb_success = _yes ]; then
1fd4bd
		return 0
1fd4bd
	fi
1fd4bd
0d8567
	printf 'configure info: exiting due to an error.\n' >&3
0d8567
55b867
	exit 2
55b867
}
55b867
55b867
55b867
config_success()
55b867
{
55b867
	trap '' EXIT
1fd4bd
	mb_success=yes
55b867
	exit 0
55b867
}
55b867
55b867
18eb48
# one: init
a8f35f
mb_args_defs=
a8f35f
mb_args_text=
a8f35f
mb_args_idx=0
a8f35f
a8f35f
init_log
0d8567
0d8567
for arg ; do
a8f35f
	mb_args_idx=$((mb_args_idx+1))
a8f35f
a8f35f
	mb_arg_def=$(printf '%s%s="${%s}"' "-D_" "${mb_args_idx}" "${mb_args_idx}")
a8f35f
	eval mb_args_defs='"$mb_args_defs "$mb_arg_def'
a8f35f
a8f35f
	mb_args_text="$mb_args_text '_$((mb_args_idx))'"
0d8567
done
0d8567
a8f35f
printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
a8f35f
a8f35f
if [ $mb_args_idx -gt 1 ]; then
a8f35f
	printf '$ %s' "$mb_script" >&3
a8f35f
a8f35f
	mb_args_idx=0
a8f35f
	mb_args_text=
a8f35f
a8f35f
	for arg; do
a8f35f
		mb_args_idx=$((mb_args_idx+1))
a8f35f
		mb_args_text="$mb_args_text"$(printf ' \\\\\n\t%s_%d%s' "'" "$mb_args_idx" "'")
a8f35f
	done
a8f35f
a8f35f
	printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
a8f35f
fi
a8f35f
18eb48
init_vars
18eb48
verify_build_directory
18eb48
18eb48
18eb48
# two: args
18eb48
for arg ; do
18eb48
	case "$arg" in
eb4330
		--help)
eb4330
			usage
eb4330
			;;
eb4330
		--help=ccenv)
eb4330
			ccenv_usage
eb4330
			;;
eb4330
eb4330
		# ccenv
eb4330
		--cross-compile=*)
eb4330
			mb_cross_compile=${arg#*=}
eb4330
			;;
eb4330
		--compiler=*)
eb4330
			mb_compiler=${arg#*=}
eb4330
			;;
eb4330
		--toolchain=*)
eb4330
			mb_toolchain=${arg#*=}
eb4330
			;;
eb4330
		--zealous)
eb4330
			mb_agnostic=yes
eb4330
			mb_zealous=
eb4330
			;;
eb4330
		--zealous=*)
eb4330
			mb_zealous=${arg#*=}
eb4330
			;;
eb4330
		--ccenv=*)
eb4330
			mb_ccenv=${arg#*=}
18eb48
			;;
18eb48
18eb48
		# dirs
18eb48
		--prefix=*)
c6c3fc
			mb_prefix_set=yes
18eb48
			mb_prefix=${arg#*=}
18eb48
			;;
39ef0f
		--exec-prefix=*)
c6c3fc
			mb_exec_prefix_set=yes
39ef0f
			mb_exec_prefix=${arg#*=}
39ef0f
			;;
18eb48
		--bindir=*)
483721
			mb_bindir_set=yes
18eb48
			mb_bindir=${arg#*=}
18eb48
			;;
85e3de
		--sbindir=*)
85e3de
			mb_sbindir=${arg#*=}
85e3de
			;;
18eb48
		--libdir=*)
18eb48
			mb_libdir=${arg#*=}
18eb48
			;;
18eb48
		--includedir=*)
18eb48
			mb_includedir=${arg#*=}
18eb48
			;;
669023
		--oldincludedir=*)
669023
			mb_oldincludedir=${arg#*=}
669023
			;;
18eb48
		--mandir=*)
18eb48
			mb_mandir=${arg#*=}
18eb48
			;;
18eb48
		--libexecdir=*)
18eb48
			mb_libexecdir=${arg#*=}
18eb48
			;;
18eb48
18eb48
669023
		--sysconfdir=*)
669023
			mb_sysconfdir=${arg#*=}
669023
			;;
669023
		--sharedstatedir=*)
669023
			mb_sharedstatedir=${arg#*=}
669023
			;;
669023
		--localstatedir=*)
669023
			mb_localstatedir=${arg#*=}
669023
			;;
669023
		--runstatedir=*)
669023
			mb_runstatedir=${arg#*=}
669023
			;;
669023
		--datarootdir=*)
669023
			mb_datarootdir=${arg#*=}
669023
			;;
669023
		--datadir=*)
669023
			mb_datadir=${arg#*=}
669023
			;;
669023
		--infodir=*)
669023
			mb_infodir=${arg#*=}
669023
			;;
669023
		--localedir=*)
669023
			mb_localedir=${arg#*=}
669023
			;;
669023
		--htmldir=*)
669023
			mb_htmldir=${arg#*=}
669023
			;;
669023
		--dvidir=*)
669023
			mb_dvidir=${arg#*=}
669023
			;;
669023
		--pdfdir=*)
669023
			mb_pdfdir=${arg#*=}
669023
			;;
669023
		--psdir=*)
669023
			mb_psdir=${arg#*=}
669023
			;;
669023
c86657
		#make
c86657
		--make=*)
c86657
			mb_make=${arg#*=}
c86657
			;;
669023
18df6e
		--makemode=*)
18df6e
			mb_makemode=${arg#*=}
18df6e
			;;
18df6e
a1f8d4
		#pkgconf[ig]
a1f8d4
		--pkgconf=*)
a1f8d4
			mb_pkgconf=${arg#*=}
a1f8d4
			;;
a1f8d4
a1f8d4
		--pkgconfig=*)
a1f8d4
			mb_pkgconf=${arg#*=}
a1f8d4
			;;
a1f8d4
18eb48
		# build
18eb48
		--build=*)
18eb48
			mb_build=${arg#*=}
18eb48
			;;
18eb48
		--host=*)
18eb48
			mb_host=${arg#*=}
18eb48
			;;
55d3a8
		--cchost=*)
55d3a8
			mb_cchost=${arg#*=}
ec019b
			mb_cchost_set=yes
55d3a8
			;;
99366d
		--cfghost=*)
99366d
			mb_cfghost=${arg#*=}
99366d
			;;
18eb48
		--target=*)
18eb48
			mb_target=${arg#*=}
18eb48
			;;
18eb48
		--arch=*)
18eb48
			mb_arch=${arg#*=}
18eb48
			;;
18eb48
		--sysroot=*)
18eb48
			mb_sysroot=${arg#*=}
18eb48
			;;
18eb48
		--shell=*)
18eb48
			mb_shell=${arg#*=}
18eb48
			;;
18eb48
		--debug)
a1d4c2
			mb_debug=yes
18eb48
			;;
9c558e
9c558e
		# config
9c558e
		--all-static)
a1d4c2
			mb_all_static=yes
9ecf7e
			mb_all_shared=no
9c558e
			;;
9c558e
		--all-shared)
a1d4c2
			mb_all_shared=yes
9ecf7e
			mb_all_static=no
9c558e
			;;
9c558e
		--disable-frontend)
a1d4c2
			mb_disable_frontend=yes
9c558e
			;;
9c558e
		--disable-app)
a1d4c2
			mb_disable_frontend=yes
9c558e
			;;
9c558e
		--enable-frontend)
9c558e
			mb_disable_frontend='no'
9c558e
			;;
9c558e
		--enable-app)
9c558e
			mb_disable_frontend='no'
9c558e
			;;
9c558e
		--disable-static)
a1d4c2
			mb_disable_static=yes
9c558e
			;;
9c558e
		--disable-shared)
a1d4c2
			mb_disable_shared=yes
9c558e
			;;
9c558e
		--enable-static)
9c558e
			mb_disable_static='no'
9c558e
			;;
9c558e
		--enable-shared)
9c558e
			mb_disable_shared='no'
9c558e
			;;
9c558e
9c558e
		# convenience
9c558e
		--strict)
a1d4c2
			mb_ccstrict=yes
a1d4c2
			mb_ldstrict=yes
9c558e
			;;
9c558e
		--ccstrict)
a1d4c2
			mb_ccstrict=yes
9c558e
			;;
9c558e
		--ldstrict)
a1d4c2
			mb_ldstrict=yes
9c558e
			;;
9c558e
9c558e
		# project
9c558e
		--nickname=*)
9c558e
			mb_nickname=${arg#*=}
9c558e
			;;
763920
		--program-prefix=*)
763920
			mb_program_prefix=${arg#*=}
763920
			;;
9c558e
		--avoid-version)
a1d4c2
			mb_avoid_version=yes
9c558e
			;;
60bad4
		--source-dir=*)
60bad4
			mb_source_dir=${arg#*=}
0d8353
			mb_source_dir_set=yes
60bad4
			;;
264150
		--srcdir=*)
264150
			mb_source_dir=${arg#*=}
0d8353
			mb_source_dir_set=yes
264150
			;;
9c558e
f9df4a
		# pkgconfig
f9df4a
		--pkgname=*)
f9df4a
			mb_pkgname=${arg#*=}
f9df4a
			;;
f9df4a
f9df4a
		--pkgdesc=*)
f9df4a
			mb_pkgdesc=${arg#*=}
f9df4a
			;;
f9df4a
f9df4a
		--pkgusrc=*)
f9df4a
			mb_pkgusrc=${arg#*=}
f9df4a
			;;
f9df4a
f9df4a
		--pkgrepo=*)
f9df4a
			mb_pkgrepo=${arg#*=}
f9df4a
			;;
f9df4a
f9df4a
		--pkgpsrc=*)
f9df4a
			mb_pkgpsrc=${arg#*=}
f9df4a
			;;
f9df4a
f9df4a
		--pkgdurl=*)
f9df4a
			mb_pkgdurl=${arg#*=}
f9df4a
			;;
f9df4a
7dd90c
		--pkgbugs=*)
7dd90c
			mb_pkgbugs=${arg#*=}
7dd90c
			;;
7dd90c
7dd90c
		--pkghome=*)
7dd90c
			mb_pkghome=${arg#*=}
7dd90c
			;;
7dd90c
f9df4a
		--pkgdefs=*)
f9df4a
			mb_pkgdefs=${arg#*=}
f9df4a
			;;
f9df4a
f9df4a
		--pkglibs=*)
f9df4a
			mb_pkglibs=${arg#*=}
f9df4a
			;;
f9df4a
0d8353
		# srcinfo
1ca6f1
		--srcinfo=*)
1ca6f1
			mb_srcinfo=${arg#*=}
1ca6f1
			;;
1ca6f1
1ca6f1
		--srcsite=*)
1ca6f1
			mb_srcsite=${arg#*=}
1ca6f1
			;;
1ca6f1
1ca6f1
		--pgprkey=*)
1ca6f1
			mb_pgprkey=${arg#*=}
1ca6f1
			;;
1ca6f1
1ca6f1
		--pgpskey=*)
1ca6f1
			mb_pgpskey=${arg#*=}
1ca6f1
			;;
1ca6f1
0d8353
		--rawball=*)
0d8353
			mb_rawball=${arg#*=}
0d8353
			;;
0d8353
0d8353
		--rawball-url=*)
0d8353
			mb_rawball_url=${arg#*=}
0d8353
			;;
0d8353
0d8353
		--rawball-sha256=*)
0d8353
			mb_rawball_sha256=${arg#*=}
0d8353
			;;
0d8353
0d8353
		--modball=*)
0d8353
			mb_modball=${arg#*=}
0d8353
			;;
0d8353
0d8353
		--modball-url=*)
0d8353
			mb_modball_url=${arg#*=}
0d8353
			;;
0d8353
0d8353
		--modball-sha256=*)
0d8353
			mb_modball_sha256=${arg#*=}
0d8353
			;;
0d8353
0d8353
		--srcball=*)
0d8353
			mb_srcball=${arg#*=}
0d8353
			;;
0d8353
0d8353
		--srcball-url=*)
0d8353
			mb_srcball_url=${arg#*=}
0d8353
			;;
0d8353
0d8353
		--srcball-sha256=*)
0d8353
			mb_srcball_sha256=${arg#*=}
0d8353
			;;
0d8353
390f7f
		# compatibility
390f7f
		--enable-dependency-tracking)
390f7f
			;;
390f7f
		--disable-dependency-tracking)
390f7f
			;;
390f7f
18eb48
		*)
a1d4c2
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
548e0e
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
548e0e
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
548e0e
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
548e0e
				mb_custom_cfgdefs_space=' '
4b7770
			else
4b7770
				error_msg ${arg#}: "unsupported config argument."
4b7770
				exit 2
4b7770
			fi
18eb48
			;;
18eb48
	esac
85c731
85c731
	mb_safe_path_desc='source directory'
85c731
	mb_safe_path_name="$mb_source_dir"
85c731
	verify_safe_path
18eb48
done
18eb48
18eb48
18eb48
60bad4
# three: validation
60bad4
verify_source_directory
0d8353
verify_source_info
60bad4
763920
if ! [ -z "$mb_program_prefix" ]; then
763920
	error_msg "--program-prefix is not yet fully support (must be null)."
763920
fi
763920
60bad4
60bad4
60bad4
# four: defaults
18eb48
common_defaults
18eb48
18eb48
60bad4
# five: config
9c558e
config_flags
beafec
config_opts
18eb48
config_copy
eb4330
config_ccenv
4b7770
config_custom
4b7770
config_cfghost
eb7107
config_host
d4fa84
config_fini
1df9f4
config_status
18eb48
18eb48
18eb48
# all done
55b867
config_success