do not use release in tag names in master branch
[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/^\([^-]\+\).*/\1/p'), rhel)
5     # add revision to tag name for rhel branches
6     TAGNAME := $(NAME)-$(VERSION)-$(REVISION)
7 else
8     TAGNAME := $(NAME)-$(VERSION)
9 endif
10 SOURCEDIR := $(shell pwd)
11
12 CVSROOT = $(shell cat CVS/Root 2>/dev/null || :)
13
14 CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
15
16 FILES = pci.ids usb.ids oui.txt pnp.ids
17
18 .PHONY: all install tag force-tag check commit create-archive archive srpm-x \
19     clean clog new-pci-ids new-usb-ids new-pnp-ids
20
21 include Makefile.inc
22
23 all:
24
25 Makefile.inc: configure
26         ./configure
27         @echo "$@ generated. Run the make again."
28         @exit 1
29
30 install: Makefile.inc
31         mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME)
32         for foo in $(FILES) ; do \
33                 install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\
34         done
35         mkdir -p -m 755 $(DESTDIR)$(libdir)/modprobe.d
36         install -m 644 -T blacklist.conf $(DESTDIR)$(libdir)/modprobe.d/dist-blacklist.conf
37
38 commit:
39         git commit -a ||:
40
41 tag:
42         @git tag -s -m "Tag as $(TAGNAME)" $(TAGNAME)
43         @echo "Tagged as $(TAGNAME)"
44
45 force-tag:
46         @git tag -s -f $(TAGNAME)
47         @echo "Tag forced as $(TAGNAME)"
48
49 changelog:
50         @rm -f ChangeLog
51         @(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)
52
53 check:
54         @[ -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"
55         @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
56         @echo -n "CHECK date of pci.ids: "; grep "Date:" pci.ids | cut -d ' ' -f 5
57         @echo -n "CHECK date of usb.ids: "; grep "Date:" usb.ids | cut -d ' ' -f 6
58
59 create-archive:
60         @rm -rf $(NAME)-$(VERSION) $(NAME)-$(VERSION).tar*  2>/dev/null
61         @make changelog
62         @git archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD > $(NAME)-$(VERSION).tar
63         @mkdir $(NAME)-$(VERSION)
64         @cp ChangeLog $(NAME)-$(VERSION)/
65         @tar --append -f $(NAME)-$(VERSION).tar $(NAME)-$(VERSION)
66         @bzip2 -f $(NAME)-$(VERSION).tar
67         @rm -rf $(NAME)-$(VERSION)
68         @echo ""
69         @echo "The final archive is in $(NAME)-$(VERSION).tar.bz2"
70
71 archive: check clean commit tag create-archive
72
73 upload:
74         @scp ${NAME}-$(VERSION).tar.bz2 fedorahosted.org:$(NAME)
75
76 dummy:
77
78 srpm-x: create-archive
79         @echo Creating $(NAME) src.rpm
80         @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
81         @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
82
83 clean:
84         @rm -f $(NAME)-*.gz $(NAME)-*.src.rpm new-pnp.xlsx pnp.ids.txt
85
86 clog: hwdata.spec
87         @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
88
89 download: new-usb-ids new-pci-ids new-oui.txt new-pnp-ids
90
91 new-usb-ids:
92         @curl -O http://www.linux-usb.org/usb.ids
93
94 new-pci-ids:
95         @curl -O http://pciids.sourceforge.net/pci.ids
96
97 new-oui.txt:
98         @curl -O http://standards.ieee.org/develop/regauth/oui/oui.txt
99
100 new-pnp-ids: pnp.ids
101
102 pnp.ids: pnp.ids.txt pnp.ids.patch
103         patch -o $@ <pnp.ids.patch
104
105 pnp.ids.txt: new-pnp.xlsx
106         @unoconv --stdout -f csv $? | \
107             tr ' ' ' ' | \
108             sed -n \
109                 -e 's/^\s*"\s*\(.*\)\s*"/\1/' \
110                 -e 's/\s\{2,\}/ /g' \
111                 -e 's/\s*(used as 2nd pnpid)\s*//' \
112                 -e 's:^\(.*\)\s*,\s*\([a-zA-Z@]\{3\}\)\s*,\s*\([0-9]\+/[0-9]\+/[0-9]\+\):\2\t\1:p' | \
113             sed 's/\s*$$//' | sort -u >$@
114
115 new-pnp.xlsx:
116         @curl -o $@ \
117             http://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/ISA_PNPID_List.xlsx