]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
liblastlog2: generate lastlog2.h from template
authorKarel Zak <kzak@redhat.com>
Thu, 19 Mar 2026 19:53:41 +0000 (20:53 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 24 Mar 2026 09:21:15 +0000 (10:21 +0100)
Convert lastlog2.h to lastlog2.h.in and add LIBLASTLOG2_VERSION,
LIBLASTLOG2_MAJOR_VERSION, LIBLASTLOG2_MINOR_VERSION, and
LIBLASTLOG2_PATCH_VERSION defines to follow the same pattern as
libmount, libfdisk, libsmartcols, and libblkid.

Update both autotools (configure.ac, Makemodule.am) and meson
(liblastlog2/meson.build) to generate the header.

Signed-off-by: Karel Zak <kzak@redhat.com>
Makefile.am
configure.ac
liblastlog2/meson.build
liblastlog2/src/.gitignore [new file with mode: 0644]
liblastlog2/src/Makemodule.am
liblastlog2/src/lastlog2.h.in [moved from liblastlog2/src/lastlog2.h with 93% similarity]

index 4ac3b2e5762b726efb8ee0852d7fcd34b6b3e76b..02db4061e6bd24cfb21cb0aadebead95270da0cc 100644 (file)
@@ -43,7 +43,7 @@ ul_libblkid_incdir = $(top_builddir)/libblkid/src
 ul_libmount_incdir = $(top_builddir)/libmount/src
 ul_libsmartcols_incdir = $(top_builddir)/libsmartcols/src
 ul_libfdisk_incdir  = $(top_builddir)/libfdisk/src
-ul_liblastlog2_incdir  = $(top_srcdir)/liblastlog2/src
+ul_liblastlog2_incdir  = $(top_builddir)/liblastlog2/src
 ul_libuuid_incdir  = $(top_srcdir)/libuuid/src
 
 bashcompletiondir = @bashcompletiondir@
index 499c382ff6392df5f9b0f5e2a65ed040880381bb..4c824eb12416253860107cd3d61adae419acb35e 100644 (file)
@@ -1322,6 +1322,9 @@ UL_REQUIRES_HAVE([liblastlog2], [sqlite3], [sqlite3 library])
 AC_SUBST([SQLITE3_LIBS])
 
 AC_SUBST([LIBLASTLOG2_VERSION])
+AC_SUBST([LIBLASTLOG2_MAJOR_VERSION], $PACKAGE_VERSION_MAJOR)
+AC_SUBST([LIBLASTLOG2_MINOR_VERSION], $PACKAGE_VERSION_MINOR)
+AC_SUBST([LIBLASTLOG2_PATCH_VERSION], $PACKAGE_VERSION_RELEASE)
 AC_SUBST([LIBLASTLOG2_VERSION_INFO])
 AM_CONDITIONAL([BUILD_LIBLASTLOG2], [test "x$build_liblastlog2" = xyes])
 AM_CONDITIONAL([BUILD_LIBLASTLOG2_TESTS], [test "x$build_liblastlog2" = xyes && test "x$enable_static" = xyes])
@@ -3124,6 +3127,7 @@ libblkid/src/blkid.h
 libfdisk/docs/Makefile
 libfdisk/docs/version.xml
 libfdisk/src/libfdisk.h
+liblastlog2/src/lastlog2.h
 libmount/docs/Makefile
 libmount/docs/version.xml
 libmount/src/libmount.h
index 9f0f76c6935112ec608a8afe263cf4df46d4c6dd..d14872a1dd0585c1c254b04eab067c8015c664aa 100644 (file)
@@ -1,8 +1,22 @@
 cc = meson.get_compiler('c')
 pkg = import('pkgconfig')
-dir_liblastlog2 = include_directories('src')
+dir_liblastlog2 = include_directories('.', 'src')
+
+defs = configuration_data()
+defs.set('LIBLASTLOG2_VERSION', pc_version)
+defs.set('LIBLASTLOG2_MAJOR_VERSION', pc_version.split('.')[0])
+defs.set('LIBLASTLOG2_MINOR_VERSION', pc_version.split('.')[1])
+defs.set('LIBLASTLOG2_PATCH_VERSION', pc_version.split('.')[2])
+
+configure_file(
+  input : 'src/lastlog2.h.in',
+  output : 'lastlog2.h',
+  configuration : defs,
+  install : build_liblastlog2,
+  install_dir : get_option('includedir') / 'liblastlog2',
+)
+
 lib_lastlog2_sources = '''
-  src/lastlog2.h
   src/lastlog2P.h
   src/lastlog2.c
 '''.split()
@@ -45,8 +59,6 @@ if build_liblastlog2
   )
   meson.override_dependency('lastlog2', lastlog2_dep)
 
-  install_headers('src/lastlog2.h', subdir : 'liblastlog2')
-
   foreach lastlog2_test: lastlog2_tests
     test_name = 'test_lastlog2_' + lastlog2_test
     exe = executable(
diff --git a/liblastlog2/src/.gitignore b/liblastlog2/src/.gitignore
new file mode 100644 (file)
index 0000000..0ef02ac
--- /dev/null
@@ -0,0 +1 @@
+lastlog2.h
index 04b8e97458b052db6723eae2762945796b3e375b..6ec3b7d62be137ead4b45a7c168cf79ec94443fb 100644 (file)
@@ -1,6 +1,6 @@
-# includes
+# lastlog2.h is generated, so it's stored in builddir!
 lastlog2incdir = $(includedir)/liblastlog2
-lastlog2inc_HEADERS = liblastlog2/src/lastlog2.h
+nodist_lastlog2inc_HEADERS = liblastlog2/src/lastlog2.h
 
 usrlib_exec_LTLIBRARIES += liblastlog2.la
 
similarity index 93%
rename from liblastlog2/src/lastlog2.h
rename to liblastlog2/src/lastlog2.h.in
index 280f387d6f7ca06bb09e835a0d018702516f5a9a..bc8ce23ee9fb9fd0526a8ac624a4254536c11c0e 100644 (file)
 extern "C" {
 #endif
 
+#define LIBLASTLOG2_VERSION   "@LIBLASTLOG2_VERSION@"
+#define LIBLASTLOG2_MAJOR_VERSION   @LIBLASTLOG2_MAJOR_VERSION@
+#define LIBLASTLOG2_MINOR_VERSION   @LIBLASTLOG2_MINOR_VERSION@
+#define LIBLASTLOG2_PATCH_VERSION   @LIBLASTLOG2_PATCH_VERSION@
+
 #define LL2_DEFAULT_DATABASE _PATH_LOCALSTATEDIR "/lib/lastlog/lastlog2.db"
 
 #include <stdint.h>