- Updated pci, usb and vendor ids
[oweals/hwdata.git] / Makefile
index b73a9cffbea08e9be3ebd5401aa6c760ff78197b..05988b726428c54588931ea6f0fa4072c38730e8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,9 +3,9 @@ VERSION=$(shell awk '/Version:/ { print $$2 }' hwdata.spec)
 RELEASE=$(shell rpm -q --define 'dist %{nil}' --specfile --qf "%{release}" hwdata.spec)
 ifeq ($(shell git rev-parse --abbrev-ref HEAD | sed -n 's/^\([^0-9-]\+\).*/\L\1/p'), rhel)
     # add revision to tag name for rhel branches
-    TAGNAME := $(NAME)-$(VERSION)-$(RELEASE)
+    TAGNAME := v$(VERSION)-$(RELEASE)
 else
-    TAGNAME := $(NAME)-$(VERSION)
+    TAGNAME := v$(VERSION)
 endif
 SOURCEDIR := $(shell pwd)
 ARCHIVE := $(TAGNAME).tar.bz2
@@ -16,8 +16,11 @@ CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
 
 IDFILES = pci.ids usb.ids oui.txt iab.txt pnp.ids
 
+# usb.ids is not in UTF-8
+UTF_IDFILES = pci.ids oui.txt iab.txt pnp.ids
+
 .PHONY: all install tag force-tag check commit create-archive archive srpm-x \
-    clean clog new-pci-ids new-usb-ids new-oui new-iab new-pnp-ids
+    clean clog download
 
 include Makefile.inc
 
@@ -30,14 +33,14 @@ Makefile.inc: configure
 
 install: Makefile.inc
        mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME)
-       for foo in $(FILES) ; do \
+       for foo in $(IDFILES) ; do \
                install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\
        done
        mkdir -p -m 755 $(DESTDIR)$(libdir)/modprobe.d
        install -m 644 -T blacklist.conf $(DESTDIR)$(libdir)/modprobe.d/dist-blacklist.conf
 
 commit:
-       git commit -a ||:
+       git commit -vas ||:
 
 tag:
        @git tag -s -m "Tag as $(TAGNAME)" $(TAGNAME)
@@ -55,7 +58,7 @@ check:
        @[ -x /sbin/lspci ] && /sbin/lspci -i pci.ids > /dev/null || { echo "FAILURE: /sbin/lspci -i pci.ids"; exit 1; } && echo "OK: /sbin/lspci -i pci.ids"
        @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
        @./check-usb-ids.sh
-       @for file in $(IDFILES); do \
+       @for file in $(UTF_IDFILES); do \
            text=`LANG=C file $$file`; \
            expected="$$file: UTF-8 Unicode text"; \
            if [[ "$$text" != "$$expected" ]]; then \
@@ -79,46 +82,54 @@ create-archive:
        @echo ""
        @echo "The final archive is in $(ARCHIVE)"
 
-archive: check clean commit tag create-archive
+archive: check clean commit tag
 
 upload:
        @scp $(ARCHIVE) fedorahosted.org:$(NAME)
 
-dummy:
-
 srpm-x: create-archive
        @echo Creating $(NAME) src.rpm
        @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
        @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
 
 clean:
-       @rm -f $(NAME)-*.gz $(NAME)-*.src.rpm new-pnp.xlsx pnp.ids.txt
+       @rm -f $(NAME)-*.gz $(NAME)-*.src.rpm pnp.ids.xlsx \
+           *.downloaded *.utf8 *.orig
 
 clog: hwdata.spec
        @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
 
-download: new-usb-ids new-pci-ids new-oui new-iab new-pnp-ids
+download: $(IDFILES)
 
-new-usb-ids:
-       @curl -O http://www.linux-usb.org/usb.ids
+usb.ids.downloaded:
+       @curl -o $@ http://www.linux-usb.org/usb.ids
 
-new-pci-ids:
-       @curl -O https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids
+pci.ids.downloaded:
+       @curl -o $@ https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids
 
-new-oui:
-       @curl -O http://standards-oui.ieee.org/oui.txt
-       @dos2unix oui.txt
+oui.txt.downloaded:
+       @curl -o $@ -O http://standards-oui.ieee.org/oui.txt
 
-new-iab:
-       @curl -O http://standards-oui.ieee.org/iab/iab.txt
-       @dos2unix iab.txt
+iab.txt.downloaded:
+       @curl -o $@ -O http://standards-oui.ieee.org/iab/iab.txt
 
-new-pnp-ids: pnp.ids
+pnp.ids.xlsx:
+       @curl -o $@ \
+           http://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/ISA_PNPID_List.xlsx
 
-pnp.ids: pnp.ids.txt pnp.ids.patch
-       patch -o $@ <pnp.ids.patch
+usb.ids: usb.ids.utf8
+       dos2unix -n $? $@
+
+pci.ids: pci.ids.utf8
+       dos2unix -n $? $@
+
+oui.txt: oui.txt.utf8
+       dos2unix -n $? $@
 
-pnp.ids.txt: new-pnp.xlsx
+iab.txt: iab.txt.utf8
+       dos2unix -n $? $@
+
+pnp.ids.orig: pnp.ids.xlsx
        @unoconv --stdout -f csv $? | \
            tr ' ' ' ' | \
            sed -n \
@@ -128,6 +139,15 @@ pnp.ids.txt: new-pnp.xlsx
                -e 's:^\(.*\)\s*,\s*\([a-zA-Z@]\{3\}\)\s*,\s*\([0-9]\+/[0-9]\+/[0-9]\+\):\2\t\1:p' | \
            sed 's/\s*$$//' | sort -u >$@
 
-new-pnp.xlsx:
-       @curl -o $@ \
-           http://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/ISA_PNPID_List.xlsx
+pnp.ids: pnp.ids.orig pnp.ids.patch
+       patch -o $@ <pnp.ids.patch
+
+%.utf8: %.downloaded
+       @text=`LANG=C file $?`
+       @encoding=`echo "$$text" | sed -n 's/.*\(iso-8859\S\*\|cp1[12]\d\+\).*/\1/Ip'`
+       @if [[ -n "$$encoding" ]]; then \
+           iconv -f "$$encoding" -t UTF-8 $?; \
+       else \
+           cat $?; \
+       fi | sed 's/\s\+$$//' >$@
+