[PATCH] Remove checking for run-time usb.ids and pci.ids at build time

Rob Taylor rob.taylor at codethink.co.uk
Wed Jan 31 08:03:12 PST 2007


Ok to commit? Any objections?

Remove build time checking for location of usb.ids and pci.ids. Adds new
configure flags --with-pci-ids and --with-usb-ids for specifying
locations of pci.ids and usb.ids respectivly. Also adds
--disable-pci-ids, --disable-usb-ids and --disable-pnp-ids.
---
 configure.in |   69
++++++++++++++++++++++++++++++++++++++++++++++++++--------
 hald/ids.c   |   41 +++++++++++++++++++++++-----------
 hald/ids.h   |   39 ++++++++++++++++++++++++++++-----
 3 files changed, 119 insertions(+), 30 deletions(-)

diff --git a/configure.in b/configure.in
index c479de3..90d8c5e 100644
--- a/configure.in
+++ b/configure.in
@@ -42,20 +42,61 @@ AC_CHECK_HEADERS([sys/ioccom.h])

 AC_ARG_WITH(os-type,     [  --with-os-type=<os>     Distribution or OS
(redhat)])
 AC_ARG_WITH(pid-file,    [  --with-pid-file=<file>  PID file for HAL
daemon])
-AC_ARG_WITH(hwdata,[  --with-hwdata=<dir>     where PCI and USB IDs are
found (auto)])
+
+AC_ARG_WITH(hwdata, AC_HELP_STRING([--with-hwdata=<dir>], [Where PCI
and USB IDs are found]))
+AC_ARG_WITH(pci-ids, AC_HELP_STRING([--with-pci-ids=<dir>], [Where PCI
IDs are found (overrides --with-hwdata)]))
+AC_ARG_WITH(usb-ids, AC_HELP_STRING([--with-usb-ids=<dir>], [Where USB
IDs are found (overrides --with-hwdata)]))
+AC_ARG_ENABLE([pci-ids], AC_HELP_STRING([--disable-pci-ids], [Do not
build with PCI IDs support]), [enable_pci_ids=$enableval],
[enable_pci_ids=yes])
+AC_ARG_ENABLE([usb-ids], AC_HELP_STRING([--disable-usb-ids], [Do not
build with USB IDs support]), [enable_usb_ids=$enableval],
[enable_usb_ids=yes])
+AC_ARG_ENABLE([pnp-ids], AC_HELP_STRING([--disable-pnp-ids], [Do not
build with PNP IDs support]), [enable_pnp_ids=$enableval],
[enable_pnp_ids=yes])
+
+AC_ARG_WITH(socket-dir,[  --with-socket-dir=<dir>  Location of the HAL
D-BUS listening sockets (auto)])
 AC_ARG_WITH(socket-dir,[  --with-socket-dir=<dir>  Location of the HAL
D-BUS listening sockets (auto)])
 if ! test -z "$with_hwdata" ; then
-   HWDATA_DIR="$with_hwdata"
+  PCI_IDS_DIR="$with_hwdata"
+  USB_IDS_DIR="$with_hwdata"
+fi
+if ! test -z "$with_pci_ids" ; then
+  PCI_IDS_DIR="$with_pci_ids"
+fi
+if ! test -z "$with_usb_ids" ; then
+  USB_IDS_DIR="$with_usb_ids"
+fi
+
+if test "x$enable_pci_ids" = "xno" ; then
+  USE_PCI_IDS=no
 else
-   for dir in /usr/share/hwdata /usr/share/misc /usr/share
/var/lib/misc; do
-      AC_CHECK_FILE($dir/pci.ids,HWDATA_DIR=$dir)
-   done
+   if test -z "$PCI_IDS_DIR"; then
+     AC_ERROR([cannot find pci.ids. Use --with-pci-ids to specify
location])
+   fi
+   USE_PCI_IDS=yes
+   AC_DEFINE(USE_PCI_IDS,1,[Whether pci.ids is to be used])
 fi
-if test -z "$HWDATA_DIR"; then
-   AC_ERROR(cannot find pci.ids. Use --with-hwdata to specify location)
+
+if test "x$enable_usb_ids" = "xno" ; then
+  USE_PCI_IDS=no
+else
+   if test -z "$USB_IDS_DIR"; then
+     AC_ERROR([cannot find usb.ids. Use --with-usb-ids to specify
location])
+   fi
+   USE_PCI_IDS=yes
+   AC_DEFINE(USE_USB_IDS,1,[Whether usb.ids is to be used])
+fi
+
+if test "x$enable_pnp_ids" = "xno" ; then
+  USE_PNP_IDS=no
+else
+  USE_PNP_IDS=yes
+  AC_DEFINE(USE_PNP_IDS,1,[Whether builtin PNP IDs are to be used])
 fi
-AC_SUBST(HWDATA_DIR)
-AC_DEFINE_UNQUOTED(HWDATA_DIR,"$HWDATA_DIR", [Where PCI and USB IDs are
found])
+
+AC_DEFINE_UNQUOTED(PCI_IDS_DIR,"$PCI_IDS_DIR", [Where PCI IDs are found])
+AC_DEFINE_UNQUOTED(USB_IDS_DIR,"$USB_IDS_DIR", [Where USB IDs are found])
+AC_SUBST(PCI_IDS_DIR)
+AC_SUBST(USB_IDS_DIR)
+AC_SUBST(USE_PCI_IDS)
+AC_SUBST(USE_USB_IDS)
+AC_SUBST(USE_PNP_IDS)


 AC_ARG_WITH(hal_user,[  --with-hal-user=<user>  User for running the
HAL daemon (haldaemon)])
@@ -329,6 +370,13 @@ if test "x$enable_pmu" != "xno"; then
 fi
 AM_CONDITIONAL(HAVE_PMU, test x$msg_pmu = xyes, [Compiling PMU])

