Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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/^\([^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.bz2
  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. install: Makefile.inc
  26. mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME)
  27. for foo in $(IDFILES) ; do \
  28. install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\
  29. done
  30. mkdir -p -m 755 $(DESTDIR)$(libdir)/modprobe.d
  31. install -m 644 -T blacklist.conf $(DESTDIR)$(libdir)/modprobe.d/dist-blacklist.conf
  32. commit:
  33. git commit -vas ||:
  34. tag:
  35. @git tag -s -m "Tag as $(TAGNAME)" $(TAGNAME)
  36. @echo "Tagged as $(TAGNAME)"
  37. force-tag:
  38. @git tag -s -f -m "Tag as $(TAGNAME)" $(TAGNAME)
  39. @echo "Tag forced as $(TAGNAME)"
  40. changelog:
  41. @rm -f ChangeLog
  42. @(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)
  43. check:
  44. @lspci -i pci.ids > /dev/null || { echo "FAILURE: lspci -i pci.ids"; exit 1; } && echo "OK: lspci -i pci.ids"
  45. @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
  46. @./check-usb-ids.sh
  47. @for file in $(UTF_IDFILES); do \
  48. iconv -f UTF-8 "$$file" >/dev/null || { echo "FAILURE: $$file is not valid UTF-8 data"; exit 1; }; \
  49. echo "OK: $$file is valid UTF-8 data"; \
  50. done
  51. @echo -n "CHECK date of pci.ids: "; grep "Date:" pci.ids | cut -d ' ' -f 5
  52. @echo -n "CHECK date of usb.ids: "; grep "Date:" usb.ids | cut -d ' ' -f 6
  53. create-archive:
  54. @rm -rf $(TAGNAME) $(TAGNAME).tar* 2>/dev/null
  55. @make changelog
  56. @git archive --format=tar --prefix=$(TAGNAME)/ HEAD > $(TAGNAME).tar
  57. @mkdir $(TAGNAME)
  58. @cp ChangeLog $(TAGNAME)/
  59. @tar --append -f $(TAGNAME).tar $(TAGNAME)
  60. @bzip2 -f $(TAGNAME).tar
  61. @rm -rf $(TAGNAME)
  62. @echo ""
  63. @echo "The final archive is in $(ARCHIVE)"
  64. archive: check clean commit tag
  65. upload:
  66. @scp $(ARCHIVE) fedorahosted.org:$(NAME)
  67. srpm-x: create-archive
  68. @echo Creating $(NAME) src.rpm
  69. @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
  70. @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
  71. clean:
  72. @rm -f $(NAME)-*.gz $(NAME)-*.src.rpm pnp.ids.csv \
  73. *.downloaded *.utf8 *.orig
  74. clog: hwdata.spec
  75. @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
  76. download: $(IDFILES)
  77. usb.ids.downloaded:
  78. @curl -o $@ http://www.linux-usb.org/usb.ids
  79. pci.ids.downloaded:
  80. @curl -o $@ https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids
  81. oui.txt.downloaded:
  82. @curl -o $@ -O https://standards-oui.ieee.org/oui/oui.txt
  83. iab.txt.downloaded:
  84. @curl -o $@ -O https://standards-oui.ieee.org/iab/iab.txt
  85. pnp.ids.csv:
  86. @curl -o $@ \
  87. https://uefi.org/uefi-pnp-export
  88. usb.ids: usb.ids.utf8
  89. dos2unix -n $? $@
  90. pci.ids: pci.ids.utf8
  91. dos2unix -n $? $@
  92. oui.txt: oui.txt.utf8
  93. dos2unix -n $? $@
  94. iab.txt: iab.txt.utf8
  95. dos2unix -n $? $@
  96. pnp.ids.orig: pnp.ids.csv
  97. ./process-pnp-ids.py $? $@
  98. pnp.ids: pnp.ids.orig pnp.ids.patch
  99. patch -p1 -o $@ pnp.ids.orig pnp.ids.patch
  100. %.utf8: %.downloaded
  101. @text=`LANG=C file $?`
  102. @encoding=`echo "$$text" | sed -n 's/.*\(iso-8859\S\*\|cp1[12]\d\+\).*/\1/Ip'`
  103. @if [ -n "$$encoding" ]; then \
  104. iconv -f "$$encoding" -t UTF-8 $?; \
  105. else \
  106. cat $?; \
  107. fi | sed 's/\s\+$$//' >$@