build: use pkg-config for libuuid

Migrate the libuuid detection to use pkg-config via PKG_CHECK_MODULES.
This allows for better portability on systems where library paths may
differ from standard locations.

To align with pkg-config standards (which typically provide include
paths ending in .../uuid), the source code includes are updated from
<uuid/uuid.h> to <uuid.h>.

A fallback mechanism using AC_CHECK_LIB is retained for environments
without pkg-config, ensuring backward compatibility.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
This commit is contained in:
Ryusuke Konishi 2025-12-27 21:03:56 +09:00
parent 0af9d5faec
commit 7fbea79b90
5 changed files with 23 additions and 11 deletions

View File

@ -84,13 +84,25 @@ AS_IF([test "x$enable_usrmerge" = "xauto"], [
])
# Checks for libraries.
AC_CHECK_LIB([uuid], [uuid_generate], [
AC_DEFINE([HAVE_LIBUUID], 1,
[Define to 1 if you have the 'uuid' library (-luuid).])
AC_SUBST(UUID_LIBS, ["-luuid"])
AC_SUBST(UUID_CFLAGS, [""])
], [
AC_MSG_ERROR([UUID library not found])
m4_ifdef([PKG_CHECK_MODULES], [
PKG_CHECK_MODULES([UUID], [uuid], [
have_uuid_pkg_config=yes
AC_DEFINE([HAVE_LIBUUID], 1,
[Define to 1 if you have the 'uuid' library (-luuid).])
], [have_uuid_pkg_config=no])
], [have_uuid_pkg_config=no])
# Fall back
AS_IF([test "x$have_uuid_pkg_config" = "xno"], [
AC_CHECK_LIB([uuid], [uuid_generate], [
AC_DEFINE([HAVE_LIBUUID], 1,
[Define to 1 if you have the 'uuid' library (-luuid).])
AC_SUBST(UUID_LIBS, ["-luuid"])
AC_SUBST(UUID_CFLAGS, ["-I/usr/include/uuid"])
], [
AC_MSG_ERROR([UUID library not found])
])
AC_CHECK_HEADERS([uuid/uuid.h])
])
LIB_POSIX_MQ=''

View File

@ -12,7 +12,7 @@
#define NILFS_CLEANER_MSG_H
#include <stdint.h>
#include <uuid/uuid.h>
#include <uuid.h>
#include "nilfs_cleaner.h"
#define NILFS_CLEANER_PRIO_HIGH 1

View File

@ -74,7 +74,7 @@
#include <stdarg.h>
#include <errno.h>
#include <assert.h>
#include <uuid/uuid.h>
#include <uuid.h>
#include "nilfs_cleaner.h"
#include "cleaner_exec.h"

View File

@ -73,7 +73,7 @@
#include <signal.h>
#include <setjmp.h>
#include <assert.h>
#include <uuid/uuid.h>
#include <uuid.h>
#include <linux/nilfs2_ondisk.h> /* NILFS_MIN_NRSVSEGS */
#include "nilfs.h"
#include "compat.h"

View File

@ -50,7 +50,7 @@
#include <sys/wait.h>
#endif /* HAVE_SYS_WAIT_H */
#include <uuid/uuid.h>
#include <uuid.h>
#if HAVE_STRING_H
#include <string.h>