/**
 * @file version.h
 * @brief Declares the libakgl version, both as compiled against and as linked.
 *
 * GENERATED FILE -- edit include/akgl/version.h.in, never the copy in the build
 * tree. Every value here comes from the project() call in CMakeLists.txt, which
 * is also what sets the shared library's VERSION and SOVERSION and the Version
 * field in akgl.pc. One number, one place, so the header, the soname and
 * pkg-config cannot drift apart.
 *
 * AKGL_VERSION is the version you *compiled against*. akgl_version() reports the
 * version of the libakgl you actually *linked*. They disagree when a stale
 * shared library is ahead of the new one on the loader path -- the failure the
 * soname exists to prevent and this pair exists to diagnose.
 */

#ifndef _AKGL_VERSION_H_
#define _AKGL_VERSION_H_

#define AKGL_VERSION               "@PROJECT_VERSION@"
#define AKGL_VERSION_MAJOR         @PROJECT_VERSION_MAJOR@
#define AKGL_VERSION_MINOR         @PROJECT_VERSION_MINOR@
#define AKGL_VERSION_PATCH         @PROJECT_VERSION_PATCH@

/**
 * @brief True when the headers on the include path are at least the given version.
 *
 * For consumers that must build against more than one libakgl release. This is
 * the test libakstdlib could not write against libakerror, which published no
 * version macro and had to feature-test on AKERR_FIRST_CONSUMER_STATUS instead.
 *
 * @code
 * #if AKGL_VERSION_AT_LEAST(0, 2, 0)
 *     akgl_something_new();
 * #endif
 * @endcode
 */
#define AKGL_VERSION_AT_LEAST(major, minor, patch)			\
    ((AKGL_VERSION_MAJOR > (major)) ||					\
     (AKGL_VERSION_MAJOR == (major) && AKGL_VERSION_MINOR > (minor)) ||	\
     (AKGL_VERSION_MAJOR == (major) && AKGL_VERSION_MINOR == (minor) && \
      AKGL_VERSION_PATCH >= (patch)))

/**
 * @brief Report the version of the libakgl that is actually linked.
 *
 * Returns "major.minor.patch". Compare it against AKGL_VERSION to detect a
 * stale shared library. Never returns NULL, and the storage is static -- the
 * caller must not free or modify it.
 *
 * This returns a string rather than an akerr_ErrorContext * because it cannot
 * fail, the same reason akerr_name_for_status() returns a name directly.
 */
const char *akgl_version(void);

#endif // _AKGL_VERSION_H_
