orbea / cross / slibtool

Forked from cross/slibtool 3 years ago
Clone

Blame configure

9ca8c4
#!/bin/sh
9ca8c4
5ca785
set -eu
5ca785
c0614b
trap config_failure 1 2 EXIT
c0614b
9ca8c4
usage()
9ca8c4
{
9ca8c4
	cat "$mb_project_dir"/config.usage
d2a366
29a758
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
d2a366
		printf '\n\n%s%s\n' \
d2a366
			" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" \
d2a366
			"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
d2a366
d2a366
		printf '%s%s\n' \
d2a366
			"| Listed above are configure's common switches " \
d2a366
			"and environment variables.     |"
d2a366
d2a366
		printf '%s%s\n' \
d2a366
			"| Found below are project-specific variables " \
d2a366
			"and other customization options. |"
d2a366
d2a366
		printf '%s%s\n\n\n' \
d2a366
			" ___________________________________________" \
d2a366
			"__________________________________"
d2a366
d2a366
		cat "$mb_project_dir"/project/config/cfgdefs.usage
d2a366
	fi
d2a366
d2a366
	exit 0
9ca8c4
}
9ca8c4
9ca8c4
error_msg()
9ca8c4
{
4e9619
	echo "$@" >&2
9ca8c4
}
9ca8c4
bd640f
warning_msg()
bd640f
{
bd640f
	echo "$@" >&2
bd640f
}
bd640f
9ca8c4
9ca8c4
init_vars()
9ca8c4
{
bc7f34
	mb_project_dir=$(cd "$(dirname $0)" ; pwd)
5fd494
	mb_pwd=$(pwd)
9ca8c4
43dbe7
	mb_custom_cfgdefs_args=''
43dbe7
	mb_custom_cfgdefs_space=''
43dbe7
3cdb2f
	sfrt_impl_dir=$mb_project_dir/sofort
3cdb2f
	sfrt_config_dir=$sfrt_impl_dir/config
3cdb2f
	sfrt_core_dir=$sfrt_impl_dir/core
3cdb2f
	sfrt_config_vars=$sfrt_config_dir/config.vars
3cdb2f
	sfrt_flag_vars=$sfrt_config_dir/flag.vars
3cdb2f
	sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
3cdb2f
3cdb2f
	mb_make_vars=$(cat $sfrt_config_vars \
eb9c1b
		| grep -v -e '^#' -e '^$' | tr '[:lower:]' '[:upper:]')
103e4c
3cdb2f
	mb_impl_vars=$(cat $sfrt_config_vars \
eb9c1b
		| grep -v -e '^#' -e '^$' | sed 's/^/mb_/g')
eb9c1b
3cdb2f
	mb_proj_vars=$(cat $sfrt_config_vars \
eb9c1b
		| grep -v -e '^#' -e '^$' | sed 's/^/mb_default_/g')
eb9c1b
3cdb2f
	mb_flag_vars=$(cat $sfrt_flag_vars \
eb9c1b
		| grep -v -e '^#' -e '^$')
eb9c1b
eb9c1b
	mb_vars="$mb_make_vars $mb_impl_vars $mb_proj_vars $mb_flag_vars"
eb9c1b
eb9c1b
	for mb_var in $mb_vars ; do
103e4c
		mb_expr=$mb_var='${'$mb_var':-}'
103e4c
		eval "$mb_expr"
103e4c
	done
103e4c
f7f887
	# ccenv
f7f887
	. $mb_project_dir/sofort/ccenv/ccenv.sh
f7f887
890075
	if ! [ -L ./ccenv ]; then
f7f887
		if [ -d ./ccenv ]; then
f7f887
			rm -f ./ccenv/host.mk
f7f887
			rm -f ./ccenv/native.mk
f7f887
			rmdir ./ccenv
f7f887
		fi
f7f887
	fi
f7f887
f7f887
	# config.project
9ca8c4
	if [ -z "$mb_config" ]; then
0d2779
		. $mb_project_dir/config.project
9ca8c4
	else
0d2779
		. "$mb_config"
9ca8c4
	fi
9ca8c4
c45ad1
	# project-specific config definitions
29a758
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
3cdb2f
		cat $sfrt_cfgdefs_in > cfgdefs.mk
801f7b
	else
801f7b
		printf '%s %s\n\n' \
801f7b
				'# this project does not include' \
801f7b
				'a custom config step.'           \
801f7b
			> cfgdefs.mk
3cdb2f
		cat $sfrt_cfgdefs_in >> cfgdefs.mk
c8e23f
c8e23f
		if [ -f $mb_project_dir/project/cfgdefs.in ]; then
c8e23f
			cat $mb_project_dir/project/cfgdefs.in >> cfgdefs.mk
c8e23f
		fi
c45ad1
	fi
c45ad1
c45ad1
	# user build-time overrides
801f7b
	touch usrdefs.mk
c45ad1
be9551
	# project
be9551
	mb_nickname=$NICKNAME
613e01
	mb_source_dir=$SOURCE_DIR
be9551
9ca8c4
	# dirs
9ca8c4
	mb_prefix=$PREFIX
4a022e
	mb_exec_prefix=$EXEC_PREFIX
9ca8c4
	mb_bindir=$BINDIR
67be49
	mb_sbindir=$SBINDIR
9ca8c4
	mb_libdir=$LIBDIR
9ca8c4
	mb_includedir=$INCLUDEDIR
aacf07
	mb_oldincludedir=$OLDINCLUDEDIR
9ca8c4
	mb_mandir=$MANDIR
9ca8c4
	mb_docdir=$DOCDIR
9ca8c4
	mb_libexecdir=$LIBEXECDIR
9ca8c4
aacf07
	mb_sysconfdir=$SYSCONFDIR
aacf07
	mb_sharedstatedir=$SHAREDSTATEDIR
aacf07
	mb_localstatedir=$LOCALSTATEDIR
aacf07
	mb_runstatedir=$RUNSTATEDIR
aacf07
	mb_datarootdir=$DATAROOTDIR
aacf07
	mb_datadir=$DATADIR
aacf07
	mb_infodir=$INFODIR
aacf07
	mb_localedir=$LOCALEDIR
aacf07
	mb_htmldir=$HTMLDIR
aacf07
	mb_dvidir=$DVIDIR
aacf07
	mb_pdfdir=$PDFDIR
aacf07
	mb_psdir=$PSDIR
aacf07
9ca8c4
9ca8c4
	# build
9ca8c4
	mb_build=$BUILD
f83f76
	mb_cchost=$CCHOST
f9d92c
	mb_cfghost=$CFGHOST
9ca8c4
	mb_arch=$ARCH
9ca8c4
	mb_compiler=$COMPILER
9ca8c4
	mb_toolchain=$TOOLCHAIN
9ca8c4
	mb_sysroot=$SYSROOT
9ca8c4
	mb_cross_compile=$CROSS_COMPILE
9ca8c4
	mb_shell=$SHELL
9ca8c4
9ca8c4
	# switches
9ca8c4
	mb_cflags=$CFLAGS
9ca8c4
	mb_cflags_debug=$CFLAGS_DEBUG
9ca8c4
	mb_cflags_common=$CFLAGS_COMMON
9ca8c4
	mb_cflags_cmdline=$CFLAGS_CMDLINE
9ca8c4
	mb_cflags_config=$CFLAGS_CONFIG
9ca8c4
	mb_cflags_sysroot=$CFLAGS_SYSROOT
9ca8c4
	mb_cflags_os=$CFLAGS_OS
9ca8c4
	mb_cflags_site=$CFLAGS_SITE
9ca8c4
	mb_cflags_path=$CFLAGS_PATH
1e6e10
	mb_cflags_strict=$CFLAGS_STRICT
fbb1cf
	mb_cflags_util=$CFLAGS_UTIL
c5c9ea
	mb_cflags_last=$CFLAGS_LAST
c5c9ea
	mb_cflags_once=$CFLAGS_ONCE
9ca8c4
9ca8c4
	mb_ldflags=$LDFLAGS
9ca8c4
	mb_ldflags_debug=$LDFLAGS_DEBUG
9ca8c4
	mb_ldflags_common=$LDFLAGS_COMMON
9ca8c4
	mb_ldflags_cmdline=$LDFLAGS_CMDLINE
9ca8c4
	mb_ldflags_config=$LDFLAGS_CONFIG
9ca8c4
	mb_ldflags_sysroot=$LDFLAGS_SYSROOT
9ca8c4
	mb_ldflags_path=$LDFLAGS_PATH
1e6e10
	mb_ldflags_strict=$LDFLAGS_STRICT
fbb1cf
	mb_ldflags_util=$LDFLAGS_UTIL
c5c9ea
	mb_ldflags_last=$LDFLAGS_LAST
c5c9ea
	mb_ldflags_once=$LDFLAGS_ONCE
9ca8c4
9ca8c4
	mb_pe_subsystem=$PE_SUBSYSTEM
9ca8c4
	mb_pe_image_base=$PE_IMAGE_BASE
9ca8c4
9ca8c4
	# overrides
9ca8c4
	mb_user_cc=$CC
9ca8c4
	mb_user_cpp=$CPP
9ca8c4
	mb_user_cxx=$CXX
f7f887
f7f887
	mb_native_cc=$NATIVE_CC
f7f887
	mb_native_cpp=$NATIVE_CPP
f7f887
	mb_native_cxx=$NATIVE_CXX
f7f887
f7f887
	mb_native_host=$NATIVE_HOST
f7f887
	mb_native_cfghost=$NATIVE_CFGHOST
f7f887
	mb_native_cflags=$NATIVE_CFLAGS
f7f887
	mb_native_ldflags=$NATIVE_LDFLAGS
fc67fb
fc67fb
	mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
fc67fb
	mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
9ca8c4
}
9ca8c4
9ca8c4
9ca8c4
verify_build_directory()
9ca8c4
{
9ca8c4
	if [ "$mb_project_dir" = "$mb_pwd" ]; then
29a758
		if [ _$mb_require_out_of_tree = _yes ]; then
9ca8c4
			error_msg "$mb_package: out-of-tree builds are required."
9ca8c4
			error_msg "please invoke configure again from a clean build directory."
0d2779
			exit 1
9ca8c4
		else
9ca8c4
			mb_project_dir='.'
9ca8c4
		fi
9ca8c4
	fi
c0614b
c0614b
	rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
9ca8c4
}
9ca8c4
9ca8c4
613e01
verify_source_directory()
613e01
{
613e01
	if [ -z "$mb_source_dir" ]; then
29a758
		if [ _$mb_require_source_dir = _yes ]; then
613e01
			error_msg "$mb_package: specifying an external source directory is required."
613e01
			error_msg "you can set the source directory either via --source-dir=<path>,"
613e01
			error_msg "or by setting the SOURCE_DIR variable."
0d2779
			exit 1
613e01
		fi
613e01
	fi
613e01
}
613e01
613e01
9ca8c4
common_defaults()
9ca8c4
{
613e01
	# git
613e01
	if [ -n "$mb_source_dir" ]; then
613e01
		if [ -d "$mb_source_dir/.git" ]; then
8ad14b
			mb_git_reference_index="\$(SOURCE_DIR)/.git/index"
613e01
		fi
613e01
	elif [ -d "$mb_project_dir/.git" ]; then
8ad14b
		mb_git_reference_index="\$(PROJECT_DIR)/.git/index"
613e01
	fi
613e01
be9551
	# project
be9551
	[ -z "$mb_nickname" ] 		&& mb_nickname=$mb_package
613e01
	[ -z "$mb_source_dir" ] 	&& mb_source_dir=$mb_project_dir
2c8d99
	[ -z "$mb_avoid_version" ] 	&& mb_avoid_version='no'
be9551
bb8747
	# pkgconfig
bb8747
	[ -z "$mb_pkgname" ]		&& mb_pkgname="$mb_default_pkgname"
bb8747
	[ -z "$mb_pkgdesc" ]		&& mb_pkgdesc="$mb_default_pkgdesc"
bb8747
	[ -z "$mb_pkgusrc" ]		&& mb_pkgusrc="$mb_default_pkgusrc"
bb8747
	[ -z "$mb_pkgrepo" ]		&& mb_pkgrepo="$mb_default_pkgrepo"
bb8747
	[ -z "$mb_pkgpsrc" ]		&& mb_pkgpsrc="$mb_default_pkgpsrc"
bb8747
	[ -z "$mb_pkgdurl" ]		&& mb_pkgdurl="$mb_default_pkgdurl"
bb8747
	[ -z "$mb_pkgdefs" ]		&& mb_pkgdefs="$mb_default_pkgdefs"
bb8747
	[ -z "$mb_pkglibs" ]		&& mb_pkglibs="$mb_default_pkglibs"
bb8747
9ca8c4
	# dirs
250816
	[ -z "$mb_prefix" ] 		&& [ -z "$mb_prefix_set" ] \
250816
					&& mb_prefix='/usr/local'
250816
250816
	[ -z "$mb_exec_prefix" ] 	&& [ -z "$mb_exec_prefix_set" ]	\
250816
					&& mb_exec_prefix=$mb_prefix
250816
290087
	[ -z "$mb_bindir" ] 		&& [ -z "$mb_bindir_set" ] \
290087
					&& [ -z "$mb_bindir_basename" ] \
290087
					&& mb_bindir=$mb_exec_prefix/bin
290087
290087
	[ -z "$mb_bindir" ] 		&& [ -z "$mb_bindir_set" ] \
290087
					&& mb_bindir=$mb_exec_prefix/$mb_bindir_basename
290087
67be49
	[ -z "$mb_sbindir" ] 		&& mb_sbindir=$mb_exec_prefix/sbin
664484
	[ -z "$mb_libdir" ] 		&& mb_libdir=$mb_exec_prefix/lib
664484
	[ -z "$mb_includedir" ]		&& mb_includedir=$mb_prefix/include
aacf07
	[ -z "$mb_oldincludedir" ]	&& mb_oldincludedir=$mb_prefix/include
664484
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
664484
	[ -z "$mb_mandir" ] 		&& mb_mandir=$mb_datarootdir/man
664484
	[ -z "$mb_docdir" ] 		&& mb_docdir=$mb_datarootdir/doc
664484
	[ -z "$mb_libexecdir" ]		&& mb_libexecdir=$mb_exec_prefix/libexec
9ca8c4
aacf07
	[ -z "$mb_sysconfdir" ] 	&& mb_sysconfdir=$mb_exec_prefix/etc
aacf07
	[ -z "$mb_sharedstatedir" ] 	&& mb_sharedstatedir=$mb_prefix/com
aacf07
	[ -z "$mb_localstatedir" ] 	&& mb_localstatedir=$mb_prefix/var
aacf07
	[ -z "$mb_runstatedir" ] 	&& mb_runstatedir=$mb_localstatedir/run
aacf07
	[ -z "$mb_datarootdir" ] 	&& mb_datarootdir=$mb_prefix/share
aacf07
	[ -z "$mb_datadir" ] 		&& mb_datadir=$mb_datarootdir
aacf07
	[ -z "$mb_infodir" ] 		&& mb_infodir=$mb_datarootdir/info
aacf07
	[ -z "$mb_localedir" ] 		&& mb_localedir=$mb_datarootdir/locale
aacf07
	[ -z "$mb_htmldir" ] 		&& mb_htmldir=$mb_docdir
aacf07
	[ -z "$mb_dvidir" ] 		&& mb_dvidir=$mb_docdir
aacf07
	[ -z "$mb_pdfdir" ] 		&& mb_pdfdir=$mb_docdir
aacf07
	[ -z "$mb_psdir" ] 		&& mb_psdir=$mb_docdir
aacf07
9ca8c4
	# switches
9ca8c4
	[ -z "$mb_cflags_debug" ]	&& mb_cflags_debug=$mb_default_cflags_debug
9ca8c4
	[ -z "$mb_cflags_common" ]	&& mb_cflags_common=$mb_default_cflags_common
9ca8c4
	[ -z "$mb_cflags_cmdline" ]	&& mb_cflags_cmdline=$mb_default_cflags_cmdline
9ca8c4
	[ -z "$mb_cflags_config" ]	&& mb_cflags_config=$mb_default_cflags_config
9ca8c4
	[ -z "$mb_cflags_sysroot" ]	&& mb_cflags_sysroot=$mb_default_cflags_sysroot
9ca8c4
	[ -z "$mb_cflags_os" ]		&& mb_cflags_os=$mb_default_cflags_os
9ca8c4
	[ -z "$mb_cflags_site" ]	&& mb_cflags_site=$mb_default_cflags_site
9ca8c4
	[ -z "$mb_cflags_path" ]	&& mb_cflags_path=$mb_default_cflags_path
1e6e10
	[ -z "$mb_cflags_strict" ]	&& mb_cflags_strict=$mb_default_cflags_strict
fbb1cf
	[ -z "$mb_cflags_util" ]	&& mb_cflags_util=$mb_default_cflags_util
c5c9ea
	[ -z "$mb_cflags_last" ]	&& mb_cflags_last=$mb_default_cflags_last
c5c9ea
	[ -z "$mb_cflags_once" ]	&& mb_cflags_once=$mb_default_cflags_once
9ca8c4
9ca8c4
	[ -z "$mb_ldflags_debug" ]	&& mb_ldflags_debug=$mb_default_ldflags_debug
9ca8c4
	[ -z "$mb_ldflags_common" ]	&& mb_ldflags_common=$mb_default_ldflags_common
9ca8c4
	[ -z "$mb_ldflags_cmdline" ]	&& mb_ldflags_cmdline=$mb_default_ldflags_cmdline
9ca8c4
	[ -z "$mb_ldflags_config" ]	&& mb_ldflags_config=$mb_default_ldflags_config
9ca8c4
	[ -z "$mb_ldflags_sysroot" ]	&& mb_ldflags_sysroot=$mb_default_ldflags_sysroot
9ca8c4
	[ -z "$mb_ldflags_path" ]	&& mb_ldflags_path=$mb_default_ldflags_path
1e6e10
	[ -z "$mb_ldflags_strict" ]	&& mb_ldflags_strict=$mb_default_ldflags_strict
fbb1cf
	[ -z "$mb_ldflags_util" ]	&& mb_ldflags_util=$mb_default_ldflags_util
c5c9ea
	[ -z "$mb_ldflags_last" ]	&& mb_ldflags_last=$mb_default_ldflags_last
c5c9ea
	[ -z "$mb_ldflags_once" ]	&& mb_ldflags_once=$mb_default_ldflags_once
9ca8c4
12b021
	# native switches
12b021
	[ -z "$mb_native_cflags" ]	&& mb_native_cflags=$mb_default_native_cflags
12b021
	[ -z "$mb_native_ldflags" ]	&& mb_native_ldflags=$mb_default_native_ldflags
12b021
ffb3a0
	# config
ffb3a0
	[ -z "$mb_all_static" ]		&& mb_all_static='no'
ffb3a0
	[ -z "$mb_all_shared" ]		&& mb_all_shared='no'
bf8bd3
	[ -z "$mb_disable_frontend" ]	&& mb_disable_frontend='no'
ffb3a0
	[ -z "$mb_disable_static" ]	&& mb_disable_static='no'
ffb3a0
	[ -z "$mb_disable_shared" ]	&& mb_disable_shared='no'
ffb3a0
9ca8c4
	# host/target
9ca8c4
	[ -z "$mb_host" ] 		&& mb_host=$mb_target
9ca8c4
	[ -z "$mb_target" ] 		&& mb_target=$mb_host
9ca8c4
9ca8c4
	# sysroot
9ca8c4
	if [ -n "$mb_sysroot" ]; then
9ca8c4
		if [ -z "$mb_cflags_sysroot" ]; then
9ca8c4
			mb_cflags_sysroot="--sysroot=$mb_sysroot"
9ca8c4
		fi
9ca8c4
9ca8c4
		if [ -z "$mb_ldflags_sysroot" ]; then
d561f3
			mb_ldflags_sysroot="--sysroot=$mb_sysroot"
9ca8c4
		fi
9ca8c4
	fi
9ca8c4
9ca8c4
	# debug
29a758
	if [ _$mb_debug = _yes ]; then
9ca8c4
		if [ -z "$mb_cflags_debug" ]; then
9ca8c4
			mb_cflags_debug='-g3 -O0'
9ca8c4
		fi
9ca8c4
	fi
bdbc6b
7e32ce
	# shell
7e32ce
	if [ -z "$mb_shell" ]; then
7e32ce
		mb_shell='/bin/sh'
7e32ce
	fi
7e32ce
bdbc6b
	# inherited cflags & ldflags
bdbc6b
	mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags"
bdbc6b
	mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags"
9ca8c4
}
9ca8c4
9ca8c4
b89c8d
config_flags()
b89c8d
{
b89c8d
	mb_ldflags_tmp=" $mb_ldflags "
5fd494
	mb_ldflags_libs=$(echo "$mb_ldflags_tmp" | sed 's/ -static / /g')
b89c8d
b89c8d
	if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then
b89c8d
		mb_ldflags="$mb_ldflags_libs"
b89c8d
		mb_ldflags_util="$mb_ldflags_util -static"
b89c8d
	fi
1e6e10
1e6e10
	# ccstrict
29a758
	if [ _$mb_ccstrict = _yes ]; then
1e6e10
		mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
1e6e10
	fi
1e6e10
1e6e10
	# ldstrict
29a758
	if [ _$mb_ldstrict = _yes ]; then
1e6e10
		mb_ldflags_strict='-Wl,--no-undefined'
1e6e10
	fi
b89c8d
}
b89c8d
b89c8d
9ca8c4
config_copy()
9ca8c4
{
3cdb2f
	mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \
eb9c1b
			| grep -v '^#')
