Makefile 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. NAME=hwdata
  2. VERSION=$(shell awk '/Version:/ { print $$2 }' hwdata.spec)
  3. RELEASE=$(shell rpm -q --define 'dist %{nil}' --specfile --qf "%{release}\n" hwdata.spec | head -n 1)
  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 := $(NAME)-$(VERSION)
  9. endif
  10. SOURCEDIR := $(shell pwd)
  11. ARCHIVE := $(TAGNAME).tar.bz2
  12. HWDBNUMINCR := 2
  13. CVSROOT = $(shell cat CVS/Root 2>/dev/null || :)
  14. CVSTAG = $(NAME)-r$(subst .,-,$(VERSION))
  15. FILES := pci.ids usb.ids oui.txt iab.txt pnp.ids sdio.ids
  16. HWDBGENERATED := \
  17. 20-OUI.hwdb \
  18. 20-pci-classes.hwdb \
  19. 20-pci-vendor-model.hwdb \
  20. 20-sdio-classes.hwdb \
  21. 20-sdio-vendor-model.hwdb \
  22. 20-usb-classes.hwdb \
  23. 20-usb-vendor-model.hwdb
  24. HWDBUPSTREAM := \
  25. 20-acpi-vendor.hwdb \
  26. 20-bluetooth-vendor-product.hwdb \
  27. 20-net-ifname.hwdb \
  28. 60-evdev.hwdb \
  29. 60-keyboard.hwdb \
  30. 70-mouse.hwdb \
  31. 70-pointingstick.hwdb
  32. HWDBFILES := $(HWDBGENERATED) $(HWDBUPSTREAM)
  33. .PHONY: all install tag force-tag check commit create-archive archive srpm-x \
  34. clean clog \
  35. new-pci-ids \
  36. new-usb-ids \
  37. new-oui \
  38. new-iab \
  39. new-pnp-ids \
  40. new-hwdb-files \
  41. new-sdio-ds \
  42. pnp.ids
  43. include Makefile.inc
  44. all:
  45. Makefile.inc: configure
  46. ./configure
  47. @echo "$@ generated. Run the make again."
  48. @exit 1
  49. install: Makefile.inc
  50. mkdir -p -m 755 $(DESTDIR)$(datadir)/$(NAME)
  51. for foo in $(FILES) ; do \
  52. install -m 644 $$foo $(DESTDIR)$(datadir)/$(NAME) ;\
  53. done
  54. mkdir -p -m 755 $(DESTDIR)$(libdir)/udev/hwdb.d/
  55. perl ./ids-update.pl
  56. for foo in $(HWDBFILES) ; do \
  57. num=`echo $$foo | sed 's,^\(.*/\|\)\([0-9]\+\)-[^/]\+,\2,'`; \
  58. destname=`printf "%02d" $$((num + $(HWDBNUMINCR)))`-`basename $$foo | sed "s/^[0-9]\+-//"`; \
  59. install -m 644 $$foo $(DESTDIR)$(libdir)/udev/hwdb.d/$$destname; \
  60. done
  61. mkdir -p -m 755 $(DESTDIR)$(libdir)/modprobe.d
  62. install -m 644 -T blacklist.conf $(DESTDIR)$(libdir)/modprobe.d/dist-blacklist.conf
  63. commit:
  64. git commit -vas ||:
  65. tag:
  66. @git tag -s -m "Tag as $(TAGNAME)" $(TAGNAME)
  67. @echo "Tagged as $(TAGNAME)"
  68. force-tag:
  69. @git tag -s -f -m "Tag as $(TAGNAME)" $(TAGNAME)
  70. @echo "Tag forced as $(TAGNAME)"
  71. changelog:
  72. @rm -f ChangeLog
  73. @(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)
  74. check:
  75. @[ -x /sbin/lspci ] && /sbin/lspci -i pci.ids > /dev/null || { echo "FAILURE: /sbin/lspci -i pci.ids"; exit 1; } && echo "OK: /sbin/lspci -i pci.ids"
  76. @./check-pci-ids.py || { echo "FAILURE: ./check-pci-ids.py"; exit 1; } && echo "OK: ./check-pci-ids.py"
  77. @./check-usb-ids.sh
  78. @for file in $(IDFILES); do \
  79. text=`LANG=C file $$file`; \
  80. expected="$$file: UTF-8 Unicode text"; \
  81. if [[ "$$text" != "$$expected" ]]; then \
  82. printf "Expected: %s\n Got instead: %s\n" "$$expected" "$$text" >&2; \
  83. exit 1; \
  84. fi; \
  85. echo "OK: $$text"; \
  86. done
  87. @echo -n "CHECK date of pci.ids: "; grep "Date:" pci.ids | cut -d ' ' -f 5
  88. @echo -n "CHECK date of usb.ids: "; grep "Date:" usb.ids | cut -d ' ' -f 6
  89. create-archive:
  90. @rm -rf $(TAGNAME) $(TAGNAME).tar* 2>/dev/null
  91. @make changelog
  92. @git archive --format=tar --prefix=$(TAGNAME)/ HEAD > $(TAGNAME).tar
  93. @mkdir $(TAGNAME)
  94. @cp ChangeLog $(TAGNAME)/
  95. @tar --append -f $(TAGNAME).tar $(TAGNAME)
  96. @bzip2 -f $(TAGNAME).tar
  97. @rm -rf $(TAGNAME)
  98. @echo ""
  99. @echo "The final archive is in $(TAGNAME).tar.bz2"
  100. archive: check clean commit tag
  101. upload:
  102. @scp $(TAGNAME).tar.bz2 fedorahosted.org:$(NAME)
  103. dummy:
  104. srpm-x: create-archive
  105. @echo Creating $(NAME) src.rpm
  106. @rpmbuild --nodeps -bs --define "_sourcedir $(SOURCEDIR)" --define "_srcrpmdir $(SOURCEDIR)" $(NAME).spec
  107. @echo SRPM is: $(NAME)-$(VERSION)-$(RELEASE).src.rpm
  108. clean:
  109. @rm -f $(NAME)-*.gz $(NAME)-*.src.rpm pnp.ids.xlsx \
  110. *.downloaded *.utf8 *.orig
  111. clog: hwdata.spec
  112. @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $< | tee $@
  113. download: $(FILES) new-hwdb-files
  114. usb.ids.downloaded:
  115. @curl -o $@ http://www.linux-usb.org/usb.ids
  116. pci.ids.downloaded:
  117. @curl -o $@ https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids
  118. oui.txt.downloaded:
  119. @curl -o $@ -O http://standards-oui.ieee.org/oui.txt
  120. iab.txt.downloaded:
  121. @curl -o $@ -O http://standards-oui.ieee.org/iab/iab.txt
  122. pnp.ids.xlsx:
  123. @curl -o $@ \
  124. http://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/ISA_PNPID_List.xlsx
  125. sdio.ids.downloaded:
  126. @curl -o $@ https://raw.githubusercontent.com/systemd/systemd/master/hwdb.d/sdio.ids
  127. usb.ids: usb.ids.utf8
  128. dos2unix -n $? $@
  129. pci.ids: pci.ids.utf8
  130. dos2unix -n $? $@
  131. oui.txt: oui.txt.utf8
  132. dos2unix -n $? $@
  133. iab.txt: iab.txt.utf8
  134. dos2unix -n $? $@
  135. sdio.ids: sdio.ids.utf8
  136. dos2unix -n $? $@
  137. pnp.ids.orig: pnp.ids.xlsx
  138. @unoconv --stdout -f csv $? | \
  139. tr ' ' ' ' | \
  140. sed -n \
  141. -e 's/^\s*"\s*\(.*\)\s*"/\1/' \
  142. -e 's/\s\{2,\}/ /g' \
  143. -e 's/\s*(used as 2nd pnpid)\s*//' \
  144. -e 's:^\(.*\)\s*,\s*\([a-zA-Z@]\{3\}\)\s*,\s*\([0-9]\+/[0-9]\+/[0-9]\+\):\2\t\1:p' | \
  145. sed 's/\s*$$//' | sort -u >$@
  146. pnp.ids: pnp.ids.orig pnp.ids.patch
  147. patch -o $@ <pnp.ids.patch
  148. %.utf8: %.downloaded
  149. @text=`LANG=C file $?`
  150. @encoding=`echo "$$text" | sed -n 's/.*\(iso-8859\S\*\|cp1[12]\d\+\).*/\1/Ip'`
  151. @if [[ -n "$$encoding" ]]; then \
  152. iconv -f "$$encoding" -t UTF-8 $?; \
  153. else \
  154. cat $?; \
  155. fi | sed 's/\s\+$$//' >$@
  156. new-hwdb-files:
  157. @for file in $(HWDBUPSTREAM); do \
  158. echo $$file; \
  159. curl -O https://raw.githubusercontent.com/systemd/systemd/master/hwdb.d/$$file; \
  160. done