Blame configure

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