eb9c1b
eb9c1b
	mb_sed_substs=" \
eb9c1b
		$(for __var in $mb_vars; do                  \
eb9c1b
			printf '%s"$%s"%s' "-e 's^@$__var@^'" \
eb9c1b
				"mb_$__var" "'^g' ";           \
eb9c1b
		done)"
eb9c1b
eb9c1b
	eval sed $mb_sed_substs \
eb9c1b
		$mb_project_dir/Makefile.in    \
43a259
			| sed -e 's/[[:blank:]]*$//g' \
eb9c1b
			> $mb_pwd/Makefile.tmp
f7f887
}
f83f76
4a289f
f7f887
config_ccenv()
f7f887
{
f7f887
	mkdir -p ./ccenv
f7f887
	touch ./ccenv/host.mk
f7f887
	touch ./ccenv/native.mk
d2a366
f7f887
	ccenv_set_host_variables
f7f887
	ccenv_set_native_variables
853512
853512
	config_copy
f7f887
}
d2a366
d2a366
config_custom()
d2a366
{
29a758
	if [ _$mb_use_custom_cfgdefs = _yes ]; then
43dbe7
		eval . $mb_project_dir/project/config/cfgdefs.sh \
43dbe7
			"$mb_custom_cfgdefs_args"
d2a366
		config_copy
d2a366
	fi
f83f76
29a758
	if [ _$mb_use_custom_usrdefs = _yes ]; then
d2a366
		. $mb_project_dir/project/usrdefs.sh
d2a366
	fi
d2a366
}
d2a366
d2a366
d2a366
config_cfghost()
d2a366
{
f9d92c
	if [ -z "$mb_cfghost" ]; then
f9d92c
		mb_cfghost=$mb_cchost
f9d92c
	fi
f9d92c
f9d92c
	sed		-e 's^@cchost@^'"$mb_cchost"'^g'     \
f9d92c
			-e 's^@cfghost@^'"$mb_cfghost"'^g'   \
0d2779
		$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
f83f76
0d2779
	rm  $mb_pwd/Makefile.tmp
0d2779
	mv  $mb_pwd/Makefile.host $mb_pwd/Makefile
9ca8c4
}
9ca8c4
9ca8c4
9ca8c4
config_host()
9ca8c4
{
9ca8c4
	make -s host.tag && return 0
9ca8c4
9ca8c4
	error_msg "configure was able to generate a Makefile for the selected host,"
9ca8c4
	error_msg "however the host-targeting compiler was found to be missing"
9ca8c4
	error_msg "at least one of the required headers or features."
9ca8c4
	exit 2
9ca8c4
}
9ca8c4
9ca8c4
9ca8c4
config_status()
9ca8c4
{
9ca8c4
	printf "\n\n"
9ca8c4
	make .display
9ca8c4
	printf "\nconfiguration completed successfully.\n\n"
9ca8c4
}
9ca8c4
c0614b
c0614b
config_failure()
c0614b
{
c0614b
	if [ -f Makefile ]; then
c0614b
		mb_error='failed to use the generated Makefile.'
c0614b
		printf '\n%s: error: %s\n' "${0}" "$mb_error" >&2
c0614b
		mv Makefile Makefile.failed
c0614b
	fi
c0614b
c0614b
	exit 2
c0614b
}
c0614b
c0614b
c0614b
config_success()
c0614b
{
c0614b
	trap '' EXIT
c0614b
	exit 0
c0614b
}
c0614b
c0614b
9ca8c4
# one: init
9ca8c4
init_vars
9ca8c4
verify_build_directory
9ca8c4
9ca8c4
9ca8c4
# two: args
9ca8c4
for arg ; do
9ca8c4
	case "$arg" in