+AC_ARG_ENABLE(have_pci, [  --disable-pci          Build without PCI
support])
+msg_pci=no
+if test "x$enable_pci" != "xno"; then
+	msg_pci=yes
+ 	AC_DEFINE(HAVE_PCI, [], [Set if we have ACPI support])
+fi
+
 # D-Bus libs
 PKG_CHECK_MODULES(DBUS, [$dbus_module])
 AC_SUBST(DBUS_CFLAGS)
@@ -671,7 +719,8 @@ echo "
         localstatedir:              ${LOCALSTATEDIR}
         docdir:                     ${DOCDIR}
         dbus-1 system.d dir:        ${DBUS_SYS_DIR}
-        pci.ids, usb.ids dir:       ${HWDATA_DIR}
+        pci.ids dir:                ${PCI_IDS_DIR}
+        usb.ids dir:                ${USB_IDS_DIR}

         compiler:                   ${CC}
         cflags:                     ${CFLAGS}
diff --git a/hald/ids.c b/hald/ids.c
index 7bfaf19..3881aca 100644
--- a/hald/ids.c
+++ b/hald/ids.c
@@ -44,6 +44,7 @@ #include "logger.h"

 #include "ids.h"

+#ifdef USE_PCI_IDS
 /** Pointer to where the pci.ids file is loaded */
 static char *pci_ids = NULL;

@@ -306,8 +307,18 @@ out:
 	return ret;
 }

+void
+pci_ids_init (void)
+{
+	/* Load /usr/share/hwdata/pci.ids */
+	pci_ids_load (PCI_IDS_DIR "/pci.ids");
+}
+
+#endif /*USE_PCI_IDS*/
+
 /*==========================================================================*/

+#ifdef USE_USB_IDS
 /** Pointer to where the usb.ids file is loaded */
 static char *usb_ids = NULL;

@@ -510,25 +521,17 @@ out:
 }

 void
-pci_ids_init (void)
-{
-	/* Load /usr/share/hwdata/pci.ids */
-	pci_ids_load (HWDATA_DIR "/pci.ids");
-}
-
-void
 usb_ids_init (void)
 {
 	/* Load /usr/share/hwdata/usb.ids */
-	usb_ids_load (HWDATA_DIR "/usb.ids");
+	usb_ids_load (USB_IDS_DIR "/usb.ids");
 }

-void
-ids_init (void)
-{
-	pci_ids_init ();
-	usb_ids_init ();
-}
+#endif /*USE_USB_IDS*/
+
+/*==========================================================================*/
+
+#ifdef USE_PNP_IDS

 /* This, somewhat incomplete, list is from this sources:
  * http://www.plasma-online.de/english/identify/serial/pnp_id_pnp.html
@@ -970,3 +973,13 @@ ids_find_pnp (const char *pnp_id, char *
         	*pnp_description = NULL;
         return;
 }
+
+#endif /*USE_PNP_IDS*/
+
+/*==========================================================================*/
+
+ids_init (void)
+{
+	pci_ids_init ();
+	usb_ids_init ();
+}
diff --git a/hald/ids.h b/hald/ids.h
index 34648b7..7773211 100644
--- a/hald/ids.h
+++ b/hald/ids.h
@@ -28,11 +28,9 @@ #define IDS_H

 #include <glib.h>

-void pci_ids_init (void);
-
-void usb_ids_init (void);
+#ifdef USE_PCI_IDS

-void ids_init (void);
+void pci_ids_init (void);

 void
 ids_find_pci (int vendor_id, int product_id,
@@ -40,12 +38,41 @@ ids_find_pci (int vendor_id, int product
 	      char **vendor_name, char **product_name,
 	      char **subsys_vendor_name, char **subsys_product_name);

+#else /*USE_PCI_IDS*/
+static inline void pci_ids_init (void) {return;};
+
+static inline void
+ids_find_pci (int vendor_id, int product_id,
+	      int subsys_vendor_id, int subsys_product_id,
+	      char **vendor_name, char **product_name,
+	      char **subsys_vendor_name, char **subsys_product_name) {return;}
+#endif /*USE_PCI_IDS*/
+
+#ifdef USE_PNP_IDS
+
+void
+ids_find_pnp (const char *pnp_id, char **pnp_description);
+
+#else /*USE_PNP_IDS*/
+static inline void
+ids_find_pnp (const char *pnp_id, char **pnp_description) {return;}
+#endif /*USE_PNP_IDS*/
+
+#ifdef USE_USB_IDS
+
+void usb_ids_init (void);
+
 void
 ids_find_usb (int vendor_id, int product_id,
 	      char **vendor_name, char **product_name);

-void
-ids_find_pnp (const char *pnp_id, char **pnp_description);
+#else /*USE_USB_IDS*/
+static inline void usb_ids_init (void) {return;}
+static inline void
+ids_find_usb (int vendor_id, int product_id,
+	      char **vendor_name, char **product_name) {return;}
+#endif /*USE_USB_IDS*/

+void ids_init (void);

 #endif /* IDS_H */


More information about the hal mailing list