Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. CVSROOT = $(shell cat CVS/Root 2>/dev/null || :)
  13. CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
  14. IDFILES = pci.ids usb.ids oui.txt iab.txt pnp.ids
  15. # usb.ids is not in UTF-8
  16. UTF_IDFILES = pci.ids oui.txt iab.txt pnp.ids
  17. .PHONY: all install tag force-tag check commit create-archive archive srpm-x \
  18. clean clog download
  19. include Makefile.inc
  20. all:
  21. Makefile.inc: configure
  22. ./configure
  23. @echo "$@ generated. Run the make again."
  24. @exit 1
  25. hwdata.pc: hwdata.pc.in
  26. datadir="$(datadir)"; \
  27. if [ "$${datadir#$(prefix)}" != "$$datadir" ]; then \
  28. datadir="\$${prefix}$${datadir#$(prefix)}"; \
  29. fi; \
  30. sed -e 's|@prefix@|$(prefix)|g' \
  31. -e "s|@datadir@|$$datadir|g" \
  32. -e 's|@pkgdatadir@|$${datadir}/$(NAME)|g' \
  33. -e 's|@VERSION@|$(VERSION)|g' \
  34. -e 's|@NAME@|$(NAME)|g' \
  35. $< > $@
  36. install: Makefile.inc hwdata.pc
  37. mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME)
  38. for foo in $(IDFILES) ; do \
  39. install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\
  40. done
  41. @if [ "$(blacklist)" = true ]; then \
  42. mkdir -p -m 755 $(DESTDIR)$(libdir)/modprobe.d ;\
  43. install -m 644 -T blacklist.conf $(DESTDIR)$(libdir)/modprobe.d/dist-blacklist.conf ;\
  44. fi;
  45. mkdir -p -m 755 $(DESTDIR)$(datadir)/pkgconfig
  46. install -m 644 hwdata.pc $(DESTDIR)$(datadir)/pkgconfig/
  47. commit:
  48. git commit -vas ||:
  49. tag:
  50. @git tag -s -m "Tag as $(TAGNAME)" $(TAGNAME)
  51. @echo "Tagged as $(TAGNAME)"
  52. force-tag:
  53. @git tag -s -f -m "Tag as $(TAGNAME)" $(TAGNAME)
  54. @echo "Tag forced as $(TAGNAME)"
  55. changelog:
  56. @rm -f ChangeLog
  57. @(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)
  58. check:
  59. @lspci -i pci.ids > /dev/null || { echo "FAILURE: lspci -i pci.ids"; exit 1; } && echo "OK: lspci -i pci.ids"
  60. @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
  61. @./check-usb-ids.sh
  62. @for file in $(UTF_IDFILES); do \
  63. iconv -f UTF-8 "$$file" >/dev/null || { echo "FAILURE: $$file is not valid UTF-8 data"; exit 1; }; \
  64. echo "OK: $$file is valid UTF-8 data"; \
  65. done
  66. @echo -n "CHECK date of pci.ids: "; grep "Date:" pci.ids | cut -d ' ' -f 5
  67. @echo -n "CHECK date of usb.ids: "; grep "Date:" usb.ids | cut -d ' ' -f 6
  68. create-archive:
  69. @rm -rf $(TAGNAME) $(TAGNAME).tar* 2>/dev/null
  70. @make changelog
  71. @git archive --format=tar --prefix=hwdata-$(VERSION)/ HEAD > $(TAGNAME).tar
  72. @mkdir hwdata-$(VERSION)
  73. @cp ChangeLog hwdata-$(VERSION)/
  74. @tar --append -f $(TAGNAME).tar hwdata-$(VERSION)
  75. @gzip -f $(TAGNAME).tar
  76. @rm -rf hwdata-$(VERSION)
  77. @echo ""
  78. @echo "The final archive is in $(ARCHIVE)"
  79. archive: check clean commit tag
  80. upload:
  81. @scp $(ARCHIVE) fedorahosted.org:$(NAME)
  82. srpm-x: create-archive
  83. @echo Creating $(NAME) src.rpm
  84. @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
  85. @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
  86. clean:
  87. @rm -f $(TAGNAME)*.gz $(NAME)-*.src.rpm pnp.ids.xlsx \
  88. *.downloaded *.utf8 *.orig hwdata.pc ChangeLog clog
  89. clog: hwdata.spec
  90. @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
  91. download: $(IDFILES)
  92. usb.ids.downloaded:
  93. @curl -o $@ http://www.linux-usb.org/usb.ids
  94. pci.ids.downloaded:
  95. @curl -o $@ https://pci-ids.ucw.cz/v2.2/pci.ids
  96. oui.txt.downloaded:
  97. @curl -o $@ -O https://standards-oui.ieee.org/oui/oui.txt
  98. iab.txt.downloaded:
  99. @curl -o $@ -O https://standards-oui.ieee.org/iab/iab.txt
  100. pnp.ids.xlsx:
  101. @curl -o $@ \
  102. https://uefi.org/uefi-pnp-export
  103. usb.ids: usb.ids.utf8
  104. dos2unix -n $? $@
  105. pci.ids: pci.ids.utf8
  106. dos2unix -n $? $@
  107. oui.txt: oui.txt.utf8
  108. dos2unix -n $? $@
  109. iab.txt: iab.txt.utf8
  110. dos2unix -n $? $@
  111. pnp.ids.orig: pnp.ids.xlsx
  112. grep "class" $? | \
  113. tr ' ' ' ' | \
  114. sed -n \
  115. -e 's/\s\{2,\}/ /g' \
  116. -e 's/\&amp;/\&/g' \
  117. -e "s/\&#039;/'/g" \
  118. -e 's:^.*<tr class=".*"><td>\(.*\)</td><td>\([a-zA-Z@]\{3\}\).*</td><td>.*$$:\2\t\1:p' | \
  119. sed 's/\s*$$//' | sort -u >$@
  120. pnp.ids: pnp.ids.orig pnp.ids.patch
  121. patch -p1 -o $@ pnp.ids.orig pnp.ids.patch
  122. %.utf8: %.downloaded
  123. @text=`LANG=C file $?`
  124. @encoding=`echo "$$text" | sed -n 's/.*\(iso-8859\S\*\|cp1[12]\d\+\).*/\1/Ip'`
  125. @if [ -n "$$encoding" ]; then \
  126. iconv -f "$$encoding" -t UTF-8 $?; \
  127. else \
  128. cat $?; \
  129. fi | sed 's/\s\+$$//' >$@