f7f887
		--help)
f7f887
			usage
f7f887
			;;
f7f887
		--help=ccenv)
f7f887
			ccenv_usage
f7f887
			;;
f7f887
f7f887
		# ccenv
f7f887
		--cross-compile=*)
f7f887
			mb_cross_compile=${arg#*=}
f7f887
			;;
f7f887
		--compiler=*)
f7f887
			mb_compiler=${arg#*=}
f7f887
			;;
f7f887
		--toolchain=*)
f7f887
			mb_toolchain=${arg#*=}
f7f887
			;;
f7f887
		--zealous)
f7f887
			mb_agnostic=yes
f7f887
			mb_zealous=
f7f887
			;;
f7f887
		--zealous=*)
f7f887
			mb_zealous=${arg#*=}
f7f887
			;;
f7f887
		--ccenv=*)
f7f887
			mb_ccenv=${arg#*=}
9ca8c4
			;;
9ca8c4
9ca8c4
		# dirs
9ca8c4
		--prefix=*)
250816
			mb_prefix_set=yes
9ca8c4
			mb_prefix=${arg#*=}
9ca8c4
			;;
4a022e
		--exec-prefix=*)
250816
			mb_exec_prefix_set=yes
4a022e
			mb_exec_prefix=${arg#*=}
4a022e
			;;
9ca8c4
		--bindir=*)
