Blame configure

cde03b
#!/bin/sh
cde03b
9c88f2
# project-agnostic ./configure script, written by hand.
9c88f2
# this file is covered by COPYING.SOFORT.
9c88f2
1f4fb3
set -eu
1f4fb3
ff655e
trap config_failure 1 2 EXIT
ff655e
eba050
# before we begin...
eba050
mb_path="$PATH"
04e030
mb_script="$0"
04e030
mb_success=no
eba050
cde03b
usage()
cde03b
{
af3780
	cat "$mb_project_dir"/config.usage
e271dd
2728dc
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
e271dd
		printf '\n\n%s%s\n' \
e271dd
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
e271dd
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
e271dd
e271dd
		printf '%s%s\n' \
e271dd
			"| Listed above are configure's common switches " \
e271dd
			"and environment variables.     |"
e271dd
e271dd
		printf '%s%s\n' \
e271dd
			"| Found below are project-specific variables " \
e271dd
			"and other customization options. |"
e271dd
e271dd
		printf '%s%s\n\n\n' \
e271dd
			" ___________________________________________" \
e271dd
			"__________________________________"
e271dd
da7c28
		if [ -f "$mb_project_dir"/project/config/cfgdefs.usage ]; then
da7c28
			cat "$mb_project_dir"/project/config/cfgdefs.usage
da7c28
		else
da7c28
			printf '%s\n\n' \
da7c28
				"[ info: this project does not provide a project-specific cfgdefs.usage file. ]"
da7c28
		fi
e271dd
	fi
e271dd
e271dd
	exit 0
cde03b
}
cde03b
cde03b
error_msg()
cde03b
{
a0ecb3
	printf '%s\n' "$@" >&2
cde03b
}
cde03b
7289b4
warning_msg()
7289b4
{
a0ecb3
	printf '%s\n' "$@" >&2
7289b4
}
7289b4
41a2ad
output_step_prolog()
41a2ad
{
9d04ad
	mb_line_dots='.................................'
9d04ad
	mb_line_dots="${mb_line_dots}.${mb_line_dots}"
65d345
	mb_step_desc="${mb_package} : ${1##*/} : ${2}  "
41a2ad
	mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
0506d8
65d345
	printf "configure step: ${2}\n" >&3
9d04ad
	printf "%s%${mb_step_dlen}.${mb_step_dlen}s  " "${mb_step_desc}" "${mb_line_dots}"
41a2ad
}
41a2ad
41a2ad
output_step_epilog()
41a2ad
{
41a2ad
	printf 'OK.\n'
41a2ad
}
41a2ad
41a2ad
output_script_status()
41a2ad
{
41a2ad
	mb_step_name="${1##*/} : ${2}"
41a2ad
	mb_step_desc="${mb_package} : ${mb_step_name}"
0506d8
0506d8
	printf "configure info: ${2}\n" >&3
41a2ad
	printf "%s\n" "${mb_step_desc}"
41a2ad
}
41a2ad
41a2ad
output_section_break()
41a2ad
{
27f073
	printf ' ..\n'
41a2ad
}
41a2ad
acb5ff
verify_safe_path()
acb5ff
{
acb5ff
	case "$mb_safe_path_name" in
acb5ff
		-*)
acb5ff
			error_msg "$mb_safe_path_desc may not begin with a hyphen."
acb5ff
			exit 2
acb5ff
			;;
acb5ff
acb5ff
		*\ *)
acb5ff
			error_msg "$mb_safe_path_desc may not contain spaces."
acb5ff
			exit 2
acb5ff
			;;
acb5ff
	esac
