Blame configure

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