290087
			mb_bindir_set=yes
9ca8c4
			mb_bindir=${arg#*=}
9ca8c4
			;;
67be49
		--sbindir=*)
67be49
			mb_sbindir=${arg#*=}
67be49
			;;
9ca8c4
		--libdir=*)
9ca8c4
			mb_libdir=${arg#*=}
9ca8c4
			;;
9ca8c4
		--includedir=*)
9ca8c4
			mb_includedir=${arg#*=}
9ca8c4
			;;
aacf07
		--oldincludedir=*)
aacf07
			mb_oldincludedir=${arg#*=}
aacf07
			;;
9ca8c4
		--mandir=*)
9ca8c4
			mb_mandir=${arg#*=}
9ca8c4
			;;
9ca8c4
		--libexecdir=*)
9ca8c4
			mb_libexecdir=${arg#*=}
9ca8c4
			;;
9ca8c4
9ca8c4
aacf07
		--sysconfdir=*)
aacf07
			mb_sysconfdir=${arg#*=}
aacf07
			;;
aacf07
		--sharedstatedir=*)
aacf07
			mb_sharedstatedir=${arg#*=}
aacf07
			;;
aacf07
		--localstatedir=*)
aacf07
			mb_localstatedir=${arg#*=}
aacf07
			;;
aacf07
		--runstatedir=*)
