4a68acc075e4180042380e7dbbc70d52a9ae4147
[oweals/hwdata.git] / Makefile
1 NAME=$(shell awk '/Name:/ { print $$2 }' hwdata.spec)
2 VERSION=$(shell awk '/Version:/ { print $$2 }' hwdata.spec)
3 RELEASE=$(shell rpm -q --specfile --qf "%{release}" hwdata.spec)
4 SOURCEDIR := $(shell pwd)
5
6 prefix=$(DESTDIR)/usr
7 sysconfdir=$(DESTDIR)/etc
8 bindir=$(prefix)/bin
9 sbindir=$(prefix)/sbin
10 datadir=$(prefix)/share
11 mandir=$(datadir)/man
12 includedir=$(prefix)/include
13 libdir=$(prefix)/lib
14
15 CC=gcc
16 CFLAGS=$(RPM_OPT_FLAGS) -g
17
18 CVSROOT = $(shell cat CVS/Root 2>/dev/null || :)
19
20 CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
21
22 FILES = MonitorsDB pci.ids upgradelist usb.ids videodrivers oui.txt pnp.ids
23
24 .PHONY: all install tag force-tag check commit create-archive archive srpm-x clean clog new-pci-ids new-usb-ids
25
26 all: 
27
28 install:
29         mkdir -p -m 755 $(datadir)/$(NAME)
30         for foo in $(FILES) ; do \
31                 install -m 644 $$foo $(datadir)/$(NAME) ;\
32         done
33         mkdir -p -m 755 $(datadir)/$(NAME)/videoaliases
34         mkdir -p -m 755 $(sysconfdir)/modprobe.d
35         install -m 644 blacklist.conf $(sysconfdir)/modprobe.d
36
37 commit:
38         git commit -a ||:
39
40 tag:
41         @git tag -a -m "Tag as $(NAME)-$(VERSION)-$(RELEASE)" $(NAME)-$(VERSION)-$(RELEASE)
42         @echo "Tagged as $(NAME)-$(VERSION)-$(RELEASE)"
43
44 force-tag:
45         @git tag -f $(NAME)-$(VERSION)-$(RELEASE)
46         @echo "Tag forced as $(NAME)-$(VERSION)-$(RELEASE)"
47
48 changelog:
49         @rm -f ChangeLog
50         @(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)
51
52 check:
53         @[ -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"
54         @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
55         @echo -n "CHECK date of pci.ids: "; grep "Date:" pci.ids | cut -d ' ' -f 5
56         @echo -n "CHECK date of usb.ids: "; grep "Date:" usb.ids | cut -d ' ' -f 6
57         @: videodrivers is tab-separated
58         @[ `grep -vc '  ' videodrivers` -eq 0 ] || { echo "FAILURE: videodrivers not TAB separated"; exit 1; } && echo "OK: videodrivers"
59
60 create-archive:
61         @rm -rf $(NAME)-$(VERSION) $(NAME)-$(VERSION)-$(RELEASE).tar*  2>/dev/null
62         @make changelog
63         @git archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD > $(NAME)-$(VERSION)-$(RELEASE).tar
64         @mkdir $(NAME)-$(VERSION)
65         @cp ChangeLog $(NAME)-$(VERSION)/
66         @tar --append -f $(NAME)-$(VERSION)-$(RELEASE).tar $(NAME)-$(VERSION)
67         @bzip2 -f $(NAME)-$(VERSION)-$(RELEASE).tar
68         @rm -rf $(NAME)-$(VERSION)
69         @echo ""
70         @echo "The final archive is in $(NAME)-$(VERSION)-$(RELEASE).tar.bz2"
71
72 archive: check clean commit tag create-archive
73
74 upload:
75         @scp ${NAME}-$(VERSION)-$(RELEASE).tar.bz2 fedorahosted.org:$(NAME)
76
77 dummy:
78
79 srpm-x: create-archive
80         @echo Creating $(NAME) src.rpm
81         @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
82         @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
83
84 clean:
85         @rm -f $(NAME)-*.gz $(NAME)-*.src.rpm
86
87 clog: hwdata.spec
88         @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
89
90 download: new-usb-ids new-pci-ids new-oui.txt
91
92 new-usb-ids:
93         @curl -O http://www.linux-usb.org/usb.ids
94
95 new-pci-ids:
96         @curl -O http://pciids.sourceforge.net/pci.ids
97
98 new-oui.txt:
99         @curl -O http://standards.ieee.org/develop/regauth/oui/oui.txt