Move compress/install logic to Makefile. hwids-20121208.2
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>
Sat, 8 Dec 2012 11:41:21 +0000 (03:41 -0800)
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>
Sat, 8 Dec 2012 11:41:21 +0000 (03:41 -0800)
This basically moves the logic from the ebuild into the hwids package
itself, since that should be shareable by other distributions as well.
Now that udev has more complex installs, it's worth doing it.

Makefile

index 346eafe68a3bee7fcd6ba5475d32d376ad3326c1..15d62deba3c17520a5517a1101db55b9bcca1742 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,18 @@ else
   Q=
 endif
 
+ifeq "$(UDEV)" "yes"
+  ALL_TARGETS="compress udev-hwdb"
+  INSTALL_TARGETS="install-base install-hwdb"
+else
+  ALL_TARGETS="compress"
+  INSTALL_TARGETS="install-base"
+endif
+
+all: $(ALL_TARGETS)
+
+install: $(INSTALL_TARGETS)
+
 fetch:
        $(Q)curl -z pci.ids -o pci.ids -R http://pci-ids.ucw.cz/v2.2/pci.ids
        $(Q)curl -z usb.ids -o usb.ids -R http://www.linux-usb.org/usb.ids
@@ -23,3 +35,26 @@ tag:
 
 udev-hwdb:
        perl ./udev-hwdb-update.pl && mv *.hwdb udev/
+
+compress: pci.ids.gz usb.ids.gz
+
+%.gz: %
+       gzip -c $< > $@
+
+MISCDIR=/usr/share/misc
+HWDBDIR=/usr/lib/udev/hwdb.d
+DOCDIR=/usr/share/doc/hwids
+
+install-base: compress
+       mkdir -p $(DESTDIR)$(DOCDIR)
+       install -p README.md $(DESTDIR)$(DOCDIR)
+       mkdir -p $(DESTDIR)$(MISCDIR)
+       for file in {usb,pci}.ids{,.gz} {oui,iab}.txt; do \
+               install -p $$file $(DESTDIR)$(MISCDIR)
+       done
+
+install-udev:
+       mkdir -p $(DESTDIR)$(HWDBDIR)
+       for file in udev/*.hwdb; do \
+               install -p $$file $(DESTDIR)$(HWDBDIR)
+       done