aacf07
			mb_runstatedir=${arg#*=}
aacf07
			;;
aacf07
		--datarootdir=*)
aacf07
			mb_datarootdir=${arg#*=}
aacf07
			;;
aacf07
		--datadir=*)
aacf07
			mb_datadir=${arg#*=}
aacf07
			;;
aacf07
		--infodir=*)
aacf07
			mb_infodir=${arg#*=}
aacf07
			;;
aacf07
		--localedir=*)
aacf07
			mb_localedir=${arg#*=}
aacf07
			;;
aacf07
		--htmldir=*)
aacf07
			mb_htmldir=${arg#*=}
aacf07
			;;
aacf07
		--dvidir=*)
aacf07
			mb_dvidir=${arg#*=}
aacf07
			;;
aacf07
		--pdfdir=*)
aacf07
			mb_pdfdir=${arg#*=}
aacf07
			;;
aacf07
		--psdir=*)
aacf07
			mb_psdir=${arg#*=}
aacf07
			;;
aacf07
aacf07
9ca8c4
		# build
9ca8c4
		--build=*)
9ca8c4
			mb_build=${arg#*=}
9ca8c4
			;;
9ca8c4
		--host=*)
9ca8c4
			mb_host=${arg#*=}
9ca8c4
			;;
f83f76
		--cchost=*)
