Anonymous avatar Anonymous committed e834aac

udev: make blkid optional

I'm building systemd for an embedded system and we would prefer not having
to include the entire util-linux package just to get a libblkid whose
functionality we don't need.

Comments (0)

Files changed (4)

 	src/udev-rules.c \
 	src/udev-ctrl.c \
 	src/udev-builtin.c \
-	src/udev-builtin-blkid.c \
 	src/udev-builtin-btrfs.c \
 	src/udev-builtin-firmware.c \
 	src/udev-builtin-hwdb.c \
 	src/udev-builtin-path_id.c \
 	src/udev-builtin-usb_id.c
 
+if HAVE_BLKID
+udev_common_sources += \
+	src/udev-builtin-blkid.c
+endif
+
 udev_common_CFLAGS = \
 	$(BLKID_CFLAGS) \
 	$(KMOD_CFLAGS)
 
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([POSIX RT library not found])])
 
-PKG_CHECK_MODULES(BLKID, blkid >= 2.20)
-
 PKG_CHECK_MODULES(KMOD, libkmod >= 5)
 
 AC_ARG_WITH([rootprefix],
 AC_SUBST([FIRMWARE_PATH], [$FIRMWARE_PATH])
 
 # ------------------------------------------------------------------------------
+# blkid - block device's information
+# ------------------------------------------------------------------------------
+
+AC_ARG_ENABLE(blkid, AS_HELP_STRING([--disable-blkid], [disable blkid support]))
+if test "x$enable_blkid" != "xno"; then
+        PKG_CHECK_MODULES(BLKID, [ blkid >= 2.20 ],
+                [AC_DEFINE(HAVE_BLKID, 1, [Define if blkid is available]) have_blkid=yes], have_blkid=no)
+        if test "x$have_blkid" = xno -a "x$enable_blkid" = xyes; then
+                AC_MSG_ERROR([blkid support requested but libraries not found])
+        fi
+fi
+AM_CONDITIONAL(HAVE_BLKID, [test "$have_blkid" = "yes"])
+
+# ------------------------------------------------------------------------------
 # GUdev - libudev gobject interface
 # ------------------------------------------------------------------------------
 AC_ARG_ENABLE([gudev],
         debug:                   ${enable_debug}
         selinux:                 ${with_selinux}
 
+        blkid:                   ${enable_blkid}
         gudev:                   ${enable_gudev}
         gintrospection:          ${enable_introspection}
         keymap:                  ${enable_keymap}

src/udev-builtin.c

 #include "udev.h"
 
 static const struct udev_builtin *builtins[] = {
+#ifdef HAVE_BLKID
         [UDEV_BUILTIN_BLKID] = &udev_builtin_blkid,
+#endif
         [UDEV_BUILTIN_BTRFS] = &udev_builtin_btrfs,
         [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware,
         [UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id,
 
 /* built-in commands */
 enum udev_builtin_cmd {
+#ifdef HAVE_BLKID
         UDEV_BUILTIN_BLKID,
+#endif
         UDEV_BUILTIN_BTRFS,
         UDEV_BUILTIN_FIRMWARE,
         UDEV_BUILTIN_INPUT_ID,
         bool (*validate)(struct udev *udev);
         bool run_once;
 };
+#ifdef HAVE_BLKID
 extern const struct udev_builtin udev_builtin_blkid;
+#endif
 extern const struct udev_builtin udev_builtin_btrfs;
 extern const struct udev_builtin udev_builtin_firmware;
 extern const struct udev_builtin udev_builtin_input_id;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.