2
0

Makefile 4.4 KB

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