Blame configure

dd89bb
#!/bin/sh
dd89bb
dd89bb
# a simple configure-make wrapper for use in conjunction with the 'lazy' build script.
dd89bb
# 'lazy' is deviant, occasionally useful, and permissively licensed; get_lazy() below,
dd89bb
# then look for configure.template in the root directory.
dd89bb
dd89bb
init_vars()
dd89bb
{
dd89bb
	lz_config_dir=`readlink -f $(dirname $0)`
dd89bb
	lz_pwd=`pwd`
dd89bb
dd89bb
	if [ x"$lz_config" = x ]; then
dd89bb
		. $lz_config_dir/config.lzy || exit 2
dd89bb
	else
dd89bb
		. "$lz_config" || exit 2
dd89bb
	fi
dd89bb
}
dd89bb
dd89bb
dd89bb
error_msg()
dd89bb
{
dd89bb
	echo $@ >&2
dd89bb
}
dd89bb
dd89bb
dd89bb
require_out_of_tree()
dd89bb
{
dd89bb
	if [ x"$lz_config_dir" = x"$lz_pwd" ]; then
dd89bb
		error_msg "$lz_package: out-of-tree builds are required."
dd89bb
		error_msg "please invoke configure again from a clean build directory."
dd89bb
		exit 2
dd89bb
	fi
dd89bb
dd89bb
	return 0
dd89bb
}
dd89bb
dd89bb
dd89bb
get_lazy()
dd89bb
{
dd89bb
	which lazy && lazy=`which lazy` && return 0
dd89bb
dd89bb
	if ! [ -d slazy ]; then
dd89bb
		git clone git://midipix.org/lazy slazy || exit 2
dd89bb
	fi
dd89bb
dd89bb
	lazy=$lz_pwd/slazy/lazy
dd89bb
}
dd89bb
dd89bb
dd89bb
lazy_approach()
dd89bb
{
dd89bb
	if [ x"$lz_prefix" = x ]; then
dd89bb
		error_msg "prefix is required."
dd89bb
		exit 2
dd89bb
	fi
dd89bb
dd89bb
	if [ x"$lz_arch" = x ];     then lz_arch=$lz_default_arch; fi
dd89bb
	if [ x"$lz_subarch" = x ];  then lz_subarch=$lz_default_subarch; fi
dd89bb
	if [ x"$lz_target" = x ];   then lz_target=$lz_default_target; fi
dd89bb
	if [ x"$lz_compiler" = x ]; then lz_compiler=$lz_default_compiler; fi
dd89bb
	if [ x"$lz_compiler" = x ]; then lz_compiler=gcc; fi
dd89bb
dd89bb
	$lazy -x config	$lz_debug	\
dd89bb
		-t $lz_target		\
dd89bb
		-a $lz_arch		\
dd89bb
		-c $lz_compiler		\
dd89bb
		-n $lz_package		\
dd89bb
		-p $lz_config_dir	\
dd89bb
		-f $lz_prefix		\
dd89bb
		|| exit 2
dd89bb
dd89bb
}
dd89bb
dd89bb
dd89bb
lazy_copy()
dd89bb
{
dd89bb
	cp "$lz_config_dir/Makefile.in" "$lz_pwd/Makefile"
dd89bb
}
dd89bb
dd89bb
dd89bb
for arg ; do
dd89bb
	case "$arg" in
dd89bb
		--help)	usage
dd89bb
			;;
dd89bb
dd89bb
		--prefix=*)
dd89bb
			lz_prefix=${arg#*=}
dd89bb
			;;
dd89bb
		--host=*)
dd89bb
			lz_target=${arg#*=}
dd89bb
			;;
dd89bb
		--target=*)
dd89bb
			lz_target=${arg#*=}
dd89bb
			;;
dd89bb
		--compiler=*)
dd89bb
			lz_compiler=${arg#*=}
dd89bb
			;;
dd89bb
		--config=*)
dd89bb
			lz_config=${arg#*=}
dd89bb
			;;
dd89bb
		--debug)
dd89bb
			lz_debug='-d'
dd89bb
			;;
dd89bb
		*)
dd89bb
			error_msg ${arg#}: "unsupported config argument."
dd89bb
			exit 2
dd89bb
			;;
dd89bb
	esac
dd89bb
done
dd89bb
dd89bb
dd89bb
init_vars
dd89bb
require_out_of_tree
dd89bb
get_lazy
dd89bb
lazy_approach
dd89bb
lazy_copy