Debian Codegraph @

Makefile

raw
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 2>/dev/null | sed -n 's/^\([^0-9-]\+\).*/\L\1/p'), rhel)
5 # add revision to tag name for rhel branches
6 TAGNAME := v$(VERSION)-$(RELEASE)
7 else
8 TAGNAME := v$(VERSION)
9 endif
10 SOURCEDIR := $(shell pwd)
11 ARCHIVE := $(TAGNAME).tar.gz
12
13 CVSROOT = $(shell cat CVS/Root 2>/dev/null || :)
14
15 CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
16
17 IDFILES = 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 download
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 hwdata.pc: hwdata.pc.in
32 datadir="$(datadir)"; \
33 if [ "$${datadir#$(prefix)}" != "$$datadir" ]; then \
34 datadir="\$${prefix}$${datadir#$(prefix)}"; \
35 fi; \
36 sed -e 's|@prefix@|$(prefix)|g' \
37 -e "s|@datadir@|$$datadir|g" \
38 -e 's|@pkgdatadir@|$${datadir}/$(NAME)|g' \
39 -e 's|@VERSION@|$(VERSION)|g' \
40 -e 's|@NAME@|$(NAME)|g' \
41 $< > $@
42
43 install: Makefile.inc hwdata.pc
44 mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME)
45 for foo in $(IDFILES) ; do \
46 install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\
47 done
48 @if [ "$(blacklist)" = true ]; then \
49 mkdir -p -m 755 $(DESTDIR)$(libdir)/modprobe.d ;\
50 install -m 644 -T blacklist.conf $(DESTDIR)$(libdir)/modprobe.d/dist-blacklist.conf ;\
51 fi;
52 mkdir -p -m 755 $(DESTDIR)$(datadir)/pkgconfig
53 install -m 644 hwdata.pc $(DESTDIR)$(datadir)/pkgconfig/
54
55 commit:
56 git commit -vas ||:
57
58 tag:
59 @git tag -s -m "Tag as $(TAGNAME)" $(TAGNAME)
60 @echo "Tagged as $(TAGNAME)"
61
62 force-tag:
63 @git tag -s -f -m "Tag as $(TAGNAME)" $(TAGNAME)
64 @echo "Tag forced as $(TAGNAME)"
65
66 changelog:
67 @rm -f ChangeLog
68 @(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)
69
70 check:
71 @lspci -A dump -O dump.name=lspci-dump.txt -i pci.ids > /dev/null || \
72 { echo "FAILURE: lspci -A dump -O dump.name=lspci-dump.txt -i pci.ids"; exit 1; } && echo "OK: lspci -A dump -O dump.name=lspci-dump.txt -i pci.ids"
73 @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
74 @./check-usb-ids.sh
75 @for file in $(IDFILES); do \
76 iconv -f UTF-8 "$$file" >/dev/null || { echo "FAILURE: $$file is not valid UTF-8 data"; exit 1; }; \
77 echo "OK: $$file is valid UTF-8 data"; \
78 done
79 @echo -n "CHECK date of pci.ids: "; grep "Date:" pci.ids | cut -d ' ' -f 5
80 @echo -n "CHECK date of usb.ids: "; grep "Date:" usb.ids | cut -d ' ' -f 6
81
82 create-archive:
83 @rm -rf $(TAGNAME) $(TAGNAME).tar* 2>/dev/null
84 @make changelog
85 @git archive --format=tar --prefix=hwdata-$(VERSION)/ HEAD > $(TAGNAME).tar
86 @mkdir hwdata-$(VERSION)
87 @cp ChangeLog hwdata-$(VERSION)/
88 @tar --append -f $(TAGNAME).tar hwdata-$(VERSION)
89 @gzip -f $(TAGNAME).tar
90 @rm -rf hwdata-$(VERSION)
91 @echo ""
92 @echo "The final archive is in $(ARCHIVE)"
93
94 archive: check clean commit tag
95
96 upload:
97 @scp $(ARCHIVE) fedorahosted.org:$(NAME)
98
99 srpm-x: create-archive
100 @echo Creating $(NAME) src.rpm
101 @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
102 @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
103
104 clean:
105 @rm -f $(TAGNAME)*.gz $(NAME)-*.src.rpm pnp.ids.csv \
106 *.downloaded *.utf8 *.orig *.converted hwdata.pc ChangeLog clog
107
108 clog: hwdata.spec
109 @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
110
111 download: $(IDFILES)
112
113 usb.ids.downloaded:
114 @curl -o $@ http://www.linux-usb.org/usb.ids
115
116 pci.ids.downloaded:
117 @curl -o $@ https://pci-ids.ucw.cz/v2.2/pci.ids
118
119 oui.txt.downloaded:
120 @curl -o $@ -O https://standards-oui.ieee.org/oui/oui.txt
121
122 iab.txt.downloaded:
123 @curl -o $@ -O https://standards-oui.ieee.org/iab/iab.txt
124
125 pnp.ids.csv:
126 @curl -o $@ \
127 https://uefi.org/uefi-pnp-export
128
129 usb.ids.converted: usb.ids.utf8
130 dos2unix -n $? $@
131
132 usb.ids: usb.ids.converted 01-utf-8-encoding.patch.patch 02-typos.patch.patch
133 patch -p1 -o $@ usb.ids.converted 01-utf-8-encoding.patch.patch
134 patch -p0 -b <02-typos.patch.patch
135
136 pci.ids: pci.ids.utf8
137 dos2unix -n $? $@
138
139 oui.txt: oui.txt.utf8
140 dos2unix -n $? $@
141
142 iab.txt: iab.txt.utf8
143 dos2unix -n $? $@
144
145 pnp.ids.orig: pnp.ids.csv
146 ./process-pnp-ids.py $? $@
147
148 pnp.ids: pnp.ids.orig pnp.ids.patch
149 patch -p1 -o - pnp.ids.orig pnp.ids.patch | \
150 sed 's/\tDO NOT USE - /\tInvalid Vendor Codename - /' >$@
151
152 %.utf8: %.downloaded
153 @text=`LANG=C file $?`
154 @encoding=`echo "$$text" | sed -n 's/.*\(iso-8859\S\*\|cp1[12]\d\+\).*/\1/Ip'`
155 @if [ -n "$$encoding" ]; then \
156 iconv -f "$$encoding" -t UTF-8 $?; \
157 else \
158 cat $?; \
159 fi | sed 's/\s\+$$//' >$@
160