#!@AWK@ -f
# -*- mode: awk; -*-

############################################################
# Copyright (c) 2009-2010 by Aleksey Cheusov
#
# See LICENSE file in the distribution.
############################################################

#
# usage:   _mkc_check_version <reqd> <version>
# example: _mkc_check_version 0.9.0  0.10.0
#

BEGIN {
	reqd = ARGV [1]
	ver  = ARGV [2]

	cnt= split(reqd, arr_reqd, /[.]/)
	if (cnt != 3){
		print "Invalid MKC_REQD " reqd > "/dev/stderr"
		print 0
		exit 0
	}

	cnt= split(ver,  arr_ver,  /[.]/)
	if (cnt != 3){
		print "Invalid MKC_VERSION " ver > "/dev/stderr"
		print 0
		exit 0
	}

	ver  = sprintf("%04d.%04d.%04d",
				   arr_ver [1]+0, arr_ver [2]+0, arr_ver [3]+0)
	reqd = sprintf("%04d.%04d.%04d",
				   arr_reqd [1]+0, arr_reqd [2]+0, arr_reqd [3]+0)

	print (reqd <= ver)
	exit 0
}
