Makefile 4.2 KB

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