Update.
[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 GZIP ?= yes
12 NET ?= yes
13 PCI ?= yes
14 UDEV ?= no
15 USB ?= yes
16
17 COMPRESS_FILES-yes =
18 COMPRESS_FILES-$(PCI) += pci.ids.gz
19 COMPRESS_FILES-$(USB) += usb.ids.gz
20
21 DATA_FILES-yes =
22 DATA_FILES-$(GZIP) += $(COMPRESS_FILES-yes)
23 DATA_FILES-$(NET) += oui.txt iab.txt
24 DATA_FILES-$(PCI) += pci.ids
25 DATA_FILES-$(USB) += usb.ids
26
27 ALL_TARGETS-yes =
28 ALL_TARGETS-$(GZIP) += $(COMPRESS_FILES-yes)
29 ALL_TARGETS-$(UDEV) += udev-hwdb
30
31 INSTALL_TARGETS-yes = install-base
32 INSTALL_TARGETS-$(UDEV) += install-hwdb
33
34 all: $(ALL_TARGETS-yes)
35
36 install: $(INSTALL_TARGETS-yes)
37
38 fetch:
39         $(Q)curl -z pci.ids -o pci.ids -R http://pci-ids.ucw.cz/v2.2/pci.ids
40         $(Q)curl -z usb.ids -o usb.ids -R http://www.linux-usb.org/usb.ids
41         $(Q)curl -z oui.txt -o oui.txt -R http://www.ieee.org/netstorage/standards/oui.txt
42         $(Q)curl -z iab.txt -o iab.txt -R http://standards.ieee.org/develop/regauth/iab/iab.txt
43         $(Q)curl -z sdio.ids -o sdio.ids -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/sdio.ids
44         $(Q)curl -z udev/20-acpi-vendor.hwdb -o udev/20-acpi-vendor.hwdb -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/20-acpi-vendor.hwdb
45         $(Q)curl -z udev/20-bluetooth-vendor-product.hwdb -o udev/20-bluetooth-vendor-product.hwdb -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/20-bluetooth-vendor-product.hwdb
46         $(Q)curl -z udev/20-net-ifname.hwdb -o udev/20-net-ifname.hwdb -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/20-net-ifname.hwdb
47         $(Q)curl -z udev/60-keyboard.hwdb -o udev/60-keyboard.hwdb -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/60-keyboard.hwdb
48         $(Q)curl -z udev/70-mouse.hwdb -o udev/70-mouse.hwdb -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/70-mouse.hwdb
49         $(Q)curl -z udev-hwdb-update.pl -o udev-hwdb-update.pl -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/ids-update.pl
50         $(Q)$(STATUS)
51
52 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-hwdb-update.pl | cut -d ' ' -f1; ) | sort | tail -n 1 | tr -d -)
53 P = hwids-$(PV)
54
55 tag:
56         git tag $(P)
57
58 udev-hwdb:
59         perl ./udev-hwdb-update.pl && mv *.hwdb udev/
60
61 compress: pci.ids.gz usb.ids.gz
62
63 %.gz: %
64         gzip -c $< > $@
65
66 MISCDIR=/usr/share/misc
67 HWDBDIR=$(shell $(PKG_CONFIG) --variable=udevdir udev)/hwdb.d
68 DOCDIR=/usr/share/doc/hwids
69
70 install-base: $(DATA_FILES-yes)
71         mkdir -p $(DESTDIR)$(DOCDIR)
72         install -p -m 644 README.md $(DESTDIR)$(DOCDIR)
73 ifneq ($(strip $(DATA_FILES-yes)),)
74         mkdir -p $(DESTDIR)$(MISCDIR)
75         install -p -m 644 $(DATA_FILES-yes) $(DESTDIR)$(MISCDIR)
76 endif
77
78 install-hwdb:
79         mkdir -p $(DESTDIR)$(HWDBDIR)
80         install -p -m 644 udev/*.hwdb $(DESTDIR)$(HWDBDIR)
81         udevadm hwdb --root $(DESTDIR) --update