f83f76
			mb_cchost=${arg#*=}
f83f76
			;;
f9d92c
		--cfghost=*)
f9d92c
			mb_cfghost=${arg#*=}
f9d92c
			;;
9ca8c4
		--target=*)
9ca8c4
			mb_target=${arg#*=}
9ca8c4
			;;
9ca8c4
		--arch=*)
9ca8c4
			mb_arch=${arg#*=}
9ca8c4
			;;
9ca8c4
		--sysroot=*)
9ca8c4
			mb_sysroot=${arg#*=}
9ca8c4
			;;
9ca8c4
		--shell=*)
9ca8c4
			mb_shell=${arg#*=}
9ca8c4
			;;
9ca8c4
		--debug)
29a758
			mb_debug=yes
9ca8c4
			;;
be9551
ffb3a0
		# config
ffb3a0
		--all-static)
29a758
			mb_all_static=yes
ffb3a0
			;;
ffb3a0
		--all-shared)
29a758
			mb_all_shared=yes
ffb3a0
			;;
bf8bd3
		--disable-frontend)
29a758
			mb_disable_frontend=yes
bf8bd3
			;;
bf8bd3
		--disable-app)
29a758
			mb_disable_frontend=yes
bf8bd3
			;;
bf8bd3
		--enable-frontend)