acb5ff
}
cde03b
0506d8
init_log()
0506d8
{
0506d8
	exec 3> config.log
0506d8
0506d8
	printf "This is config.log, generated by sofort's configure script.\n\n" >&3
0506d8
	printf '$ %s' "$mb_script" >&3
0506d8
}
0506d8
cde03b
init_vars()
cde03b
{
7af2a7
	mb_project_dir=$(cd -- "${mb_script%/*}/" ; pwd -P)
aab67b
	mb_pwd=$(pwd -P)
cde03b
acb5ff
	mb_safe_path_desc='project directory'
acb5ff
	mb_safe_path_name="$mb_project_dir"
acb5ff
	verify_safe_path
acb5ff
acb5ff
	mb_safe_path_desc='working directory'
acb5ff
	mb_safe_path_name="$mb_pwd"
acb5ff
	verify_safe_path
acb5ff
823a96
	mb_custom_cfgdefs_args=''
823a96
	mb_custom_cfgdefs_space=''
823a96
8abfb9
	mb_srcinfo='$(PROJECT_DIR)/project/srcdist/srcinfo.in'
8abfb9
	mb_srcsite='localhost'
8abfb9
8abfb9
	mb_pgprkey='!!VARIABLE_NOT_SET!!'
8abfb9
	mb_pgpskey='!!VARIABLE_NOT_SET!!'
8abfb9
6afb06
	sfrt_impl_dir=$mb_project_dir/sofort
6afb06
	sfrt_config_dir=$sfrt_impl_dir/config
6afb06
	sfrt_core_dir=$sfrt_impl_dir/core
6afb06
	sfrt_config_vars=$sfrt_config_dir/config.vars
6afb06
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
f11003
	sfrt_opt_vars=$sfrt_config_dir/opt.vars
6afb06
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
6afb06
f320a3
	mb_make_vars=$(< "$sfrt_config_vars" \
f320a3
		grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
da830f
f320a3
	mb_impl_vars=$(< "$sfrt_config_vars" \
f320a3
		grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
5d5382
f320a3
	mb_proj_vars=$(< "$sfrt_config_vars" \
f320a3
		grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
5d5382
f320a3
	mb_flag_vars=$(< "$sfrt_flag_vars" \
f320a3
		grep -v -e '^#' -e '^$')
5d5382
5d5382
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
5d5382
820082
	for mb_var in $(printf '%s' "$mb_vars") ; do
da830f
		mb_expr=$mb_var='${'$mb_var':-}'
da830f
		eval "$mb_expr"
da830f
	done
da830f
f512c5
	# cfgtest
f512c5
	. $mb_project_dir/sofort/cfgtest/cfgtest.sh
f512c5
b8199b
	# ccenv
b8199b
	. $mb_project_dir/sofort/ccenv/ccenv.sh
b8199b
a92929
	if ! [ -L ./ccenv ]; then
b8199b
		if [ -d ./ccenv ]; then
b8199b
			rm -f ./ccenv/host.mk
b8199b
			rm -f ./ccenv/native.mk
b8199b
			rmdir ./ccenv
b8199b
		fi
b8199b
	fi
b8199b
b8199b
	# config.project
3a8a92
	if [ -z "$mb_config" ]; then
dcbb08
		mb_config="$mb_project_dir/config.project"
dcbb08
	fi
dcbb08
dcbb08
	. "$mb_config"
dcbb08
49ec73
	# config.project make preferences
49ec73
	if [ -z "${MAKE}" ]; then
49ec73
		MAKE="$mb_make"
49ec73
	fi
49ec73
49ec73
	if [ -z "${MAKEMODE}" ]; then
49ec73
		MAKEMODE="$mb_makemode"
49ec73
	fi
49ec73
d2829c
d2829c
	if [ -z "$mb_makefile" ]; then
d2829c
		mb_makefile='Makefile'
d2829c
	fi
d2829c
7b7ac4
	# pkgconf (host)
7b7ac4
	if [ -z "${PKGCONF}" ]; then
7b7ac4
		PKGCONF="$mb_pkgconf"
7b7ac4
	fi
7b7ac4
7b7ac4
	if [ -z "${PKGCONF}" ]; then
7b7ac4
		PKGCONF="${PKGCONFIG}"
7b7ac4
	fi
7b7ac4
7b7ac4
	# pkgconf (native)
7b7ac4
	if [ -z "${NATIVE_PKGCONF}" ]; then
7b7ac4
		NATIVE_PKGCONF="$mb_native_pkgconf"
7b7ac4
	fi
7b7ac4
7b7ac4
	if [ -z "${NATIVE_PKGCONF}" ]; then
7b7ac4
		NATIVE_PKGCONF="${NATIVE_PKGCONFIG}"
7b7ac4
	fi
7b7ac4
ce4e33
	# project-specific initialization
ce4e33
	if [ _$mb_use_custom_cfginit = _yes ]; then
ce4e33
		. "$mb_project_dir/project/config/cfginit.sh"
ce4e33
	fi
ce4e33
dcbb08
	# package
dcbb08
	if [ -z "$mb_package" ]; then
dcbb08
		error_msg "$mb_script: incomplete information in $mb_config."
dcbb08
		error_msg "$mb_script: \$mb_package not set."
dcbb08
		exit 1
cde03b
	fi
cde03b
cf3fe9
	if [ -z "${NICKNAME}" ]; then
cf3fe9
		NICKNAME="$mb_nickname"
cf3fe9
	fi
cf3fe9
aee3db
	# srcinfo
aee3db
	if [ -n "$SOURCE_DIR" ]; then
aee3db
		mb_source_dir_set=yes
aee3db
	fi
aee3db
fe273c
	# cchost
fe273c
	if [ -n "$CCHOST" ]; then
fe273c
		mb_cchost_set=yes
fe273c
	fi
fe273c
41a2ad
	# step prolog
41a2ad
	output_step_prolog ${mb_script} 'init_vars'
41a2ad
ee3e67
	# project
ee3e67
	mb_nickname=$NICKNAME
f7b445
	mb_source_dir=$SOURCE_DIR
ee3e67
cde03b
	# dirs
cde03b
	mb_prefix=$PREFIX
17f6d3
	mb_exec_prefix=$EXEC_PREFIX
cde03b
	mb_bindir=$BINDIR
a6f38d
	mb_sbindir=$SBINDIR
cde03b
	mb_libdir=$LIBDIR
cde03b
	mb_includedir=$INCLUDEDIR
7f5702
	mb_oldincludedir=$OLDINCLUDEDIR
cde03b
	mb_mandir=$MANDIR
cde03b
	mb_docdir=$DOCDIR
cde03b
	mb_libexecdir=$LIBEXECDIR
cde03b
7f5702
	mb_sysconfdir=$SYSCONFDIR
7f5702
	mb_sharedstatedir=$SHAREDSTATEDIR
7f5702
	mb_localstatedir=$LOCALSTATEDIR
7f5702
	mb_runstatedir=$RUNSTATEDIR
7f5702
	mb_datarootdir=$DATAROOTDIR
7f5702
	mb_datadir=$DATADIR
7f5702
	mb_infodir=$INFODIR
7f5702
	mb_localedir=$LOCALEDIR
7f5702
	mb_htmldir=$HTMLDIR
7f5702
	mb_dvidir=$DVIDIR
7f5702
	mb_pdfdir=$PDFDIR
7f5702
	mb_psdir=$PSDIR
7f5702
4f06b3
	# make
4f06b3
	mb_make=$MAKE
19ccfa
	mb_makemode=$MAKEMODE
cde03b
cde03b
	# build
cde03b
	mb_build=$BUILD
7e1d96
	mb_cchost=$CCHOST
a18dc4
	mb_cfghost=$CFGHOST
cde03b
	mb_arch=$ARCH
d015ab
	mb_compiler=$COMPILER
e692ec
	mb_toolchain=$TOOLCHAIN
cde03b
	mb_sysroot=$SYSROOT
cde03b
	mb_cross_compile=$CROSS_COMPILE
f39341
	mb_shell=$CONFIG_SHELL
cde03b
7b7ac4
	# pkgconf
7b7ac4
	mb_pkgconf=$PKGCONF
7b7ac4
cde03b
	# switches
cde03b
	mb_cflags=$CFLAGS
cde03b
	mb_cflags_debug=$CFLAGS_DEBUG
cde03b
	mb_cflags_common=$CFLAGS_COMMON
cde03b
	mb_cflags_cmdline=$CFLAGS_CMDLINE
cde03b
	mb_cflags_config=$CFLAGS_CONFIG
cde03b
	mb_cflags_sysroot=$CFLAGS_SYSROOT
5de097
	mb_cflags_os=$CFLAGS_OS
5de097
	mb_cflags_site=$CFLAGS_SITE
cde03b
	mb_cflags_path=$CFLAGS_PATH
bec9ab
	mb_cflags_strict=$CFLAGS_STRICT
a5d617
	mb_cflags_util=$CFLAGS_UTIL
9f6e4d
	mb_cflags_last=$CFLAGS_LAST
9f6e4d
	mb_cflags_once=$CFLAGS_ONCE
cde03b
cde03b
	mb_ldflags=$LDFLAGS
cde03b
	mb_ldflags_debug=$LDFLAGS_DEBUG
cde03b
	mb_ldflags_common=$LDFLAGS_COMMON
cde03b
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
cde03b
	mb_ldflags_config=$LDFLAGS_CONFIG
cde03b
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
cde03b
	mb_ldflags_path=$LDFLAGS_PATH
bec9ab
	mb_ldflags_strict=$LDFLAGS_STRICT
a5d617
	mb_ldflags_util=$LDFLAGS_UTIL
9f6e4d
	mb_ldflags_last=$LDFLAGS_LAST
9f6e4d
	mb_ldflags_once=$LDFLAGS_ONCE
cde03b
cde03b
	mb_pe_subsystem=$PE_SUBSYSTEM
cde03b
	mb_pe_image_base=$PE_IMAGE_BASE
cde03b
cde03b
	# overrides
cde03b
	mb_user_cc=$CC
cde03b
	mb_user_cpp=$CPP
cde03b
	mb_user_cxx=$CXX
b8199b
b8199b
	mb_native_cc=$NATIVE_CC
b8199b
	mb_native_cpp=$NATIVE_CPP
b8199b
	mb_native_cxx=$NATIVE_CXX
b8199b
b8199b
	mb_native_host=$NATIVE_HOST
b8199b
	mb_native_cfghost=$NATIVE_CFGHOST
b8199b
	mb_native_cflags=$NATIVE_CFLAGS
b8199b
	mb_native_ldflags=$NATIVE_LDFLAGS
ef8273
7b7ac4
	mb_native_pkgconf=$NATIVE_PKGCONF
7b7ac4
ef8273
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
ef8273
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
41a2ad
41a2ad
	# step epilog
41a2ad
	output_step_epilog
cde03b
}
cde03b
cde03b
cde03b
verify_build_directory()
cde03b
{
41a2ad
	output_step_prolog ${mb_script} 'verify_build_directory'
41a2ad
3a8a92
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
2728dc
		if [ _$mb_require_out_of_tree = _yes ]; then
cde03b
			error_msg "$mb_package: out-of-tree builds are required."
cde03b
			error_msg "please invoke configure again from a clean build directory."
da372a
			exit 1
cde03b
		else
cde03b
			mb_project_dir='.'
cde03b
		fi
cde03b
	fi
ff655e
d8cfb6
	if [ -f "$mb_pwd/Makefile.common" ]; then
d8cfb6
		error_msg
d8cfb6
		error_msg "$mb_package: the file-name Makefile.common is reserved for bootstrapping projects."
d8cfb6
		error_msg "$mb_package: please remove or rename the file manually and then re-run configure."
d8cfb6
		exit 1
d8cfb6
	fi
d8cfb6
d2829c
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed $mb_makefile
41a2ad
41a2ad
	output_step_epilog
cde03b
}
cde03b
cde03b
f7b445
verify_source_directory()
f7b445
{
41a2ad
	output_step_prolog ${mb_script} 'verify_source_directory'
41a2ad
d0f155
	if [ _"$mb_source_dir" != _${mb_source_dir##* } ]; then
d0f155
		error_msg "source directory path contains spaces, aborting."
d0f155
		exit 1
d0f155
	fi
d0f155
d0f155
	eval mb_source_dir=$(printf '%s' "$mb_source_dir")
d0f155
f7b445
	if [ -z "$mb_source_dir" ]; then
2728dc
		if [ _$mb_require_source_dir = _yes ]; then
f7b445
			error_msg "$mb_package: specifying an external source directory is required."
f7b445
			error_msg "you can set the source directory either via --source-dir=<path>,"
f7b445
			error_msg "or by setting the SOURCE_DIR variable."
da372a
			exit 1
f7b445
		fi
f7b445
	fi
41a2ad
41a2ad
	output_step_epilog
f7b445
}
f7b445
f7b445
aee3db
verify_source_info()
aee3db
{
aee3db
	output_step_prolog ${mb_script} 'verify_source_info'
aee3db
aee3db
	if [ "${mb_source_dir_set:-}" = yes ]; then
aee3db
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ] || [ -n "$mb_srcball" ]; then
aee3db
			error_msg "$mb_package: conflicting arguments: --rawball/--modball/--srcball arguments"
aee3db
			error_msg "may not be used together with an explicit source-dir argument or variable."
aee3db
			exit 1
aee3db
		fi
aee3db
	fi
aee3db
aee3db
	if [ -n "$mb_srcball" ]; then
aee3db
		eval mb_srcball=$(printf '%s' "$mb_srcball")
aee3db
aee3db
		if [ -n "$mb_rawball" ] || [ -n "$mb_modball" ]; then
aee3db
			error_msg "$mb_package: conflicting arguments: --rawball and/or --modball arguments"
aee3db
			error_msg "may not be used together with an explicitly --srcball argument."
aee3db
			exit 1
aee3db
		fi
aee3db
aee3db
		if [ -z "$mb_srcball_sha256" ]; then
aee3db
			error_msg "$mb_package: --srcball-sha256 must be provided"
aee3db
			error_msg "in conjunction with --srcball."
aee3db
			exit 1
aee3db
		fi
aee3db
aee3db
		mb_srcball_sha256_test=$(sha256sum "$mb_srcball")
aee3db
		mb_srcball_sha256_test="${mb_srcball_sha256_test%% *}"
aee3db
aee3db
		if [ "$mb_srcball_sha256_test" != "$mb_srcball_sha256" ]; then
aee3db
			error_msg "$mb_package: sha256 signature of srcball $mb_srcball does not match!"
aee3db
			exit 1
aee3db
		fi
aee3db
aee3db
		mb_srcball_topdir=$(xz -c -d "$mb_srcball" | pax | sed -n '1,1p')
aee3db
		mb_source_dir="./srctree/$mb_package/${mb_srcball_topdir%/}"
aee3db
aee3db
		mb_srcball_dirname=$(cd -- "${mb_srcball%/*}" ; pwd -P)
aee3db
		mb_srcball_basename=${mb_srcball##*/}
aee3db
		mb_srcball="$mb_srcball_dirname/$mb_srcball_basename"
aee3db
aee3db
		mkdir -p "./srctree/$mb_package"
aee3db
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_srcball" | pax -r)
aee3db
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
aee3db
	fi
aee3db
aee3db
	if [ -z "$mb_rawball" ] && [ -n "$mb_modball" ]; then
aee3db
		error_msg "$mb_package: conflicting arguments: --modball argument may only be used"
aee3db
		error_msg "together with an explicit --rawball argument."
aee3db
		exit 1
aee3db
	fi
aee3db
aee3db
	if [ -n "$mb_modball" ]; then
aee3db
		eval mb_modball=$(printf '%s' "$mb_modball")
aee3db
aee3db
		if [ -z "$mb_modball_sha256" ]; then
aee3db
			error_msg "$mb_package: --modball-sha256 must be provided"
aee3db
			error_msg "in conjunction with --modball."
aee3db
			exit 1
aee3db
		fi
aee3db
aee3db
		mb_modball_sha256_test=$(sha256sum "$mb_modball")
aee3db
		mb_modball_sha256_test="${mb_modball_sha256_test%% *}"
aee3db
aee3db
		if [ "$mb_modball_sha256_test" != "$mb_modball_sha256" ]; then
aee3db
			error_msg "$mb_package: sha256 signature of modball $mb_modball does not match!"
aee3db
			exit 1
aee3db
		fi
aee3db
	fi
aee3db
aee3db
	if [ -n "$mb_rawball" ]; then
aee3db
		eval mb_rawball=$(printf '%s' "$mb_rawball")
aee3db
aee3db
		if [ -z "$mb_rawball_sha256" ]; then
aee3db
			error_msg "$mb_package: --rawball-sha256 must be provided."
aee3db
			error_msg "in conjunction with --rawball."
aee3db
			exit 1
aee3db
		fi
aee3db
aee3db
		mb_rawball_sha256_test=$(sha256sum "$mb_rawball")
aee3db
		mb_rawball_sha256_test="${mb_rawball_sha256_test%% *}"
aee3db
aee3db
		if [ "$mb_rawball_sha256_test" != "$mb_rawball_sha256" ]; then
aee3db
			error_msg "$mb_package: sha256 signature of rawball $mb_rawball does not match!"
aee3db
			exit 1
aee3db
		fi
aee3db
aee3db
		mb_rawball_topdir=$(xz -c -d "$mb_rawball" | pax | sed -n '1,1p')
aee3db
		mb_source_dir="./srctree/$mb_package/${mb_rawball_topdir%/}"
aee3db
aee3db
		mb_rawball_dirname=$(cd -- "${mb_rawball%/*}" ; pwd -P)
aee3db
		mb_rawball_basename=${mb_rawball##*/}
aee3db
		mb_rawball="$mb_rawball_dirname/$mb_rawball_basename"
aee3db
aee3db
		mkdir -p "./srctree/$mb_package"
aee3db
		mb_dummy=$(cd -- "./srctree/$mb_package"; xz -c -d "$mb_rawball" | pax -r)
aee3db
		mb_source_dir=$(cd -- $mb_source_dir; pwd -P)
aee3db
	fi
aee3db
aee3db
	if [ -n "$mb_modball" ]; then
aee3db
		mb_modball_dirname=$(cd -- "${mb_modball%/*}" ; pwd -P)
aee3db
		mb_modball_basename=${mb_modball##*/}
aee3db
		mb_modball="$mb_modball_dirname/$mb_modball_basename"
aee3db
aee3db
		mb_modball_topdir="./modtree/$mb_package/$mb_modball_sha256"
aee3db
		mkdir -p "$mb_modball_topdir"
aee3db
		mb_modball_topdir=$(cd -- $mb_modball_topdir; pwd -P)
aee3db
		mb_dummy=$(cd -- "$mb_modball_topdir"; xz -c -d "$mb_modball" | pax -r)
aee3db
aee3db
		if [ -d "$mb_modball_topdir/overlay" ]; then
aee3db
			mb_dummy=$(cd -- "$mb_modball_topdir/overlay"; \
aee3db
				cp -p -P -R . "$mb_source_dir")
aee3db
		fi
aee3db
aee3db
		if [ -d "$mb_modball_topdir/patches" ]; then
aee3db
			mb_dummy=$(cd -- "$mb_source_dir";                        \
aee3db
				for p in $mb_modball_topdir/patches/*.patch; do  \
aee3db
					patch -p1 < $p;                         \
aee3db
				done);
aee3db
		fi
aee3db
	fi
aee3db
aee3db
	output_step_epilog
aee3db
}
aee3db
aee3db
cde03b
common_defaults()
cde03b
{
41a2ad
	# step prolog
41a2ad
	output_step_prolog ${mb_script} 'common_defaults'
41a2ad
73dcee
	# project-specific config definitions
73dcee
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
73dcee
		cat $sfrt_cfgdefs_in > cfgdefs.mk
73dcee
	else
73dcee
		printf '%s %s\n\n' \
73dcee
				'# this project does not include' \
73dcee
				'a custom config step.'           \
73dcee
			> cfgdefs.mk
73dcee
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
73dcee
73dcee
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
73dcee
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
73dcee
		fi
73dcee
	fi
73dcee
73dcee
	# user build-time overrides
73dcee
	touch usrdefs.mk
73dcee
f7b445
	# git
f7b445
	if [ -n "$mb_source_dir" ]; then
f7b445
		if [ -d "$mb_source_dir/.git" ]; then
2994e2
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
f7b445
		fi
f7b445
	elif [ -d "$mb_project_dir/.git" ]; then
2994e2
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
f7b445
	fi
f7b445
ee3e67
	# project
bd5f11
	[ -n "$mb_nickname" ] 		|| mb_nickname=$mb_package
bd5f11
	[ -n "$mb_source_dir" ] 	|| mb_source_dir=$mb_project_dir
bd5f11
	[ -n "$mb_avoid_version" ] 	|| mb_avoid_version='no'
ee3e67
b9138e
	# pkgconfig
bd5f11
	[ -n "$mb_pkgname" ]		|| mb_pkgname="$mb_default_pkgname"
bd5f11
	[ -n "$mb_pkgdesc" ]		|| mb_pkgdesc="$mb_default_pkgdesc"
bd5f11
	[ -n "$mb_pkgusrc" ]		|| mb_pkgusrc="$mb_default_pkgusrc"
bd5f11
	[ -n "$mb_pkgrepo" ]		|| mb_pkgrepo="$mb_default_pkgrepo"
bd5f11
	[ -n "$mb_pkgpsrc" ]		|| mb_pkgpsrc="$mb_default_pkgpsrc"
bd5f11
	[ -n "$mb_pkgdurl" ]		|| mb_pkgdurl="$mb_default_pkgdurl"
5b4717
	[ -n "$mb_pkgbugs" ]		|| mb_pkgbugs="$mb_default_pkgbugs"
5b4717
	[ -n "$mb_pkghome" ]		|| mb_pkghome="$mb_default_pkghome"
bd5f11
	[ -n "$mb_pkgdefs" ]		|| mb_pkgdefs="$mb_default_pkgdefs"
bd5f11
	[ -n "$mb_pkglibs" ]		|| mb_pkglibs="$mb_default_pkglibs"
b9138e
aee3db
	# srcinfo
aee3db
	[ -n "$mb_rawball" ]		|| mb_rawball="$mb_default_rawball"
aee3db
	[ -n "$mb_rawball_url" ]	|| mb_rawball_url="$mb_default_rawball_url"
aee3db
	[ -n "$mb_rawball_sha256" ]	|| mb_rawball_sha256="$mb_default_rawball_sha256"
aee3db
	[ -n "$mb_modball" ]		|| mb_modball="$mb_default_modball"
aee3db
	[ -n "$mb_modball_url" ]	|| mb_modball_url="$mb_default_modball_url"
aee3db
	[ -n "$mb_modball_sha256" ]	|| mb_modball_sha256="$mb_default_modball_sha256"
aee3db
	[ -n "$mb_srcball" ]		|| mb_srcball="$mb_default_srcball"
aee3db
	[ -n "$mb_srcball_url" ]	|| mb_srcball_url="$mb_default_srcball_url"
aee3db
	[ -n "$mb_srcball_sha256" ]	|| mb_srcball_sha256="$mb_default_srcball_sha256"
aee3db
cde03b
	# dirs
bd5f11
	[ -n "$mb_prefix" ] 		|| [ -n "$mb_prefix_set" ] \
bd5f11
					|| mb_prefix='/usr/local'
bd5f11
bd5f11
	[ -n "$mb_exec_prefix" ] 	|| [ -n "$mb_exec_prefix_set" ]	\
bd5f11
					|| mb_exec_prefix=$mb_prefix
bd5f11
bd5f11
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
bd5f11
					|| [ -n "$mb_bindir_basename" ] \
bd5f11
					|| mb_bindir=$mb_exec_prefix/bin
bd5f11
bd5f11
	[ -n "$mb_bindir" ] 		|| [ -n "$mb_bindir_set" ] \
bd5f11
					|| mb_bindir=$mb_exec_prefix/$mb_bindir_basename
bd5f11
bd5f11
	[ -n "$mb_sbindir" ] 		|| mb_sbindir=$mb_exec_prefix/sbin
bd5f11
	[ -n "$mb_libdir" ] 		|| mb_libdir=$mb_exec_prefix/lib
bd5f11
	[ -n "$mb_includedir" ]		|| mb_includedir=$mb_prefix/include
bd5f11
	[ -n "$mb_oldincludedir" ]	|| mb_oldincludedir=$mb_prefix/include
bd5f11
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
bd5f11
	[ -n "$mb_mandir" ] 		|| mb_mandir=$mb_datarootdir/man
6e21a2
	[ -n "$mb_docdir" ] 		|| mb_docdir=$mb_datarootdir/doc/'$(PACKAGE)'
bd5f11
	[ -n "$mb_libexecdir" ]		|| mb_libexecdir=$mb_exec_prefix/libexec
bd5f11
bd5f11
	[ -n "$mb_sysconfdir" ] 	|| mb_sysconfdir=$mb_exec_prefix/etc
bd5f11
	[ -n "$mb_sharedstatedir" ] 	|| mb_sharedstatedir=$mb_prefix/com
bd5f11
	[ -n "$mb_localstatedir" ] 	|| mb_localstatedir=$mb_prefix/var
bd5f11
	[ -n "$mb_runstatedir" ] 	|| mb_runstatedir=$mb_localstatedir/run
bd5f11
	[ -n "$mb_datarootdir" ] 	|| mb_datarootdir=$mb_prefix/share
bd5f11
	[ -n "$mb_datadir" ] 		|| mb_datadir=$mb_datarootdir
bd5f11
	[ -n "$mb_infodir" ] 		|| mb_infodir=$mb_datarootdir/info
bd5f11
	[ -n "$mb_localedir" ] 		|| mb_localedir=$mb_datarootdir/locale
bd5f11
	[ -n "$mb_htmldir" ] 		|| mb_htmldir=$mb_docdir
bd5f11
	[ -n "$mb_dvidir" ] 		|| mb_dvidir=$mb_docdir
bd5f11
	[ -n "$mb_pdfdir" ] 		|| mb_pdfdir=$mb_docdir
bd5f11
	[ -n "$mb_psdir" ] 		|| mb_psdir=$mb_docdir
7f5702
cde03b
	# switches
bd5f11
	[ -n "$mb_cflags_debug" ]	|| mb_cflags_debug=$mb_default_cflags_debug
bd5f11
	[ -n "$mb_cflags_common" ]	|| mb_cflags_common=$mb_default_cflags_common
bd5f11
	[ -n "$mb_cflags_cmdline" ]	|| mb_cflags_cmdline=$mb_default_cflags_cmdline
bd5f11
	[ -n "$mb_cflags_config" ]	|| mb_cflags_config=$mb_default_cflags_config
bd5f11
	[ -n "$mb_cflags_sysroot" ]	|| mb_cflags_sysroot=$mb_default_cflags_sysroot
bd5f11
	[ -n "$mb_cflags_os" ]		|| mb_cflags_os=$mb_default_cflags_os
bd5f11
	[ -n "$mb_cflags_site" ]	|| mb_cflags_site=$mb_default_cflags_site
bd5f11
	[ -n "$mb_cflags_path" ]	|| mb_cflags_path=$mb_default_cflags_path
bd5f11
	[ -n "$mb_cflags_strict" ]	|| mb_cflags_strict=$mb_default_cflags_strict
bd5f11
	[ -n "$mb_cflags_util" ]	|| mb_cflags_util=$mb_default_cflags_util
bd5f11
	[ -n "$mb_cflags_last" ]	|| mb_cflags_last=$mb_default_cflags_last
bd5f11
	[ -n "$mb_cflags_once" ]	|| mb_cflags_once=$mb_default_cflags_once
bd5f11
bd5f11
	[ -n "$mb_ldflags_debug" ]	|| mb_ldflags_debug=$mb_default_ldflags_debug
bd5f11
	[ -n "$mb_ldflags_common" ]	|| mb_ldflags_common=$mb_default_ldflags_common
bd5f11
	[ -n "$mb_ldflags_cmdline" ]	|| mb_ldflags_cmdline=$mb_default_ldflags_cmdline
bd5f11
	[ -n "$mb_ldflags_config" ]	|| mb_ldflags_config=$mb_default_ldflags_config
bd5f11
	[ -n "$mb_ldflags_sysroot" ]	|| mb_ldflags_sysroot=$mb_default_ldflags_sysroot
bd5f11
	[ -n "$mb_ldflags_path" ]	|| mb_ldflags_path=$mb_default_ldflags_path
bd5f11
	[ -n "$mb_ldflags_strict" ]	|| mb_ldflags_strict=$mb_default_ldflags_strict
bd5f11
	[ -n "$mb_ldflags_util" ]	|| mb_ldflags_util=$mb_default_ldflags_util
bd5f11
	[ -n "$mb_ldflags_last" ]	|| mb_ldflags_last=$mb_default_ldflags_last
bd5f11
	[ -n "$mb_ldflags_once" ]	|| mb_ldflags_once=$mb_default_ldflags_once
cde03b
cb77c1
	# native switches
bd5f11
	[ -n "$mb_native_cflags" ]	|| mb_native_cflags=$mb_default_native_cflags
bd5f11
	[ -n "$mb_native_ldflags" ]	|| mb_native_ldflags=$mb_default_native_ldflags
cb77c1
d184a6
	# config
bd5f11
	[ -n "$mb_all_static" ]		|| mb_all_static='no'
bd5f11
	[ -n "$mb_all_shared" ]		|| mb_all_shared='no'
bd5f11
	[ -n "$mb_disable_frontend" ]	|| mb_disable_frontend='no'
bd5f11
	[ -n "$mb_disable_static" ]	|| mb_disable_static='no'
bd5f11
	[ -n "$mb_disable_shared" ]	|| mb_disable_shared='no'
d184a6
cde03b
	# host/target
bd5f11
	[ -n "$mb_host" ] 		|| mb_host=$mb_target
bd5f11
	[ -n "$mb_target" ] 		|| mb_target=$mb_host
cde03b
cde03b
	# sysroot
3a8a92
	if [ -n "$mb_sysroot" ]; then
3a8a92
		if [ -z "$mb_cflags_sysroot" ]; then
9093a6
			mb_cflags_sysroot='$(_CFLAGS_SYSROOT)'
cde03b
		fi
cde03b
3a8a92
		if [ -z "$mb_ldflags_sysroot" ]; then
9093a6
			mb_ldflags_sysroot='$(_LDFLAGS_SYSROOT)'
cde03b
		fi
cde03b
	fi
cde03b
cde03b
	# debug
2728dc
	if [ _$mb_debug = _yes ]; then
3a8a92
		if [ -z "$mb_cflags_debug" ]; then
aac228
			mb_cflags_debug='$(_CFLAGS_g3) $(_CFLAGS_O0)'
cde03b
		fi
cde03b
	fi
722923
4f06b3
	# make
4f06b3
	if [ -z "$mb_make" ]; then
4f06b3
		mb_make='make'
4f06b3
	fi
4f06b3
19ccfa
	if [ -z "$mb_makemode" ]; then
19ccfa
		mb_makemode='posix'
724c12
724c12
		printf '%s\n%s\n%s\n\n%s\n\n'        \
724c12
				'ifeq (a,b)'          \
724c12
				'VAR = val'            \
724c12
				'endif'                 \
724c12
				'all:'                   \
724c12
			| ${mb_make} -s -f - 2>/dev/null  \
724c12
		&& mb_makemode='modern'
724c12
19ccfa
	fi
19ccfa
d53f69
	# shell
d53f69
	if [ -z "$mb_shell" ]; then
d53f69
		mb_shell='/bin/sh'
d53f69
	fi
d53f69
722923
	# inherited cflags & ldflags
722923
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
722923
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
41a2ad
41a2ad
	# step epilog
41a2ad
	output_step_epilog
cde03b
}
cde03b
cde03b
598a7f
config_flags()
598a7f
{
41a2ad
	# step prolog
41a2ad
	output_step_prolog ${mb_script} 'config_flags'
41a2ad
598a7f
	mb_ldflags_tmp=" $mb_ldflags "
668aa6
	mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g')
598a7f
598a7f
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
598a7f
		mb_ldflags="$mb_ldflags_libs"
598a7f
		mb_ldflags_util="$mb_ldflags_util -static"
598a7f
	fi
bec9ab
bec9ab
	# ccstrict
2728dc
	if [ _$mb_ccstrict = _yes ]; then
0832a5
		mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef) $(_CFLAGS_Wpedantic)'
bec9ab
	fi
bec9ab
bec9ab
	# ldstrict
2728dc
	if [ _$mb_ldstrict = _yes ]; then
4f9e7b
		mb_ldflags_strict='$(_CFLAGS_Wl___no_undefined)'
bec9ab
	fi
41a2ad
41a2ad
	# step epilog
41a2ad
	output_step_epilog
598a7f
}
598a7f
598a7f
f11003
config_opts()
f11003
{
f11003
	if [ "$mb_avoid_version" = 'yes' ]; then
f11003
		mb_version_opt='none'
f11003
	else
f11003
		mb_version_opt='used'
f11003
	fi
46a33a
46a33a
	if [ "$mb_custom_install_headers" = 'yes' ]; then
46a33a
		mb_install_headers_opt='custom'
46a33a
	else
46a33a
		mb_install_headers_opt='default'
46a33a
	fi
46a33a
46a33a
	if [ "$mb_disable_static" = 'yes' ]; then
46a33a
		mb_static_library_opt='disabled'
46a33a
	else
46a33a
		mb_static_library_opt='enabled'
46a33a
	fi
46a33a
46a33a
	if [ "$mb_disable_shared" = 'yes' ]; then
46a33a
		mb_shared_library_opt='disabled'
46a33a
	else
46a33a
		mb_shared_library_opt='enabled'
46a33a
	fi
46a33a
46a33a
	if [ "$mb_disable_frontend" = 'yes' ]; then
46a33a
		mb_app_frontend_opt='disabled'
46a33a
	else
46a33a
		mb_app_frontend_opt='enabled'
46a33a
	fi
46a33a
46a33a
	if [ "$mb_all_static" = 'yes' ]; then
46a33a
		mb_app_linking_opt='all_static'
46a33a
46a33a
	elif [ "$mb_all_shared" = 'yes' ]; then
46a33a
		mb_app_linking_opt='all_shared'
46a33a
46a33a
	else
46a33a
		mb_app_linking_opt='default'
46a33a
	fi
f11003
}
f11003
cde03b
config_copy()
cde03b
{
41a2ad
	output_step_prolog ${mb_script} 'config_copy'
41a2ad
b17dc7
	mb_var_defs=
b17dc7
	mb_sed_substs=
8beabb
	mb_template="${1:-$mb_project_dir/Makefile.in}"
b17dc7
f11003
	mb_vars=$(cut -d'=' -f1 "$sfrt_config_vars" "$sfrt_opt_vars" \
b17dc7
		| grep -v '^#');
b17dc7
b17dc7
	for __var in $(printf '%s' "$mb_vars"); do
b17dc7
		mb_sed_subst=$(printf '%s %s%s%s'  \
b17dc7
				'-e' "'s^@$__var@"  \
b17dc7
				"^___${__var}___"    \
b17dc7
				"^g'")
b17dc7
b17dc7
		mb_sed_substs="$mb_sed_substs $mb_sed_subst"
b17dc7
b17dc7
		mb_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "mb_${__var}")
b17dc7
		eval mb_var_defs='"$mb_var_defs "$mb_var_def'
b17dc7
	done
b17dc7
8beabb
	eval sed $mb_sed_substs $mb_template         \
8beabb
			| eval m4 $mb_var_defs -      \
8beabb
			| sed -e 's/[[:blank:]]*$//g'  \
b17dc7
		> $mb_pwd/Makefile.tmp
41a2ad
41a2ad
	output_step_epilog
b8199b
}
7e1d96
6d1fc0
b8199b
config_ccenv()
b8199b
{
b8199b
	mkdir -p ./ccenv
b8199b
	touch ./ccenv/host.mk
b8199b
	touch ./ccenv/native.mk
e271dd
41a2ad
	output_section_break
b8199b
	ccenv_set_host_variables
41a2ad
41a2ad
	output_section_break
b8199b
	ccenv_set_native_variables
c65d32
1e22ce
	# implicit --sysroot for use with pkgconf and friends
1e22ce
	if [ -z "$mb_sysroot" ]; then
1e22ce
		mb_sysroot="$ccenv_host_sysroot"
1e22ce
	fi
1e22ce
b1a116
	# require --sysroot when cross-compiling
1e22ce
	if [ "$mb_cchost" != "$mb_native_cchost" ]                   \
1e22ce
			&& [ "$ccenv_host_cc" != "$ccenv_native_cc" ] \
1e22ce
			&& [ -z "$mb_sysroot" ]; then
0d90d3
		mb_pretty=$(printf "%-${#mb_package}s" '')
0d90d3
0d90d3
		error_msg ' !!'
0d90d3
		error_msg "$mb_package: host machine:    $mb_cchost"
0d90d3
		error_msg "$mb_package: host compiler:   $ccenv_host_cc"
0d90d3
0d90d3
		error_msg ' !!'
0d90d3
		error_msg "$mb_package: native machine:  $mb_native_cchost"
0d90d3
		error_msg "$mb_package: native compiler: $ccenv_native_cc"
0d90d3
0d90d3
		error_msg ' !!'
0d90d3
		error_msg "$mb_package: detected host machine and native machine differ, assuming cross-compilation."
0d90d3
0d90d3
		error_msg ' !!'
0d90d3
		error_msg "$mb_package: native compilation mode can be forced via --cchost=$mb_native_cchost"
0d90d3
		error_msg "${mb_pretty}  or otherwise by setting the NATIVE_CC environment variable to '$ccenv_host_cc',"
0d90d3
		error_msg "${mb_pretty}  however that should almost never be necessary; then again,"
0d90d3
		error_msg "${mb_pretty}  forcing native mode when cross-building is strictly prohibited."
b1a116
	fi
b1a116
b1a116
	# re-generate Makefile.tmp
41a2ad
	output_section_break
c65d32
	config_copy
b8199b
}
e271dd
013c47
config_custom_cfgdefs()
013c47
{
013c47
	. $mb_project_dir/project/config/cfgdefs.sh
013c47
}
013c47
e271dd
config_custom()
e271dd
{
2728dc
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
41a2ad
		output_section_break
41a2ad
		output_script_status ${mb_script} \
0506d8
			'invoking project-specific cfgdefs.sh'
41a2ad
013c47
		eval config_custom_cfgdefs "$mb_custom_cfgdefs_args"
41a2ad
41a2ad
		output_section_break
e4f17a
e4f17a
		if [ -f "$mb_project_dir/project/config/Makefile.in" ]; then
e4f17a
			config_copy "$mb_project_dir/project/config/Makefile.in"
e4f17a
			mv $mb_pwd/Makefile.tmp Makefile
e4f17a
		fi
e4f17a
e271dd
		config_copy
e271dd
	fi
7e1d96
2728dc
	if [ _$mb_use_custom_usrdefs = _yes ]; then
41a2ad
		output_section_break
41a2ad
		output_script_status ${mb_scirpt} \
0506d8
			'invoking project-specific usrdefs.sh'
41a2ad
e271dd
		. $mb_project_dir/project/usrdefs.sh
41a2ad
		output_section_break
e271dd
	fi
e271dd
}
e271dd
e271dd
e271dd
config_cfghost()
e271dd
{
41a2ad
	output_step_prolog ${mb_script} 'config_cfghost'
41a2ad
a18dc4
	if [ -z "$mb_cfghost" ]; then
a18dc4
		mb_cfghost=$mb_cchost
a18dc4
	fi
a18dc4
a18dc4
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
a18dc4
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
da372a
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
7e1d96
da372a
	rm  $mb_pwd/Makefile.tmp
d2829c
	mv  $mb_pwd/Makefile.host $mb_pwd/$mb_makefile
41a2ad
41a2ad
	output_step_epilog
cde03b
}
cde03b
cde03b
cde03b
config_host()
cde03b
{
b12adc
	# init
41a2ad
	output_step_prolog ${mb_script} 'config_host'
41a2ad
b12adc
	mb_cfghost_cc="$ccenv_host_cc"
b12adc
	mb_cfghost_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
b12adc
b12adc
	mb_cfghost_cflags=$(${mb_make} -n -f "$mb_makefile" \
b12adc
		.cflags-host)
b12adc
b12adc
	mb_cfghost_cflags="${mb_cfghost_cflags#*: }"
b12adc
b0b5da
	if [ "$mb_cc_environment" = 'freestanding' ]; then
430ec8
		if [ -z "mb_cc_underscore" ]; then
430ec8
			mb_cfghost_start_fn='_start'
430ec8
		else
430ec8
			mb_cfghost_start_fn='start'
430ec8
		fi
430ec8
430ec8
		printf 'int %s(void){return 0;}' "$mb_cfghost_start_fn" \
430ec8
			> "$mb_cfghost_tmpname"
430ec8
430ec8
		mb_cfghost_cflags="$mb_cfghost_cflags -ffreestanding"
430ec8
		mb_cfghost_cflags="$mb_cfghost_cflags -nostdlib"
430ec8
	else
430ec8
		printf 'int main(void){return 0;}' \
430ec8
			> "$mb_cfghost_tmpname"
430ec8
	fi
b12adc
b12adc
	# log
b12adc
	printf '\n' >&3
b12adc
b12adc
	printf '%s\n'                                         \
b12adc
		'#'                                           \
b12adc
		'# verify that that following combination of' \
b12adc
		'# host compiler and host cflags is working.' \
b12adc
		'#'                                           \
b12adc
		>&3
b12adc
b12adc
	printf '\n%s' "$mb_cfghost_cc $ccenv_tmpname -o a.out" >&3
b12adc
d360e0
	for mb_cfghost_cflag in $(printf '%s' "$mb_cfghost_cflags"); do
b12adc
		printf ' \\\n\t%s' "$mb_cfghost_cflag" >&3
b12adc
	done
b12adc
b12adc
	printf '\n\n' >&3
b12adc
b12adc
	# execute
b12adc
	if eval $mb_cfghost_cc "$ccenv_tmpname" -o a.out    \
b12adc
			$(printf '%s' "$mb_cfghost_cflags") \
b12adc
			2>&3; then
b12adc
		rm a.out
b12adc
		rm $mb_cfghost_tmpname
b12adc
		mb_cfghost_ret=0
b12adc
	else
b12adc
		mb_cfghost_ret=1
b12adc
	fi
b12adc
b12adc
	if [ $mb_cfghost_ret = 0 ]; then
b12adc
		output_step_epilog
b12adc
		return 0
b12adc
	fi
cde03b
d2829c
	# should never happen
b12adc
	error_msg
cde03b
	error_msg "configure was able to generate a Makefile for the selected host,"
d015ab
	error_msg "however the host-targeting compiler was found to be missing"
cde03b
	error_msg "at least one of the required headers or features."
cde03b
	exit 2
cde03b
}
cde03b
cde03b
ce4e33
config_fini()
ce4e33
{
ce4e33
	# project-specific post-configuration steps
ce4e33
	if [ _$mb_use_custom_cfgfini = _yes ]; then
ce4e33
		. "$mb_project_dir/project/config/cfgfini.sh"
ce4e33
	fi
ce4e33
}
ce4e33
ce4e33
cde03b
config_status()
cde03b
{
41a2ad
	output_script_status ${mb_script} \
41a2ad
		'configuration completed successfully.'
41a2ad
	printf '\n'
cde03b
}
cde03b
ff655e
ff655e
config_failure()
ff655e
{
0d688b
	if [ _$mb_success = _yes ]; then
0d688b
		return 0
0d688b
	fi
0d688b
0506d8
	printf 'configure info: exiting due to an error.\n' >&3
0506d8
ff655e
	exit 2
ff655e
}
ff655e
ff655e
ff655e
config_success()
ff655e
{
ff655e
	trap '' EXIT
0d688b
	mb_success=yes
ff655e
	exit 0
ff655e
}
ff655e
ff655e
cde03b
# one: init
25fe37
mb_args_defs=
25fe37
mb_args_text=
25fe37
mb_args_idx=0
25fe37
25fe37
init_log
0506d8
0506d8
for arg ; do
25fe37
	mb_args_idx=$((mb_args_idx+1))
25fe37
25fe37
	mb_arg_def=$(printf '%s%s="${%s}"' "-D_" "${mb_args_idx}" "${mb_args_idx}")
25fe37
	eval mb_args_defs='"$mb_args_defs "$mb_arg_def'
25fe37
25fe37
	mb_args_text="$mb_args_text '_$((mb_args_idx))'"
0506d8
done
0506d8
25fe37
printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
25fe37
25fe37
if [ $mb_args_idx -gt 1 ]; then
25fe37
	printf '$ %s' "$mb_script" >&3
25fe37
25fe37
	mb_args_idx=0
25fe37
	mb_args_text=
25fe37
25fe37
	for arg; do
25fe37
		mb_args_idx=$((mb_args_idx+1))
25fe37
		mb_args_text="$mb_args_text"$(printf ' \\\\\n\t%s_%d%s' "'" "$mb_args_idx" "'")
25fe37
	done
25fe37
25fe37
	printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
25fe37
fi
25fe37
cde03b
init_vars
cde03b
verify_build_directory
cde03b
cde03b
cde03b
# two: args
cde03b
for arg ; do
cde03b
	case "$arg" in
b8199b
		--help)
b8199b
			usage
b8199b
			;;
b8199b
		--help=ccenv)
b8199b
			ccenv_usage
b8199b
			;;
b8199b
b8199b
		# ccenv
b8199b
		--cross-compile=*)
b8199b
			mb_cross_compile=${arg#*=}
b8199b
			;;
b8199b
		--compiler=*)
b8199b
			mb_compiler=${arg#*=}
b8199b
			;;
b8199b
		--toolchain=*)
b8199b
			mb_toolchain=${arg#*=}
b8199b
			;;
b8199b
		--zealous)
b8199b
			mb_agnostic=yes
b8199b
			mb_zealous=
b8199b
			;;
b8199b
		--zealous=*)
b8199b
			mb_zealous=${arg#*=}
b8199b
			;;
b8199b
		--ccenv=*)
b8199b
			mb_ccenv=${arg#*=}
cde03b
			;;
cde03b
cde03b
		# dirs
cde03b
		--prefix=*)
3d4f90
			mb_prefix_set=yes
cde03b
			mb_prefix=${arg#*=}
cde03b
			;;
17f6d3
		--exec-prefix=*)
3d4f90
			mb_exec_prefix_set=yes
17f6d3
			mb_exec_prefix=${arg#*=}
17f6d3
			;;
cde03b
		--bindir=*)
92911d
			mb_bindir_set=yes
cde03b
			mb_bindir=${arg#*=}
cde03b
			;;
a6f38d
		--sbindir=*)
a6f38d
			mb_sbindir=${arg#*=}
a6f38d
			;;
cde03b
		--libdir=*)
cde03b
			mb_libdir=${arg#*=}
cde03b
			;;
cde03b
		--includedir=*)
cde03b
			mb_includedir=${arg#*=}
cde03b
			;;
7f5702
		--oldincludedir=*)
7f5702
			mb_oldincludedir=${arg#*=}
7f5702
			;;
cde03b
		--mandir=*)
cde03b
			mb_mandir=${arg#*=}
cde03b
			;;
cde03b
		--libexecdir=*)
cde03b
			mb_libexecdir=${arg#*=}
cde03b
			;;
cde03b
cde03b
7f5702
		--sysconfdir=*)
7f5702
			mb_sysconfdir=${arg#*=}
7f5702
			;;
7f5702
		--sharedstatedir=*)
7f5702
			mb_sharedstatedir=${arg#*=}
7f5702
			;;
7f5702
		--localstatedir=*)
7f5702
			mb_localstatedir=${arg#*=}
7f5702
			;;
7f5702
		--runstatedir=*)
7f5702
			mb_runstatedir=${arg#*=}
7f5702
			;;
7f5702
		--datarootdir=*)
7f5702
			mb_datarootdir=${arg#*=}
7f5702
			;;
7f5702
		--datadir=*)
7f5702
			mb_datadir=${arg#*=}
7f5702
			;;
7f5702
		--infodir=*)
7f5702
			mb_infodir=${arg#*=}
7f5702
			;;
7f5702
		--localedir=*)
7f5702
			mb_localedir=${arg#*=}
7f5702
			;;
7f5702
		--htmldir=*)
7f5702
			mb_htmldir=${arg#*=}
7f5702
			;;
7f5702
		--dvidir=*)
7f5702
			mb_dvidir=${arg#*=}
7f5702
			;;
7f5702
		--pdfdir=*)
7f5702
			mb_pdfdir=${arg#*=}
7f5702
			;;
7f5702
		--psdir=*)
7f5702
			mb_psdir=${arg#*=}
7f5702
			;;
7f5702
4f06b3
		#make
4f06b3
		--make=*)
4f06b3
			mb_make=${arg#*=}
4f06b3
			;;
7f5702
19ccfa
		--makemode=*)
19ccfa
			mb_makemode=${arg#*=}
19ccfa
			;;
19ccfa
7b7ac4
		#pkgconf[ig]
7b7ac4
		--pkgconf=*)
7b7ac4
			mb_pkgconf=${arg#*=}
7b7ac4
			;;
7b7ac4
7b7ac4
		--pkgconfig=*)
7b7ac4
			mb_pkgconf=${arg#*=}
7b7ac4
			;;
7b7ac4
cde03b
		# build
cde03b
		--build=*)
cde03b
			mb_build=${arg#*=}
cde03b
			;;
cde03b
		--host=*)
cde03b
			mb_host=${arg#*=}
cde03b
			;;
7e1d96
		--cchost=*)
7e1d96
			mb_cchost=${arg#*=}
fe273c
			mb_cchost_set=yes
7e1d96
			;;
a18dc4
		--cfghost=*)
a18dc4
			mb_cfghost=${arg#*=}
a18dc4
			;;
cde03b
		--target=*)
cde03b
			mb_target=${arg#*=}
cde03b
			;;
cde03b
		--arch=*)
cde03b
			mb_arch=${arg#*=}
cde03b
			;;
cde03b
		--sysroot=*)
cde03b
			mb_sysroot=${arg#*=}
cde03b
			;;
cde03b
		--shell=*)
cde03b
			mb_shell=${arg#*=}
cde03b
			;;
cde03b
		--debug)
2728dc
			mb_debug=yes
cde03b
			;;
ee3e67
d184a6
		# config
d184a6
		--all-static)
2728dc
			mb_all_static=yes
b2532d
			mb_all_shared=no
d184a6
			;;
d184a6
		--all-shared)
2728dc
			mb_all_shared=yes
b2532d
			mb_all_static=no
d184a6
			;;
4a9807
		--disable-frontend)
2728dc
			mb_disable_frontend=yes
4a9807
			;;
4a9807
		--disable-app)
2728dc
			mb_disable_frontend=yes
4a9807
			;;
4a9807
		--enable-frontend)
4a9807
			mb_disable_frontend='no'
4a9807
			;;
4a9807
		--enable-app)
4a9807
			mb_disable_frontend='no'
4a9807
			;;
d184a6
		--disable-static)
2728dc
			mb_disable_static=yes
d184a6
			;;
d184a6
		--disable-shared)
2728dc
			mb_disable_shared=yes
d184a6
			;;
d184a6
		--enable-static)
d184a6
			mb_disable_static='no'
d184a6
			;;
d184a6
		--enable-shared)
d184a6
			mb_disable_shared='no'
d184a6
			;;
d184a6
bec9ab
		# convenience
bec9ab
		--strict)
2728dc
			mb_ccstrict=yes
2728dc
			mb_ldstrict=yes
bec9ab
			;;
bec9ab
		--ccstrict)
2728dc
			mb_ccstrict=yes
bec9ab
			;;
bec9ab
		--ldstrict)
2728dc
			mb_ldstrict=yes
bec9ab
			;;
bec9ab
ee3e67
		# project
ee3e67
		--nickname=*)
ee3e67
			mb_nickname=${arg#*=}
ee3e67
			;;
c3b00a
		--program-prefix=*)
c3b00a
			mb_program_prefix=${arg#*=}
c3b00a
			;;
67ced2
		--avoid-version)
2728dc
			mb_avoid_version=yes
67ced2
			;;
f7b445
		--source-dir=*)
f7b445
			mb_source_dir=${arg#*=}
aee3db
			mb_source_dir_set=yes
f7b445
			;;
463f3d
		--srcdir=*)
463f3d
			mb_source_dir=${arg#*=}
aee3db
			mb_source_dir_set=yes
463f3d
			;;
ee3e67
b9138e
		# pkgconfig
b9138e
		--pkgname=*)
b9138e
			mb_pkgname=${arg#*=}
b9138e
			;;
b9138e
b9138e
		--pkgdesc=*)
b9138e
			mb_pkgdesc=${arg#*=}
b9138e
			;;
b9138e
b9138e
		--pkgusrc=*)
b9138e
			mb_pkgusrc=${arg#*=}
b9138e
			;;
b9138e
b9138e
		--pkgrepo=*)
b9138e
			mb_pkgrepo=${arg#*=}
b9138e
			;;
b9138e
b9138e
		--pkgpsrc=*)
b9138e
			mb_pkgpsrc=${arg#*=}
b9138e
			;;
b9138e
b9138e
		--pkgdurl=*)
b9138e
			mb_pkgdurl=${arg#*=}
b9138e
			;;
b9138e
5b4717
		--pkgbugs=*)
5b4717
			mb_pkgbugs=${arg#*=}
5b4717
			;;
5b4717
5b4717
		--pkghome=*)
5b4717
			mb_pkghome=${arg#*=}
5b4717
			;;
5b4717
b9138e
		--pkgdefs=*)
b9138e
			mb_pkgdefs=${arg#*=}
b9138e
			;;
b9138e
b9138e
		--pkglibs=*)
b9138e
			mb_pkglibs=${arg#*=}
b9138e
			;;
b9138e
aee3db
		# srcinfo
8abfb9
		--srcinfo=*)
8abfb9
			mb_srcinfo=${arg#*=}
8abfb9
			;;
8abfb9
8abfb9
		--srcsite=*)
8abfb9
			mb_srcsite=${arg#*=}
8abfb9
			;;
8abfb9
8abfb9
		--pgprkey=*)
8abfb9
			mb_pgprkey=${arg#*=}
8abfb9
			;;
8abfb9
8abfb9
		--pgpskey=*)
8abfb9
			mb_pgpskey=${arg#*=}
8abfb9
			;;
8abfb9
aee3db
		--rawball=*)
aee3db
			mb_rawball=${arg#*=}
aee3db
			;;
aee3db
aee3db
		--rawball-url=*)
aee3db
			mb_rawball_url=${arg#*=}
aee3db
			;;
aee3db
aee3db
		--rawball-sha256=*)
aee3db
			mb_rawball_sha256=${arg#*=}
aee3db
			;;
aee3db
aee3db
		--modball=*)
aee3db
			mb_modball=${arg#*=}
aee3db
			;;
aee3db
aee3db
		--modball-url=*)
aee3db
			mb_modball_url=${arg#*=}
aee3db
			;;
aee3db
aee3db
		--modball-sha256=*)
aee3db
			mb_modball_sha256=${arg#*=}
aee3db
			;;
aee3db
aee3db
		--srcball=*)
aee3db
			mb_srcball=${arg#*=}
aee3db
			;;
aee3db
aee3db
		--srcball-url=*)
aee3db
			mb_srcball_url=${arg#*=}
aee3db
			;;
aee3db
aee3db
		--srcball-sha256=*)
aee3db
			mb_srcball_sha256=${arg#*=}
aee3db
			;;
aee3db
6efc00
		# compatibility
6efc00
		--enable-dependency-tracking)
6efc00
			;;
6efc00
		--disable-dependency-tracking)
6efc00
			;;
6efc00
cde03b
		*)
2728dc
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
823a96
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
823a96
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
823a96
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
823a96
				mb_custom_cfgdefs_space=' '
e271dd
			else
e271dd
				error_msg ${arg#}: "unsupported config argument."
e271dd
				exit 2
e271dd
			fi
cde03b
			;;
cde03b
	esac
acb5ff
acb5ff
	mb_safe_path_desc='source directory'
acb5ff
	mb_safe_path_name="$mb_source_dir"
acb5ff
	verify_safe_path
cde03b
done
cde03b
cde03b
cde03b
f7b445
# three: validation
f7b445
verify_source_directory
aee3db
verify_source_info
f7b445
c3b00a
if ! [ -z "$mb_program_prefix" ]; then
c3b00a
	error_msg "--program-prefix is not yet fully support (must be null)."
c3b00a
fi
c3b00a
f7b445
f7b445
f7b445
# four: defaults
cde03b
common_defaults
cde03b
cde03b
f7b445
# five: config
598a7f
config_flags
f11003
config_opts
cde03b
config_copy
b8199b
config_ccenv
e271dd
config_custom
e271dd
config_cfghost
cde03b
config_host
ce4e33
config_fini
cde03b
config_status
cde03b
cde03b
cde03b
# all done
ff655e
config_success