Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/main/hwdb.d
  28. UDEV_FILES = 20-acpi-vendor.hwdb
  29. UDEV_FILES += 20-bluetooth-vendor-product.hwdb
  30. UDEV_FILES += 20-dmi-id.hwdb
  31. UDEV_FILES += 20-net-ifname.hwdb
  32. UDEV_FILES += 20-vmbus-class.hwdb
  33. UDEV_FILES += 60-autosuspend.hwdb
  34. UDEV_FILES += 60-autosuspend-fingerprint-reader.hwdb
  35. UDEV_FILES += 60-evdev.hwdb
  36. UDEV_FILES += 60-input-id.hwdb
  37. UDEV_FILES += 60-keyboard.hwdb
  38. UDEV_FILES += 60-sensor.hwdb
  39. UDEV_FILES += 70-joystick.hwdb
  40. UDEV_FILES += 70-mouse.hwdb
  41. UDEV_FILES += 70-pointingstick.hwdb
  42. UDEV_FILES += 70-touchpad.hwdb
  43. UDEV_FILES += 80-ieee1394-unit-function.hwdb
  44. all: $(ALL_TARGETS-yes)
  45. .PHONY: all install install-base install-hwdb fetch tag udev-hwdb compress
  46. install: $(INSTALL_TARGETS-yes)
  47. # OUI/IAB: https://regauth.standards.ieee.org/standards-ra-web/pub/view.html#registries
  48. fetch:
  49. $(Q)curl -z pci.ids -o pci.ids -R http://pci-ids.ucw.cz/v2.2/pci.ids
  50. $(Q)curl -z usb.ids -o usb.ids -R http://www.linux-usb.org/usb.ids
  51. $(Q)curl -z oui.txt -o oui.txt -R http://standards-oui.ieee.org/oui/oui.txt
  52. $(Q)curl -z ma-medium.txt -o ma-medium.txt -R http://standards-oui.ieee.org/oui28/mam.txt
  53. $(Q)curl -z ma-small.txt -o ma-small.txt -R http://standards-oui.ieee.org/oui36/oui36.txt
  54. $(Q)curl -z iab.txt -o iab.txt -R http://standards-oui.ieee.org/iab/iab.txt
  55. $(Q)curl -L -z sdio.ids -o sdio.ids -R $(SYSTEMD_SOURCE)/sdio.ids
  56. $(Q)curl -L -z ids_parser.py -o ids_parser.py -R $(SYSTEMD_SOURCE)/ids_parser.py
  57. $(Q)for f in $(UDEV_FILES); do curl -L -z udev/$$f -o udev/$$f -R $(SYSTEMD_SOURCE)/$$f; done
  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 -s $(P)
  63. udev-hwdb:
  64. $(PYTHON) ids_parser.py
  65. $(PYTHON) make-autosuspend-rules.py > 60-autosuspend-chromiumos.hwdb
  66. mv *.hwdb udev/
  67. compress: pci.ids.gz usb.ids.gz
  68. %.gz: %
  69. gzip -c $< > $@
  70. MISCDIR=/usr/share/misc
  71. HWDBDIR=$(shell $(PKG_CONFIG) --variable=udevdir udev)/hwdb.d
  72. DOCDIR=/usr/share/doc/hwids
  73. install-base: $(DATA_FILES-yes)
  74. mkdir -p $(DESTDIR)$(DOCDIR)
  75. install -p -m 644 README.md $(DESTDIR)$(DOCDIR)
  76. ifneq ($(strip $(DATA_FILES-yes)),)
  77. mkdir -p $(DESTDIR)$(MISCDIR)
  78. install -p -m 644 $(DATA_FILES-yes) $(DESTDIR)$(MISCDIR)
  79. endif
  80. install-hwdb:
  81. mkdir -p $(DESTDIR)$(HWDBDIR)
  82. install -p -m 644 udev/*.hwdb $(DESTDIR)$(HWDBDIR)
  83. udevadm hwdb --root $(DESTDIR) --update