mtp-hotplug: support outputting HWDB files.

- Output new udev hardware database style files
  Using -w option.
- Makefile.am: generate hwdb files by default
- configure.ac: udev rules live in /usr/lib/udev usually these days
diff --git a/.gitignore b/.gitignore
index ffa99a5..5d4f1ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@
 configure
 *.rules
 *.fdi
+*.hwdb
 *.pc
 *.usermap
 hotplug.sh
diff --git a/Makefile.am b/Makefile.am
index c6d46c2..7b7e06b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,15 +10,22 @@
 # build and ship it on Linux.
 if USE_LINUX
 udevrulesdir=@UDEV@/rules.d
+hwdbdir=@UDEV@/hwdb.d
 udevrules_DATA=@UDEV_RULES@
+hwdb_DATA=69-libmtp.hwdb
 noinst_DATA=libmtp.usermap libmtp.fdi
 
 libmtp.usermap: util/mtp-hotplug
 	util/mtp-hotplug > libmtp.usermap
+
 @UDEV_RULES@: util/mtp-hotplug
 	util/mtp-hotplug -u -p"@UDEV@" @UDEV_GROUP@ @UDEV_MODE@ > @UDEV_RULES@
+
 libmtp.fdi: util/mtp-hotplug
 	util/mtp-hotplug -H > libmtp.fdi
 
-CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi
+$(hwdb_DATA): util/mtp-hotplug
+	util/mtp-hotplug -w > $(hwdb_DATA)
+
+CLEANFILES = libmtp.usermap @UDEV_RULES@ libmtp.fdi libmtp.hwdb
 endif
diff --git a/configure.ac b/configure.ac
index b445220..6c80884 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@
 AM_ICONV
 
 # Optionally set install location of udev
-UDEV=/lib/udev
+UDEV=/usr/lib/udev
 AC_ARG_WITH(udev,
     AC_HELP_STRING([--with-udev=DIR],
     [directory where udev is installed [default=/lib/udev]]),
diff --git a/util/mtp-hotplug.c b/util/mtp-hotplug.c
index 8965426..8e118ae 100644
--- a/util/mtp-hotplug.c
+++ b/util/mtp-hotplug.c
@@ -29,6 +29,7 @@
 static void usage(void)
 {
   fprintf(stderr, "usage: hotplug [-u -H -i -a\"ACTION\"] -p\"DIR\" -g\"GROUP\" -m\"MODE\"\n");
+  fprintf(stderr, "       -w:  use hwdb syntax\n");
   fprintf(stderr, "       -u:  use udev syntax\n");
   fprintf(stderr, "       -o:  use old udev syntax\n");
   fprintf(stderr, "       -H:  use hal syntax\n");
@@ -45,7 +46,8 @@
   style_udev,
   style_udev_old,
   style_hal,
-  style_usbids
+  style_usbids,
+  style_hwdb
 };
 
 int main (int argc, char **argv)
@@ -73,7 +75,7 @@
   char *udev_group= NULL;
   char *udev_mode = NULL;
 
-  while ( (opt = getopt(argc, argv, "uoiHa:p:g:m:")) != -1 ) {
+  while ( (opt = getopt(argc, argv, "wuoiHa:p:g:m:")) != -1 ) {
     switch (opt) {
     case 'a':
       udev_action = strdup(optarg);
@@ -90,6 +92,9 @@
     case 'i':
       style = style_usbids;
       break;
+    case 'w':
+      style = style_hwdb;
+      break;
     case 'p':
       strncpy(mtp_probe_dir,optarg,sizeof(mtp_probe_dir));
       mtp_probe_dir[sizeof(mtp_probe_dir)-1] = '\0';
@@ -180,6 +185,9 @@
       printf("# usb.ids style device list from libmtp\n");
       printf("# Compare: http://www.linux-usb.org/usb.ids\n");
       break;
+    case style_hwdb:
+      printf("# hardware database file for libmtp supported devices\n");
+      break;
     }
 
     for (i = 0; i < numentries; i++) {
@@ -198,7 +206,7 @@
           printf("# %s %s\n", entry->vendor, entry->product);
           printf("libmtp.sh    0x0003  0x%04x  0x%04x  0x0000  0x0000  0x00    0x00    0x00    0x00    0x00    0x00    0x00000000\n", entry->vendor_id, entry->product_id);
           break;
-        case style_hal:
+      case style_hal:
           printf("      <!-- %s %s -->\n", entry->vendor, entry->product);
           printf("      <match key=\"usb.vendor_id\" int=\"0x%04x\">\n", entry->vendor_id);
           printf("        <match key=\"usb.product_id\" int=\"0x%04x\">\n", entry->product_id);
@@ -233,12 +241,19 @@
           printf("        </match>\n");
           printf("      </match>\n");
         break;
-        case style_usbids:
+      case style_usbids:
           if (last_vendor != entry->vendor_id) {
             printf("%04x\n", entry->vendor_id);
           }
           printf("\t%04x  %s %s\n", entry->product_id, entry->vendor, entry->product);
         break;
+      case style_hwdb:
+          printf("# %s %s\n", entry->vendor, entry->product);
+          printf("usb:v%04xp%04x*\n", entry->vendor_id, entry->product_id);
+          printf(" ID_MEDIA_PLAYER=1\n");
+          printf(" ID_MTP_DEVICE=1\n");
+          printf("\n");
+          break;
       }
       last_vendor = entry->vendor_id;
     }
@@ -250,6 +265,7 @@
   // Then the footer.
   switch (style) {
   case style_usbmap:
+  case style_hwdb:
     break;
   case style_udev:
   case style_udev_old: