Blame configure

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