Commits

Anonymous committed ac73f9d

build-sys: make loadable module support optional

kmod is unecessary if loadable module support is disabled in the kernel,
so make the dependency optional.

Comments (0)

Files changed (6)

 	rules/75-net-description.rules \
 	rules/75-tty-description.rules \
 	rules/78-sound-card.rules \
-	rules/80-drivers.rules \
 	rules/95-udev-late.rules
 
+if HAVE_KMOD
+dist_udevrules_DATA += \
+	rules/80-drivers.rules
+endif
+
 udevconfdir = $(sysconfdir)/udev
 dist_udevconf_DATA = src/udev.conf
 
 	src/udev-builtin-firmware.c \
 	src/udev-builtin-hwdb.c \
 	src/udev-builtin-input_id.c \
-	src/udev-builtin-kmod.c \
 	src/udev-builtin-path_id.c \
 	src/udev-builtin-usb_id.c
 
 	src/udev-builtin-blkid.c
 endif
 
+if HAVE_KMOD
+udev_common_sources += \
+	src/udev-builtin-kmod.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(KMOD, libkmod >= 5)
-
 AC_ARG_WITH([rootprefix],
        AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]),
        [], [with_rootprefix=${ac_default_prefix}])
 IFS=$OLD_IFS
 AC_SUBST([FIRMWARE_PATH], [$FIRMWARE_PATH])
 
+
+# ------------------------------------------------------------------------------
+# kmod - library and tools for managing linux kernel modules
+# ------------------------------------------------------------------------------
+
+have_kmod=no
+AC_ARG_ENABLE(kmod, AS_HELP_STRING([--disable-kmod], [disable loadable modules support]))
+if test "x$enable_kmod" != "xno"; then
+        PKG_CHECK_MODULES(KMOD, [ libkmod >= 5 ],
+                [AC_DEFINE(HAVE_KMOD, 1, [Define if kmod is available]) have_kmod=yes], have_kmod=no)
+        if test "x$have_kmod" = xno -a "x$enable_kmod" = xyes; then
+                AC_MSG_ERROR([kmod support requested but libraries not found])
+        fi
+fi
+AM_CONDITIONAL(HAVE_KMOD, [test "$have_kmod" = "yes"])
+
 # ------------------------------------------------------------------------------
 # blkid - block device's information
 # ------------------------------------------------------------------------------
         selinux:                 ${with_selinux}
 
         blkid:                   ${have_blkid}
+        kmod:                    ${have_kmod}
+
         gudev:                   ${enable_gudev}
         gintrospection:          ${enable_introspection}
         keymap:                  ${enable_keymap}

rules/80-drivers.rules

 SUBSYSTEM=="memstick", IMPORT{builtin}="kmod load ms_block mspro_block"
 SUBSYSTEM=="i2o", IMPORT{builtin}="kmod load i2o_block"
 SUBSYSTEM=="module", KERNEL=="parport_pc", IMPORT{builtin}="kmod load ppdev"
+KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", IMPORT{builtin}="kmod load sm_ftl"
 
 LABEL="drivers_end"

src/mtd_probe/75-probe_mtd.rules

 ACTION!="add", GOTO="mtd_probe_end"
 
 KERNEL=="mtd*ro", IMPORT{program}="mtd_probe $devnode"
-KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", IMPORT{builtin}="kmod load sm_ftl"
 
 LABEL="mtd_probe_end"

src/udev-builtin.c

         [UDEV_BUILTIN_BTRFS] = &udev_builtin_btrfs,
         [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware,
         [UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id,
+#ifdef HAVE_KMOD
         [UDEV_BUILTIN_KMOD] = &udev_builtin_kmod,
+#endif
         [UDEV_BUILTIN_PATH_ID] = &udev_builtin_path_id,
         [UDEV_BUILTIN_PCI_DB] = &udev_builtin_pci_db,
         [UDEV_BUILTIN_USB_DB] = &udev_builtin_usb_db,
         UDEV_BUILTIN_BTRFS,
         UDEV_BUILTIN_FIRMWARE,
         UDEV_BUILTIN_INPUT_ID,
+#ifdef HAVE_KMOD
         UDEV_BUILTIN_KMOD,
+#endif
         UDEV_BUILTIN_PATH_ID,
         UDEV_BUILTIN_PCI_DB,
         UDEV_BUILTIN_USB_DB,
 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;
+#ifdef HAVE_KMOD
 extern const struct udev_builtin udev_builtin_kmod;
+#endif
 extern const struct udev_builtin udev_builtin_path_id;
 extern const struct udev_builtin udev_builtin_pci_db;
 extern const struct udev_builtin udev_builtin_usb_db;