Declare phony targets
[oweals/hwids.git] / Makefile
index 67c18c27cdd02509b92581d193e0ccd4e733807c..5dd4b3bdbee313d1232f114ca5286566189f393f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,38 +7,62 @@ else
   Q=
 endif
 
-ifeq "$(UDEV)" "yes"
-  ALL_TARGETS=compress udev-hwdb
-  INSTALL_TARGETS=install-base install-hwdb
-else
-  ALL_TARGETS=compress
-  INSTALL_TARGETS=install-base
-endif
+PKG_CONFIG ?= pkg-config
+PYTHON ?= python3
+GZIP ?= yes
+NET ?= yes
+PCI ?= yes
+UDEV ?= no
+USB ?= yes
+
+COMPRESS_FILES-yes =
+COMPRESS_FILES-$(PCI) += pci.ids.gz
+COMPRESS_FILES-$(USB) += usb.ids.gz
+
+DATA_FILES-yes =
+DATA_FILES-$(GZIP) += $(COMPRESS_FILES-yes)
+DATA_FILES-$(NET) += oui.txt iab.txt
+DATA_FILES-$(PCI) += pci.ids
+DATA_FILES-$(USB) += usb.ids
+
+ALL_TARGETS-yes =
+ALL_TARGETS-$(GZIP) += $(COMPRESS_FILES-yes)
 
-all: $(ALL_TARGETS)
+INSTALL_TARGETS-yes = install-base
+INSTALL_TARGETS-$(UDEV) += install-hwdb
 
-install: $(INSTALL_TARGETS)
+SYSTEMD_SOURCE = https://github.com/systemd/systemd/raw/master/hwdb
+UDEV_FILES = 20-acpi-vendor.hwdb 20-bluetooth-vendor-product.hwdb
+UDEV_FILES += 20-net-ifname.hwdb 60-evdev.hwdb 60-keyboard.hwdb 60-sensor.hwdb
+UDEV_FILES += 70-joystick.hwdb 70-mouse.hwdb 70-pointingstick.hwdb 70-touchpad.hwdb
 
+all: $(ALL_TARGETS-yes)
+
+.PHONY: all install install-base install-hwdb fetch tag udev-hwdb compress
+
+install: $(INSTALL_TARGETS-yes)
+
+# OUI/IAB: https://regauth.standards.ieee.org/standards-ra-web/pub/view.html#registries
 fetch:
        $(Q)curl -z pci.ids -o pci.ids -R http://pci-ids.ucw.cz/v2.2/pci.ids
        $(Q)curl -z usb.ids -o usb.ids -R http://www.linux-usb.org/usb.ids
-       $(Q)curl -z oui.txt -o oui.txt -R http://standards.ieee.org/develop/regauth/oui/oui.txt
-       $(Q)curl -z iab.txt -o iab.txt -R http://standards.ieee.org/develop/regauth/iab/iab.txt
-       $(Q)curl -z sdio.ids -o sdio.ids -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/sdio.ids
-       $(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
-       $(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
-       $(Q)curl -z udev/60-keyboard.hwdb -o udev/60-keyboard.hwdb -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/60-keyboard.hwdb
-       $(Q)curl -z udev-hwdb-update.pl -o udev-hwdb-update.pl -R http://cgit.freedesktop.org/systemd/systemd/plain/hwdb/ids-update.pl
+       $(Q)curl -z oui.txt -o oui.txt -R http://standards-oui.ieee.org/oui/oui.txt
+       $(Q)curl -z ma-medium.txt -o ma-medium.txt -R http://standards-oui.ieee.org/oui28/mam.txt
+       $(Q)curl -z ma-small.txt -o ma-small.txt -R http://standards-oui.ieee.org/oui36/oui36.txt
+       $(Q)curl -z iab.txt -o iab.txt -R http://standards-oui.ieee.org/iab/iab.txt
+       $(Q)curl -L -z sdio.ids -o sdio.ids -R $(SYSTEMD_SOURCE)/sdio.ids
+       $(Q)curl -L -z ids_parser.py -o ids_parser.py -R $(SYSTEMD_SOURCE)/ids_parser.py
+       $(Q)for f in $(UDEV_FILES); do curl -L -z udev/$$f -o udev/$$f -R $(SYSTEMD_SOURCE)/$$f; done
        $(Q)$(STATUS)
 
-PV ?= $(shell ( awk '$$2 == "Date:" { print $$3; nextfile }' pci.ids usb.ids; git log --format=format:%ci -1 -- oui.txt hwdb/20-acpi-vendor.hwdb udev/20-bluetooth-vendor-product.hwdb udev-hwdb-update.pl | cut -d ' ' -f1; ) | sort | tail -n 1 | tr -d -)
+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 -)
 P = hwids-$(PV)
 
 tag:
        git tag $(P)
 
 udev-hwdb:
-       perl ./udev-hwdb-update.pl && mv *.hwdb udev/
+       $(PYTHON) ids_parser.py && mv *.hwdb udev/
 
 compress: pci.ids.gz usb.ids.gz
 
@@ -46,20 +70,18 @@ compress: pci.ids.gz usb.ids.gz
        gzip -c $< > $@
 
 MISCDIR=/usr/share/misc
-HWDBDIR=$(shell pkg-config --variable=udevdir udev)/hwdb.d
+HWDBDIR=$(shell $(PKG_CONFIG) --variable=udevdir udev)/hwdb.d
 DOCDIR=/usr/share/doc/hwids
 
-install-base: compress
+install-base: $(DATA_FILES-yes)
        mkdir -p $(DESTDIR)$(DOCDIR)
        install -p -m 644 README.md $(DESTDIR)$(DOCDIR)
+ifneq ($(strip $(DATA_FILES-yes)),)
        mkdir -p $(DESTDIR)$(MISCDIR)
-       for file in usb.ids pci.ids usb.ids.gz pci.ids.gz oui.txt iab.txt; do \
-               install -p -m 644 $$file $(DESTDIR)$(MISCDIR); \
-       done
+       install -p -m 644 $(DATA_FILES-yes) $(DESTDIR)$(MISCDIR)
+endif
 
 install-hwdb:
        mkdir -p $(DESTDIR)$(HWDBDIR)
-       for file in udev/*.hwdb; do \
-               install -p -m 644 $$file $(DESTDIR)$(HWDBDIR); \
-       done
+       install -p -m 644 udev/*.hwdb $(DESTDIR)$(HWDBDIR)
        udevadm hwdb --root $(DESTDIR) --update