Use new python script for udev database updates
[oweals/hwids.git] / Makefile
1
2 ifeq "$(V)" "0"
3   STATUS = git status -s
4   Q=@
5 else
6   STATUS = git status
7   Q=
8 endif
9
10 PKG_CONFIG ?= pkg-config
11 PYTHON ?= python3
12 GZIP ?= yes
13 NET ?= yes
14 PCI ?= yes
15 UDEV ?= no
16 USB ?= yes
17
18 COMPRESS_FILES-yes =
19 COMPRESS_FILES-$(PCI) += pci.ids.gz
20 COMPRESS_FILES-$(USB) += usb.ids.gz
21
22 DATA_FILES-yes =
23 DATA_FILES-$(GZIP) += $(COMPRESS_FILES-yes)
24 DATA_FILES-$(NET) += oui.txt iab.txt
25 DATA_FILES-$(PCI) += pci.ids
26 DATA_FILES-$(USB) += usb.ids
27
28 ALL_TARGETS-yes =
29 ALL_TARGETS-$(GZIP) += $(COMPRESS_FILES-yes)
30 ALL_TARGETS-$(UDEV) += udev-hwdb
31
32 INSTALL_TARGETS-yes = install-base
33 INSTALL_TARGETS-$(UDEV) += install-hwdb
34
35 SYSTEMD_SOURCE = https://github.com/systemd/systemd/raw/master/hwdb
36 UDEV_FILES = 20-acpi-vendor.hwdb 20-bluetooth-vendor-product.hwdb
37 UDEV_FILES += 20-net-ifname.hwdb 60-evdev.hwdb 60-keyboard.hwdb 60-sensor.hwdb
38 UDEV_FILES += 70-joystick.hwdb 70-mouse.hwdb 70-pointingstick.hwdb 70-touchpad.hwdb
39
40 all: $(ALL_TARGETS-yes)
41
42 install: $(INSTALL_TARGETS-yes)
43
44 # OUI/IAB: https://regauth.standards.ieee.org/standards-ra-web/pub/view.html#registries
45 fetch:
46         $(Q)curl -z pci.ids -o pci.ids -R http://pci-ids.ucw.cz/v2.2/pci.ids
47         $(Q)curl -z usb.ids -o usb.ids -R http://www.linux-usb.org/usb.ids
48         $(Q)curl -z oui.txt -o oui.txt -R http://standards-oui.ieee.org/oui/oui.txt
49         $(Q)curl -z ma-medium.txt -o ma-medium.txt -R http://standards-oui.ieee.org/oui28/mam.txt
50         $(Q)curl -z ma-small.txt -o ma-small.txt -R http://standards-oui.ieee.org/oui36/oui36.txt
51         $(Q)curl -z iab.txt -o iab.txt -R http://standards-oui.ieee.org/iab/iab.txt
52         $(Q)curl -L -z sdio.ids -o sdio.ids -R $(SYSTEMD_SOURCE)/sdio.ids
53         $(Q)curl -L -z ids_parser.py -o ids_parser.py -R $(SYSTEMD_SOURCE)/ids_parser.py
54         $(Q)for f in $(UDEV_FILES); do curl -L -z udev/$$f -o udev/$$f -R $(SYSTEMD_SOURCE)/$$f; done
55         $(Q)$(STATUS)
56
57 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 -)
58 P = hwids-$(PV)
59
60 tag:
61         git tag $(P)
62
63 udev-hwdb:
64         $(PYTHON) ids_parser.py && mv *.hwdb udev/
65
66 compress: pci.ids.gz usb.ids.gz
67
68 %.gz: %
69         gzip -c $< > $@
70
71 MISCDIR=/usr/share/misc
72 HWDBDIR=$(shell $(PKG_CONFIG) --variable=udevdir udev)/hwdb.d
73 DOCDIR=/usr/share/doc/hwids
74
75 install-base: $(DATA_FILES-yes)
76         mkdir -p $(DESTDIR)$(DOCDIR)
77         install -p -m 644 README.md $(DESTDIR)$(DOCDIR)
78 ifneq ($(strip $(DATA_FILES-yes)),)
79         mkdir -p $(DESTDIR)$(MISCDIR)
80         install -p -m 644 $(DATA_FILES-yes) $(DESTDIR)$(MISCDIR)
81 endif
82
83 install-hwdb:
84         mkdir -p $(DESTDIR)$(HWDBDIR)
85         install -p -m 644 udev/*.hwdb $(DESTDIR)$(HWDBDIR)
86         udevadm hwdb --root $(DESTDIR) --update