bf8bd3
			mb_disable_frontend='no'
bf8bd3
			;;
bf8bd3
		--enable-app)
bf8bd3
			mb_disable_frontend='no'
bf8bd3
			;;
ffb3a0
		--disable-static)
29a758
			mb_disable_static=yes
ffb3a0
			;;
ffb3a0
		--disable-shared)
29a758
			mb_disable_shared=yes
ffb3a0
			;;
ffb3a0
		--enable-static)
ffb3a0
			mb_disable_static='no'
ffb3a0
			;;
ffb3a0
		--enable-shared)
ffb3a0
			mb_disable_shared='no'
ffb3a0
			;;
ffb3a0
1e6e10
		# convenience
1e6e10
		--strict)
29a758
			mb_ccstrict=yes
29a758
			mb_ldstrict=yes
1e6e10
			;;
1e6e10
		--ccstrict)
29a758
			mb_ccstrict=yes
1e6e10
			;;
1e6e10
		--ldstrict)
29a758
			mb_ldstrict=yes
1e6e10
			;;
1e6e10
be9551
		# project
be9551
		--nickname=*)
be9551
			mb_nickname=${arg#*=}
be9551
			;;
7e3001
		--program-prefix=*)
7e3001
			mb_program_prefix=${arg#*=}
7e3001
			;;
2c8d99
		--avoid-version)
