ifndef __GRAPHENE_VERSION_MACROS_H__
define __GRAPHENE_VERSION_MACROS_H__

if  not defined(GRAPHENE_H_INSIDE) and not defined(GRAPHENE_COMPILATION)
.err <"Only graphene.h can be included directly.">
endif

include graphene/graphene-version.inc

GRAPHENE_ENCODE_VERSION macro major,minor,micro
  exitm<(((major) shl 24) or ((minor) shl 16) or ((micro) shl 8))>
  endm

_GRAPHENE_ENCODE_VERSION macro maj,min
  exitm<(((maj) shl 16) or ((min) shl 8))>
  endm

define GRAPHENE_VERSION GRAPHENE_ENCODE_VERSION(GRAPHENE_MAJOR_VERSION,GRAPHENE_MINOR_VERSION,GRAPHENE_MICRO_VERSION)

GRAPHENE_CHECK_VERSION macro major,minor,micro
    if (((major) gt GRAPHENE_MAJOR_VERSION) or
    ((major) eq GRAPHENE_MAJOR_VERSION and (minor) gt GRAPHENE_MINOR_VERSION) or
    ((major) eq GRAPHENE_MAJOR_VERSION and (minor) eq GRAPHENE_MINOR_VERSION and (micro) ge GRAPHENE_MICRO_VERSION)))
        exitm<1>
    else
        exitm<0>
    endif
    endm


if (GRAPHENE_MINOR_VERSION eq 99)
define GRAPHENE_VERSION_CUR_STABLE    _GRAPHENE_ENCODE_VERSION (GRAPHENE_MAJOR_VERSION + 1, 0)
elseif (GRAPHENE_MINOR_VERSION mod 2)
define GRAPHENE_VERSION_CUR_STABLE    _GRAPHENE_ENCODE_VERSION (GRAPHENE_MAJOR_VERSION, GRAPHENE_MINOR_VERSION + 1)
else
define GRAPHENE_VERSION_CUR_STABLE    _GRAPHENE_ENCODE_VERSION (GRAPHENE_MAJOR_VERSION, GRAPHENE_MINOR_VERSION)
endif


if (GRAPHENE_MINOR_VERSION eq 99)
define GRAPHENE_VERSION_PREV_STABLE   _GRAPHENE_ENCODE_VERSION (GRAPHENE_MAJOR_VERSION + 1, 0)
elseif (GRAPHENE_MINOR_VERSION mod 2)
define GRAPHENE_VERSION_PREV_STABLE   _GRAPHENE_ENCODE_VERSION (GRAPHENE_MAJOR_VERSION, GRAPHENE_MINOR_VERSION - 1)
else
define GRAPHENE_VERSION_PREV_STABLE   _GRAPHENE_ENCODE_VERSION (GRAPHENE_MAJOR_VERSION, GRAPHENE_MINOR_VERSION - 2)
endif

define GRAPHENE_VERSION_1_0    _GRAPHENE_ENCODE_VERSION (1, 0)
define GRAPHENE_VERSION_1_2    _GRAPHENE_ENCODE_VERSION (1, 2)
define GRAPHENE_VERSION_1_4    _GRAPHENE_ENCODE_VERSION (1, 4)
define GRAPHENE_VERSION_1_6    _GRAPHENE_ENCODE_VERSION (1, 6)
define GRAPHENE_VERSION_1_8    _GRAPHENE_ENCODE_VERSION (1, 8)
define GRAPHENE_VERSION_1_10   _GRAPHENE_ENCODE_VERSION (1, 10)

ifndef GRAPHENE_VERSION_MIN_REQUIRED
define GRAPHENE_VERSION_MIN_REQUIRED  GRAPHENE_VERSION_1_0
endif

ifndef GRAPHENE_VERSION_MAX_ALLOWED
if GRAPHENE_VERSION_MIN_REQUIRED gt GRAPHENE_VERSION_PREV_STABLE
define GRAPHENE_VERSION_MAX_ALLOWED  GRAPHENE_VERSION_MIN_REQUIRED
else
define GRAPHENE_VERSION_MAX_ALLOWED  GRAPHENE_VERSION_CUR_STABLE
endif
endif


if GRAPHENE_VERSION_MAX_ALLOWED lt GRAPHENE_VERSION_MIN_REQUIRED
.err <"GRAPHENE_VERSION_MAX_ALLOWED must be >= GRAPHENE_VERSION_MIN_REQUIRED">
endif
if GRAPHENE_VERSION_MIN_REQUIRED lt GRAPHENE_VERSION_1_0
.err <"GRAPHENE_VERSION_MIN_REQUIRED must be >= GRAPHENE_VERSION_1_0">
endif

endif
