New pci, usb and vendor ids
[oweals/hwdata.git] / Makefile
1 NAME=hwdata
2 VERSION=$(shell awk '/Version:/ { print $$2 }' hwdata.spec)
3 RELEASE=$(shell rpm -q --define 'dist %{nil}' --specfile --qf "%{release}" hwdata.spec)
4 ifeq ($(shell git rev-parse --abbrev-ref HEAD | sed -n 's/^\([^0-9-]\+\).*/\L\1/p'), rhel)
5     # add revision to tag name for rhel branches
6     TAGNAME := $(NAME)-$(VERSION)-$(RELEASE)
7 else
8     TAGNAME := $(NAME)-$(VERSION)
9 endif
10 SOURCEDIR := $(shell pwd)
11 ARCHIVE := $(TAGNAME).tar.bz2
12
13 CVSROOT = $(shell cat CVS/Root 2>/dev/null || :)
14
15 CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
16
17 FILES = pci.ids usb.ids oui.txt iab.txt pnp.ids
18
19 .PHONY: all install tag force-tag check commit create-archive archive srpm-x \
20     clean clog new-pci-ids new-usb-ids new-oui new-iab new-pnp-ids
21
22 include Makefile.inc
23
24 all:
25
26 Makefile.inc: configure
27         ./configure
28         @echo "$@ generated. Run the make again."
29         @exit 1
30
31 install: Makefile.inc
32         mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME)
33         for foo in $(FILES) ; do \
34                 install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\
35         done
36         mkdir -p -m 755 $(DESTDIR)$(libdir)/modprobe.d
37         install -m 644 -T blacklist.conf $(DESTDIR)$(libdir)/modprobe.d/dist-blacklist.conf
38
39 commit:
40         git commit -a ||:
41
42 tag:
43         @git tag -s -m "Tag as $(TAGNAME)" $(TAGNAME)
44         @echo "Tagged as $(TAGNAME)"
45
46 force-tag:
47         @git tag -s -f $(TAGNAME)
48         @echo "Tag forced as $(TAGNAME)"
49
50 changelog:
51         @rm -f ChangeLog
52         @(GIT_DIR=.git git log > .changelog.tmp && mv .changelog.tmp ChangeLog || rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2)
53
54 check:
55         @[ -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"
56         @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
57         @if [[ -e /run/docker.sock ]]; then \
58             tmpdir=`mktemp -d`; \
59             echo "Listing usb devices:"; \
60             docker run -t --privileged --rm=true \
61                 -v `pwd`/usb.ids:/usr/share/hwdata/usb.ids:ro \
62                 -v "$$tmpdir:/mnt/out" \
63                 miminar/hwdata-check /bin/bash -c 'lsusb 2>/mnt/out/err.out'; \
64             if [[ `cat $$tmpdir/err.out | wc -l` -gt 0 ]]; then \
65                 echo "ERRORS:"; nl $$tmpdir/err.out; rm -rf $$tmpdir; exit 1; \
66             fi; \
67             rm -rf $$tmpdir; \
68         fi
69         @echo -n "CHECK date of pci.ids: "; grep "Date:" pci.ids | cut -d ' ' -f 5
70         @echo -n "CHECK date of usb.ids: "; grep "Date:" usb.ids | cut -d ' ' -f 6
71
72 create-archive:
73         @rm -rf $(TAGNAME) $(TAGNAME).tar*  2>/dev/null
74         @make changelog
75         @git archive --format=tar --prefix=$(TAGNAME)/ HEAD > $(TAGNAME).tar
76         @mkdir $(TAGNAME)
77         @cp ChangeLog $(TAGNAME)/
78         @tar --append -f $(TAGNAME).tar $(TAGNAME)
79         @bzip2 -f $(TAGNAME).tar
80         @rm -rf $(TAGNAME)
81         @echo ""
82         @echo "The final archive is in $(ARCHIVE)"
83
84 archive: check clean commit tag create-archive
85
86 upload:
87         @scp $(ARCHIVE) fedorahosted.org:$(NAME)
88
89 dummy:
90
91 srpm-x: create-archive
92         @echo Creating $(NAME) src.rpm
93         @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
94         @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
95
96 clean:
97         @rm -f $(NAME)-*.gz $(NAME)-*.src.rpm new-pnp.xlsx pnp.ids.txt
98
99 clog: hwdata.spec
100         @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
101
102 download: new-usb-ids new-pci-ids new-oui new-iab new-pnp-ids
103
104 new-usb-ids:
105         @curl -O http://www.linux-usb.org/usb.ids
106
107 new-pci-ids:
108         @curl -O http://pciids.sourceforge.net/pci.ids
109
110 new-oui:
111         @curl -O http://standards-oui.ieee.org/oui.txt
112
113 new-iab:
114         @curl -O http://standards.ieee.org/develop/regauth/iab/iab.txt
115
116 new-pnp-ids: pnp.ids
117
118 pnp.ids: pnp.ids.txt pnp.ids.patch
119         patch -o $@ <pnp.ids.patch
120
121 pnp.ids.txt: new-pnp.xlsx
122         @unoconv --stdout -f csv $? | \
123             tr ' ' ' ' | \
124             sed -n \
125                 -e 's/^\s*"\s*\(.*\)\s*"/\1/' \
126                 -e 's/\s\{2,\}/ /g' \
127                 -e 's/\s*(used as 2nd pnpid)\s*//' \
128                 -e 's:^\(.*\)\s*,\s*\([a-zA-Z@]\{3\}\)\s*,\s*\([0-9]\+/[0-9]\+/[0-9]\+\):\2\t\1:p' | \
129             sed 's/\s*$$//' | sort -u >$@
130
131 new-pnp.xlsx:
132         @curl -o $@ \
133             http://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/ISA_PNPID_List.xlsx