Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. PYTHON ?= python3
  10. GZIP ?= yes
  11. NET ?= yes
  12. PCI ?= yes
  13. UDEV ?= no
  14. USB ?= yes
  15. COMPRESS_FILES-yes =
  16. COMPRESS_FILES-$(PCI) += pci.ids.gz
  17. COMPRESS_FILES-$(USB) += usb.ids.gz
  18. DATA_FILES-yes =
  19. DATA_FILES-$(GZIP) += $(COMPRESS_FILES-yes)
  20. DATA_FILES-$(NET) += oui.txt iab.txt
  21. DATA_FILES-$(PCI) += pci.ids
  22. DATA_FILES-$(USB) += usb.ids
  23. ALL_TARGETS-yes =
  24. ALL_TARGETS-$(GZIP) += $(COMPRESS_FILES-yes)
  25. INSTALL_TARGETS-yes = install-base
  26. INSTALL_TARGETS-$(UDEV) += install-hwdb
  27. SYSTEMD_SOURCE = https://github.com/systemd/systemd/raw/master/hwdb.d
  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 60-sensor.hwdb
  30. UDEV_FILES += 70-joystick.hwdb 70-mouse.hwdb 70-pointingstick.hwdb 70-touchpad.hwdb
  31. UDEV_PATHS = $(addprefix udev/,$(UDEV_FILES))
  32. all: $(ALL_TARGETS-yes)
  33. .PHONY: all install install-base install-hwdb fetch tag udev-hwdb compress
  34. .PHONY: pci.ids usb.ids oui.txt ma-medium.txt ma-small.txt iab.txt sdio.ids ids_parser.py
  35. .PHONY: $(UDEV_PATHS)
  36. install: $(INSTALL_TARGETS-yes)
  37. curl-get = $(Q)curl -s -L -z $@ -o $@ -R $1
  38. pci.ids:
  39. $(call curl-get,http://pci-ids.ucw.cz/v2.2/pci.ids)
  40. usb.ids:
  41. $(call curl-get,http://www.linux-usb.org/usb.ids)
  42. # OUI/IAB: https://regauth.standards.ieee.org/standards-ra-web/pub/view.html#registries
  43. oui.txt:
  44. $(call curl-get,http://standards-oui.ieee.org/oui/oui.txt)
  45. ma-medium.txt:
  46. $(call curl-get,http://standards-oui.ieee.org/oui28/mam.txt)
  47. ma-small.txt:
  48. $(call curl-get,http://standards-oui.ieee.org/oui36/oui36.txt)
  49. iab.txt:
  50. $(call curl-get,http://standards-oui.ieee.org/iab/iab.txt)
  51. sdio.ids:
  52. $(call curl-get,$(SYSTEMD_SOURCE)/sdio.ids)
  53. ids_parser.py:
  54. $(call curl-get,$(SYSTEMD_SOURCE)/ids_parser.py)
  55. $(UDEV_PATHS):
  56. $(call curl-get,$(SYSTEMD_SOURCE)/$(notdir $@))
  57. fetch: pci.ids usb.ids oui.txt ma-medium.txt ma-small.txt iab.txt sdio.ids ids_parser.py $(UDEV_PATHS)
  58. $(Q)$(STATUS)
  59. PV ?= $(shell ( awk '$$2 == "Date:" { print $$3; nextfile }' pci.ids usb.ids; git log --format=format:%ci -1 -- oui.txt $(addprefix udev/,$(UDEV_FILES)) ids_parser.py | cut -d ' ' -f1; ) | sort | tail -n 1 | tr -d -)
  60. P = hwids-$(PV)
  61. tag:
  62. git tag $(P)
  63. udev-hwdb:
  64. $(PYTHON) ids_parser.py && mv *.hwdb udev/
  65. compress: pci.ids.gz usb.ids.gz
  66. %.gz: %
  67. gzip -c $< > $@
  68. MISCDIR=/usr/share/misc
  69. HWDBDIR=$(shell $(PKG_CONFIG) --variable=udevdir udev)/hwdb.d
  70. DOCDIR=/usr/share/doc/hwids
  71. install-base: $(DATA_FILES-yes)
  72. mkdir -p $(DESTDIR)$(DOCDIR)
  73. install -p -m 644 README.md $(DESTDIR)$(DOCDIR)
  74. ifneq ($(strip $(DATA_FILES-yes)),)
  75. mkdir -p $(DESTDIR)$(MISCDIR)
  76. install -p -m 644 $(DATA_FILES-yes) $(DESTDIR)$(MISCDIR)
  77. endif
  78. install-hwdb:
  79. mkdir -p $(DESTDIR)$(HWDBDIR)
  80. install -p -m 644 udev/*.hwdb $(DESTDIR)$(HWDBDIR)
  81. udevadm hwdb --root $(DESTDIR) --update