29a758
			mb_avoid_version=yes
2c8d99
			;;
613e01
		--source-dir=*)
613e01
			mb_source_dir=${arg#*=}
613e01
			;;
be9551
bb8747
		# pkgconfig
bb8747
		--pkgname=*)
bb8747
			mb_pkgname=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgdesc=*)
bb8747
			mb_pkgdesc=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgusrc=*)
bb8747
			mb_pkgusrc=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgrepo=*)
bb8747
			mb_pkgrepo=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgpsrc=*)
bb8747
			mb_pkgpsrc=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgdurl=*)
bb8747
			mb_pkgdurl=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkgdefs=*)
bb8747
			mb_pkgdefs=${arg#*=}
bb8747
			;;
bb8747
bb8747
		--pkglibs=*)
bb8747
			mb_pkglibs=${arg#*=}
bb8747
			;;
bb8747
25d614
		# compatibility
25d614
		--enable-dependency-tracking)
25d614
			;;
25d614
		--disable-dependency-tracking)
25d614
			;;
25d614
9ca8c4
		*)
29a758
			if [ _$mb_use_custom_cfgdefs = _yes ]; then
43dbe7
				mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
43dbe7
				mb_escaped_arg="$mb_custom_cfgdefs_space$mb_escaped_arg"
43dbe7
				mb_custom_cfgdefs_args="$mb_custom_cfgdefs_args$mb_escaped_arg"
43dbe7
				mb_custom_cfgdefs_space=' '
d2a366
			else
d2a366
				error_msg ${arg#}: "unsupported config argument."
d2a366
				exit 2
d2a366
			fi
9ca8c4
			;;
9ca8c4
	esac
9ca8c4
done
9ca8c4
9ca8c4
9ca8c4
613e01
# three: validation
613e01
verify_source_directory
613e01
7e3001
if ! [ -z "$mb_program_prefix" ]; then
7e3001
	error_msg "--program-prefix is not yet fully support (must be null)."
7e3001
fi
7e3001
613e01
613e01
613e01
# four: defaults
9ca8c4
common_defaults
9ca8c4
9ca8c4
613e01
# five: config
b89c8d
config_flags
9ca8c4
config_copy
f7f887
config_ccenv
d2a366
config_custom
d2a366
config_cfghost
9ca8c4
config_host
9ca8c4
config_status
9ca8c4
9ca8c4
9ca8c4
# all done
c0614b
config_success