{{include "license.h"}}

#ifndef {{NAME}}_VERSION_H
#define {{NAME}}_VERSION_H

#if !defined({{NAME}}_INSIDE) && !defined({{NAME}}_COMPILATION)
# error "Only <{{name}}.h> can be included directly."
#endif

/**
 * SECTION:{{prefix}}version
 * @short_description: {{name}} version checking
 *
 * {{name}} provides macros to check the version of the library
 * at compile-time
 */

/**
 * {{PREFIX}}_MAJOR_VERSION:
 *
 * {{name}} major version component (e.g. 1 if %{{PREFIX}}_VERSION is 1.2.3)
 */
#define {{PREFIX}}_MAJOR_VERSION (@MAJOR_VERSION@)

/**
 * {{PREFIX}}_MINOR_VERSION:
 *
 * {{name}} minor version component (e.g. 2 if %{{PREFIX}}_VERSION is 1.2.3)
 */
#define {{PREFIX}}_MINOR_VERSION (@MINOR_VERSION@)

/**
 * {{PREFIX}}_MICRO_VERSION:
 *
 * {{name}} micro version component (e.g. 3 if %{{PREFIX}}_VERSION is 1.2.3)
 */
#define {{PREFIX}}_MICRO_VERSION (@MICRO_VERSION@)

/**
 * {{PREFIX}}_VERSION
 *
 * {{name}} version.
 */
#define {{PREFIX}}_VERSION (@VERSION@)

/**
 * {{PREFIX}}_VERSION_S:
 *
 * {{name}} version, encoded as a string, useful for printing and
 * concatenation.
 */
#define {{PREFIX}}_VERSION_S "@VERSION@"

#define {{PREFIX}}_ENCODE_VERSION(major,minor,micro) \
        ((major) << 24 | (minor) << 16 | (micro) << 8)

/**
 * {{PREFIX}}_VERSION_HEX:
 *
 * {{name}} version, encoded as an hexadecimal number, useful for
 * integer comparisons.
 */
#define {{PREFIX}}_VERSION_HEX \
        ({{PREFIX}}_ENCODE_VERSION ({{PREFIX}}_MAJOR_VERSION, {{PREFIX}}_MINOR_VERSION, {{PREFIX}}_MICRO_VERSION))

/**
 * {{PREFIX}}_CHECK_VERSION:
 * @major: required major version
 * @minor: required minor version
 * @micro: required micro version
 *
 * Compile-time version checking. Evaluates to %TRUE if the version
 * of {{name}} is greater than the required one.
 */
#define {{PREFIX}}_CHECK_VERSION(major,minor,micro)   \
        ({{PREFIX}}_MAJOR_VERSION > (major) || \
         ({{PREFIX}}_MAJOR_VERSION == (major) && {{PREFIX}}_MINOR_VERSION > (minor)) || \
         ({{PREFIX}}_MAJOR_VERSION == (major) && {{PREFIX}}_MINOR_VERSION == (minor) && \
          {{PREFIX}}_MICRO_VERSION >= (micro)))

#endif /* {{NAME}}_VERSION_H */
