Makefile 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 -A dump -O dump.name=lspci-dump.txt -i pci.ids > /dev/null || \
  60. { 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"
  61. @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
  62. @./check-usb-ids.sh
  63. @for file in $(UTF_IDFILES); do \
  64. iconv -f UTF-8 "$$file" >/dev/null || { echo "FAILURE: $$file is not valid UTF-8 data"; exit 1; }; \
  65. echo "OK: $$file is valid UTF-8 data"; \
  66. done
  67. @echo -n "CHECK date of pci.ids: "; grep "Date:" pci.ids | cut -d ' ' -f 5
  68. @echo -n "CHECK date of usb.ids: "; grep "Date:" usb.ids | cut -d ' ' -f 6
  69. create-archive:
  70. @rm -rf $(TAGNAME) $(TAGNAME).tar* 2>/dev/null
  71. @make changelog
  72. @git archive --format=tar --prefix=hwdata-$(VERSION)/ HEAD > $(TAGNAME).tar
  73. @mkdir hwdata-$(VERSION)
  74. @cp ChangeLog hwdata-$(VERSION)/
  75. @tar --append -f $(TAGNAME).tar hwdata-$(VERSION)
  76. @gzip -f $(TAGNAME).tar
  77. @rm -rf hwdata-$(VERSION)
  78. @echo ""
  79. @echo "The final archive is in $(ARCHIVE)"
  80. archive: check clean commit tag
  81. upload:
  82. @scp $(ARCHIVE) fedorahosted.org:$(NAME)
  83. srpm-x: create-archive
  84. @echo Creating $(NAME) src.rpm
  85. @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
  86. @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
  87. clean:
  88. @rm -f $(TAGNAME)*.gz $(NAME)-*.src.rpm pnp.ids.csv \
  89. *.downloaded *.utf8 *.orig hwdata.pc ChangeLog clog
  90. clog: hwdata.spec
  91. @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
  92. download: $(IDFILES)
  93. usb.ids.downloaded:
  94. @curl -o $@ http://www.linux-usb.org/usb.ids
  95. pci.ids.downloaded:
  96. @curl -o $@ https://pci-ids.ucw.cz/v2.2/pci.ids
  97. oui.txt.downloaded:
  98. @curl -o $@ -O https://standards-oui.ieee.org/oui/oui.txt
  99. iab.txt.downloaded:
  100. @curl -o $@ -O https://standards-oui.ieee.org/iab/iab.txt
  101. pnp.ids.csv:
  102. @curl -o $@ \
  103. https://uefi.org/uefi-pnp-export
  104. usb.ids: usb.ids.utf8
  105. dos2unix -n $? $@
  106. pci.ids: pci.ids.utf8
  107. dos2unix -n $? $@
  108. oui.txt: oui.txt.utf8
  109. dos2unix -n $? $@
  110. iab.txt: iab.txt.utf8
  111. dos2unix -n $? $@
  112. pnp.ids.orig: pnp.ids.csv
  113. ./process-pnp-ids.py $? $@
  114. pnp.ids: pnp.ids.orig pnp.ids.patch
  115. patch -p1 -o $@ pnp.ids.orig pnp.ids.patch
  116. %.utf8: %.downloaded
  117. @text=`LANG=C file $?`
  118. @encoding=`echo "$$text" | sed -n 's/.*\(iso-8859\S\*\|cp1[12]\d\+\).*/\1/Ip'`
  119. @if [ -n "$$encoding" ]; then \
  120. iconv -f "$$encoding" -t UTF-8 $?; \
  121. else \
  122. cat $?; \
  123. fi | sed 's/\s\+$$//' >$@