respect $PKG_CONFIG env var
[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 ifeq "$(UDEV)" "yes"
12   ALL_TARGETS=compress udev-hwdb
13   INSTALL_TARGETS=install-base install-hwdb
14 else
15   ALL_TARGETS=compress
16   INSTALL_TARGETS=install-base
17 endif
18
19 all: $(ALL_TARGETS)
20
21 install: $(INSTALL_TARGETS)
22
23 fetch:
24         $(Q)curl -z pci.ids -o pci.ids -R http://pci-ids.ucw.cz/v2.2/pci.ids
25         $(Q)curl -z usb.ids -o usb.ids -R http://www.linux-usb.org/usb.ids
26         $(Q)curl -z oui.txt -o oui.txt -R http://standards.ieee.org/develop/regauth/oui/oui.txt
27         $(Q)curl -z iab.txt -o iab.txt -R http://standards.ieee.org/develop/regauth/iab/iab.txt
28         $(Q)curl -z sdio.ids -o sdio.ids -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/sdio.ids
29         $(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
30         $(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
31         $(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
32         $(Q)curl -z udev/60-keyboard.hwdb -o udev/60-keyboard.hwdb -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/60-keyboard.hwdb
33         $(Q)curl -z udev-hwdb-update.pl -o udev-hwdb-update.pl -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/ids-update.pl
34         $(Q)$(STATUS)
35
36 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-hwdb-update.pl | cut -d ' ' -f1; ) | sort | tail -n 1 | tr -d -)
37 P = hwids-$(PV)
38
39 tag:
40         git tag $(P)
41
42 udev-hwdb:
43         perl ./udev-hwdb-update.pl && mv *.hwdb udev/
44
45 compress: pci.ids.gz usb.ids.gz
46
47 %.gz: %
48         gzip -c $< > $@
49
50 MISCDIR=/usr/share/misc
51 HWDBDIR=$(shell $(PKG_CONFIG) --variable=udevdir udev)/hwdb.d
52 DOCDIR=/usr/share/doc/hwids
53
54 install-base: compress
55         mkdir -p $(DESTDIR)$(DOCDIR)
56         install -p -m 644 README.md $(DESTDIR)$(DOCDIR)
57         mkdir -p $(DESTDIR)$(MISCDIR)
58         install -p -m 644 usb.ids pci.ids usb.ids.gz pci.ids.gz oui.txt iab.txt $(DESTDIR)$(MISCDIR)
59
60 install-hwdb:
61         mkdir -p $(DESTDIR)$(HWDBDIR)
62         install -p -m 644 udev/*.hwdb $(DESTDIR)$(HWDBDIR)
63         udevadm hwdb --root $(DESTDIR) --update