[pacman-dev] [PATCH v2 1/1] libalpm: generate alpm.h on the fly and add version information
Christian Hesse
list at eworm.de
Mon Dec 29 16:53:31 UTC 2014
From: Christian Hesse <mail at eworm.de>
Programs linked against libalpm (for example packagekit) may want to use
preprocessor macros to check version and choose correct API. This adds
version information to alpm.h.
Signed-off-by: Christian Hesse <mail at eworm.de>
---
configure.ac | 13 +++++++++++++
lib/libalpm/.gitignore | 1 +
lib/libalpm/{alpm.h => alpm.h.in} | 8 ++++++++
3 files changed, 22 insertions(+)
rename lib/libalpm/{alpm.h => alpm.h.in} (99%)
diff --git a/configure.ac b/configure.ac
index e0ed3cf..7b30d24 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,10 @@ AM_SILENT_RULES([yes])
LT_INIT
LIB_VERSION=`expr lib_current - lib_age`.lib_age.lib_revision
+LIB_VERSION_CURRENT=lib_current
+LIB_VERSION_REVISION=lib_revision
+LIB_VERSION_AGE=lib_age
+LIB_VERSION_NUMBER=`printf 0x%02x%02x%02x lib_current lib_revision lib_age`
LIB_VERSION_INFO="lib_current:lib_revision:lib_age"
# Respect empty CFLAGS during compiler tests
@@ -76,7 +80,15 @@ fi
# and put LIB_VERSION in config.h
AC_SUBST(LIB_VERSION)
AC_SUBST(LIB_VERSION_INFO)
+AC_SUBST(LIB_VERSION_CURRENT)
+AC_SUBST(LIB_VERSION_REVISION)
+AC_SUBST(LIB_VERSION_AGE)
+AC_SUBST(LIB_VERSION_NUMBER)
AC_DEFINE_UNQUOTED([LIB_VERSION], ["$LIB_VERSION"], [libalpm version number])
+AC_DEFINE_UNQUOTED([LIB_VERSION_CURRENT], ["$LIB_VERSION_CURRENT"], [libalpm version number current])
+AC_DEFINE_UNQUOTED([LIB_VERSION_REVISION], ["$LIB_VERSION_REVISION"], [libalpm version number revision])
+AC_DEFINE_UNQUOTED([LIB_VERSION_AGE], ["$LIB_VERSION_AGE"], [libalpm version number age])
+AC_DEFINE_UNQUOTED([LIB_VERSION_NUMBER], ["$LIB_VERSION_NUMBER"], [libalpm version number hex])
# Help line for root directory
AC_ARG_WITH(root-dir,
@@ -498,6 +510,7 @@ AC_CONFIG_FILES([
lib/libalpm/Makefile
lib/libalpm/po/Makefile.in
lib/libalpm/libalpm.pc
+lib/libalpm/alpm.h
src/common/Makefile
src/pacman/Makefile
src/pacman/po/Makefile.in
diff --git a/lib/libalpm/.gitignore b/lib/libalpm/.gitignore
index 82318d3..5b94ed8 100644
--- a/lib/libalpm/.gitignore
+++ b/lib/libalpm/.gitignore
@@ -2,4 +2,5 @@
.libs
*.lo
*.la
+alpm.h
libalpm.pc
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h.in
similarity index 99%
rename from lib/libalpm/alpm.h
rename to lib/libalpm/alpm.h.in
index 91b9461..7fc6f3b 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h.in
@@ -23,6 +23,14 @@
#ifndef _ALPM_H
#define _ALPM_H
+#define ALPM_VERSION "@LIB_VERSION@"
+
+#define ALPM_VERSION_CURRENT @LIB_VERSION_CURRENT@
+#define ALPM_VERSION_REVISION @LIB_VERSION_REVISION@
+#define ALPM_VERSION_AGE @LIB_VERSION_AGE@
+
+#define ALPM_VERSION_NUMBER @LIB_VERSION_NUMBER@
+
#ifdef __cplusplus
extern "C" {
#endif
--
2.2.1
More information about the pacman-dev
mailing list