more dist fixes
[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 awk '/Release:/ { a=$$2; sub("%.*","",a); print a }' hwdata.spec)
4 RELVER=$(shell awk '/define relver/ { print $3 }' hwdata.spec)
5 SOURCEDIR := $(shell pwd)
6
7 prefix=$(DESTDIR)/usr
8 sysconfdir=$(DESTDIR)/etc
9 bindir=$(prefix)/bin
10 sbindir=$(prefix)/sbin
11 datadir=$(prefix)/share
12 mandir=$(datadir)/man
13 includedir=$(prefix)/include
14 libdir=$(prefix)/lib
15
16 CC=gcc
17 CFLAGS=$(RPM_OPT_FLAGS) -g
18
19 CVSROOT = $(shell cat CVS/Root 2>/dev/null || :)
20
21 CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
22
23 FILES = MonitorsDB pci.ids upgradelist usb.ids videodrivers oui.txt pnp.ids
24
25 .PHONY: all install tag force-tag check commit create-archive archive srpm-x clean clog new-pci-ids new-usb-ids
26
27 all: 
28
29 install:
30         mkdir -p -m 755 $(datadir)/$(NAME)
31         for foo in $(FILES) ; do \
32                 install -m 644 $$foo $(datadir)/$(NAME) ;\
33         done
34         mkdir -p -m 755 $(datadir)/$(NAME)/videoaliases
35         mkdir -p -m 755 $(sysconfdir)/modprobe.d
36         install -m 644 blacklist.conf $(sysconfdir)/modprobe.d
37
38 commit:
39         git commit -a ||:
40
41 tag:
42         @git tag -a -m "Tag as $(NAME)-$(VERSION)-$(RELEASE)" $(NAME)-$(VERSION)-$(RELEASE)
43         @echo "Tagged as $(NAME)-$(VERSION)-$(RELEASE)"
44
45 force-tag:
46         @git tag -f $(NAME)-$(VERSION)-$(RELEASE)
47         @echo "Tag forced as $(NAME)-$(VERSION)-$(RELEASE)"
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         @: videodrivers is tab-separated
57         @[ `grep -vc '  ' videodrivers` -eq 0 ] || { echo "FAILURE: videodrivers not TAB separated"; exit 1; } && echo "OK: videodrivers"
58
59 create-archive:
60         @rm -rf $(NAME)-$(VERSION) $(NAME)-$(VERSION)-$(RELVER).tar*  2>/dev/null
61         @make changelog
62         @git archive --format=tar --prefix=$(NAME)-$(VERSION)/ HEAD > $(NAME)-$(VERSION)-$(RELVER).tar
63         @mkdir $(NAME)-$(VERSION)
64         @cp ChangeLog $(NAME)-$(VERSION)/
65         @tar --append -f $(NAME)-$(VERSION)-$(RELVER).tar $(NAME)-$(VERSION)
66         @bzip2 -f $(NAME)-$(VERSION)-$(RELVER).tar
67         @rm -rf $(NAME)-$(VERSION)
68         @echo ""
69         @echo "The final archive is in $(NAME)-$(VERSION)-$(RELVER).tar.bz2"
70
71 archive: check clean commit tag create-archive
72
73 upload:
74         @scp ${NAME}-$(VERSION)-$(RELVER).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
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
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