From 17afb0320c77e47a44dc838d3724f89aff06c703 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 18 May 2009 16:01:27 +0200 Subject: [PATCH] build-sys: cleanup libuuid stuff Supported scenarios: * internal libuuid (--enable-libuuid, default) * external libuuid (--disable-libuuid) - systems without pkg-config - systems with pkg-config * systems without libuuid at all (the library is optional for u-l-ng) Signed-off-by: Karel Zak --- configure.ac | 49 ++++++++++++++++++++++++++---------- disk-utils/Makefile.am | 13 +++++++--- shlibs/blkid/src/Makefile.am | 13 +++++++--- 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index 27d8fa35..574be219 100644 --- a/configure.ac +++ b/configure.ac @@ -201,13 +201,39 @@ AC_DEFUN([UTIL_RESTORE_FLAGS], [ ]) -UTIL_CHECK_LIB(uuid, uuid_is_null) -if test "x$have_uuid" = xno; then - AC_MSG_WARN([uuid library is not found; mkswap(8) will not generate UUIDs]) +AC_ARG_ENABLE([libuuid], + AS_HELP_STRING([--disable-libuuid], [do not build libuuid and uuid utilities]), + [], enable_libuuid=yes +) +AC_SUBST(LIBUUID_VERSION) +AM_CONDITIONAL(BUILD_LIBUUID, test "x$enable_libuuid" = xyes) +have_uuid=yes + +if test "x$enable_libuuid" = xno; then + # Check for external (e2fsprogs) libuuid + PKG_CHECK_MODULES(UUID, uuid, [have_uuid=yes], [have_uuid=no]) + if test "x$have_uuid" = xno; then + # system without pkg-config or so, try classic check + AC_CHECK_LIB(uuid, uuid_is_null, [have_uuid=yes], [have_uuid=no]) + fi + if test "x$have_uuid" = xyes; then + UTIL_SET_FLAGS($UUID_CFLAGS, $UUID_CFLAGS, $UUID_LIBS) + AC_CHECK_HEADERS([uuid.h uuid/uuid.h], [break], []) + UTIL_RESTORE_FLAGS + fi +else + # internal librray + AC_DEFINE(HAVE_UUID_H, 1, [Define to 1 if you have the header file.]) fi -UTIL_CHECK_LIB(util, openpty) -UTIL_CHECK_LIB(termcap, tgetnum) +if test "x$have_uuid" = xyes; then + AC_DEFINE(HAVE_LIBUUID, 1, [Define to 1 if you have the -luuid.]) +else + AC_MSG_WARN([uuid library is not found; mkswap(8) will not generate UUIDs]) +fi +AM_CONDITIONAL(HAVE_UUID, test "x$have_uuid" = xyes) +# default +: ${UUID_LIBS='-luuid'} AC_ARG_WITH([fsprobe], @@ -269,14 +295,6 @@ fi AM_CONDITIONAL(BUILD_MOUNT, test "x$build_mount" = xyes) -AC_ARG_ENABLE([libuuid], - AS_HELP_STRING([--disable-libuuid], [do not build libuuid and uuid utilities]), - [], enable_libuuid=yes -) -AC_SUBST(LIBUUID_VERSION) -AM_CONDITIONAL(BUILD_LIBUUID, test "x$enable_libuuid" = xyes) - - AC_ARG_ENABLE([fsck], AS_HELP_STRING([--enable-fsck], [do build fsck]), [], enable_fsck=no @@ -289,6 +307,8 @@ fi AM_CONDITIONAL(BUILD_FSCK, test "x$enable_fsck" = xyes) + + dnl UTIL_PKG_STATIC(VARIABLE, MODULES) dnl ---------------------------------- AC_DEFUN([UTIL_PKG_STATIC], [ @@ -299,6 +319,7 @@ AC_DEFUN([UTIL_PKG_STATIC], [ fi ]) + # These default values should work in most cases: : ${BLKID_LIBS='-lblkid -luuid'} : ${VOLUME_ID_LIBS='-lvolume_id'} @@ -314,6 +335,8 @@ fi AC_ARG_VAR([BLKID_LIBS_STATIC], [-l options for linking statically with blkid]) AC_ARG_VAR([VOLUME_ID_LIBS_STATIC], [-l options for linking statically with volume_id]) +UTIL_CHECK_LIB(util, openpty) +UTIL_CHECK_LIB(termcap, tgetnum) AM_GNU_GETTEXT_VERSION([0.14.1]) AM_GNU_GETTEXT([external]) diff --git a/disk-utils/Makefile.am b/disk-utils/Makefile.am index 4854d5f6..60481ab7 100644 --- a/disk-utils/Makefile.am +++ b/disk-utils/Makefile.am @@ -12,7 +12,10 @@ sbin_PROGRAMS = mkfs mkswap fsck.minix mkfs.minix mkfs.bfs fsck_minix_SOURCES = fsck.minix.c minix.h mkfs_minix_SOURCES = mkfs.minix.c minix.h $(utils_common) mkfs_bfs_SOURCES = mkfs.bfs.c $(utils_common) + mkswap_SOURCES = mkswap.c $(utils_common) ../lib/wholedisk.c ../lib/pttype.c +mkswap_LDADD = +mkswap_CFLAGS = usrbinexec_PROGRAMS = isosize usrsbinexec_PROGRAMS = @@ -46,10 +49,14 @@ fsck_cramfs_LDADD = -lz mkfs_cramfs_LDADD = -lz endif -mkswap_LDADD = - if HAVE_UUID -mkswap_LDADD += -luuid +if BUILD_LIBUUID +mkswap_LDADD += $(ul_libuuid_la) +mkswap_CFLAGS += -I$(ul_libuuid_srcdir) +else +mkswap_LDADD += $(UUID_LIBS) +mkswap_CFLAGS += $(UUID_CFLAGS) +endif endif if HAVE_SELINUX diff --git a/shlibs/blkid/src/Makefile.am b/shlibs/blkid/src/Makefile.am index 2b935e29..18e5c2e3 100644 --- a/shlibs/blkid/src/Makefile.am +++ b/shlibs/blkid/src/Makefile.am @@ -2,14 +2,21 @@ include $(top_srcdir)/config/include-Makefile.am SUBDIRS = probers . -AM_CPPFLAGS += -I$(ul_libblkid_srcdir) - common_ldadd = +common_cflags = if HAVE_UUID -common_ldadd += -luuid #TODO $(UUID_LIBS) +if BUILD_LIBUUID +common_ldadd += $(ul_libuuid_la) +common_cflags += -I$(ul_libuuid_srcdir) +else +common_ldadd += $(UUID_LIBS) +common_cflags += $(UUID_CFLAGS) +endif endif +AM_CPPFLAGS += -I$(ul_libblkid_srcdir) $(common_cflags) + # includes blkidincdir = $(includedir)/blkid blkidinc_HEADERS = blkid.h -- 2.39.5