Makefile 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ifeq "$(V)" "0"
  2. STATUS = git status -s
  3. Q=@
  4. else
  5. STATUS = git status
  6. Q=
  7. endif
  8. PKG_CONFIG ?= pkg-config
  9. GZIP ?= yes
  10. NET ?= yes
  11. PCI ?= yes
  12. UDEV ?= no
  13. USB ?= yes
  14. COMPRESS_FILES-yes =
  15. COMPRESS_FILES-$(PCI) += pci.ids.gz
  16. COMPRESS_FILES-$(USB) += usb.ids.gz
  17. DATA_FILES-yes =
  18. DATA_FILES-$(GZIP) += $(COMPRESS_FILES-yes)
  19. DATA_FILES-$(NET) += oui.txt iab.txt
  20. DATA_FILES-$(PCI) += pci.ids
  21. DATA_FILES-$(USB) += usb.ids
  22. ALL_TARGETS-yes =
  23. ALL_TARGETS-$(GZIP) += $(COMPRESS_FILES-yes)
  24. ALL_TARGETS-$(UDEV) += udev-hwdb
  25. INSTALL_TARGETS-yes = install-base
  26. INSTALL_TARGETS-$(UDEV) += install-hwdb
  27. SYSTEMD_SOURCE = https://github.com/systemd/systemd/raw/master/hwdb
  28. UDEV_FILES = 20-acpi-vendor.hwdb 20-bluetooth-vendor-product.hwdb
  29. UDEV_FILES += 20-net-ifname.hwdb 60-evdev.hwdb 60-keyboard.hwdb 70-mouse.hwdb
  30. UDEV_FILES += 70-pointingstick.hwdb
  31. all: $(ALL_TARGETS-yes)
  32. install: $(INSTALL_TARGETS-yes)
  33. fetch:
  34. $(Q)curl -z pci.ids -o pci.ids -R http://pci-ids.ucw.cz/v2.2/pci.ids
  35. $(Q)curl -z usb.ids -o usb.ids -R http://www.linux-usb.org/usb.ids
  36. $(Q)curl -z oui.txt -o oui.txt -R http://standards-oui.ieee.org/oui.txt
  37. $(Q)curl -z iab.txt -o iab.txt -R http://standards.ieee.org/develop/regauth/iab/iab.txt
  38. $(Q)curl -L -z sdio.ids -o sdio.ids -R $(SYSTEMD_SOURCE)/sdio.ids
  39. $(Q)curl -L -z udev-hwdb-update.pl -o udev-hwdb-update.pl -R $(SYSTEMD_SOURCE)/ids-update.pl
  40. $(Q)for f in $(UDEV_FILES); do curl -L -z udev/$$f -o udev/$$f -R $(SYSTEMD_SOURCE)/$$f; done
  41. $(Q)$(STATUS)
  42. PV ?= $(shell ( awk '$$2 == "Date:" { print $$3; nextfile }' pci.ids usb.ids; git log --format=format:%ci -1 -- oui.txt udev/20-acpi-vendor.hwdb udev/20-bluetooth-vendor-product.hwdb udev/20-net-ifname.hwdb udev/60-keyboard.hwdb udev/70-mouse.hwdb udev/70-pointingstick.hwdb udev/70-touchpad.hwdb udev-hwdb-update.pl | cut -d ' ' -f1; ) | sort | tail -n 1 | tr -d -)
  43. P = hwids-$(PV)
  44. tag:
  45. git tag $(P)
  46. udev-hwdb:
  47. perl ./udev-hwdb-update.pl && mv *.hwdb udev/
  48. compress: pci.ids.gz usb.ids.gz
  49. %.gz: %
  50. gzip -c $< > $@
  51. MISCDIR=/usr/share/misc
  52. HWDBDIR=$(shell $(PKG_CONFIG) --variable=udevdir udev)/hwdb.d
  53. DOCDIR=/usr/share/doc/hwids
  54. install-base: $(DATA_FILES-yes)
  55. mkdir -p $(DESTDIR)$(DOCDIR)
  56. install -p -m 644 README.md $(DESTDIR)$(DOCDIR)
  57. ifneq ($(strip $(DATA_FILES-yes)),)
  58. mkdir -p $(DESTDIR)$(MISCDIR)
  59. install -p -m 644 $(DATA_FILES-yes) $(DESTDIR)$(MISCDIR)
  60. endif
  61. install-hwdb:
  62. mkdir -p $(DESTDIR)$(HWDBDIR)
  63. install -p -m 644 udev/*.hwdb $(DESTDIR)$(HWDBDIR)
  64. udevadm hwdb --root $(DESTDIR) --update