Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # Install prefix
  2. PREFIX ?= /usr
  3. CRDA_PATH ?= $(PREFIX)/lib/crda
  4. CRDA_KEY_PATH ?= $(CRDA_PATH)/pubkeys
  5. FIRMWARE_PATH ?= /lib/firmware
  6. MANDIR ?= $(PREFIX)/share/man/
  7. SHA1SUM ?= /usr/bin/sha1sum
  8. LSB_RELEASE ?= /usr/bin/lsb_release
  9. WHOAMI ?= /usr/bin/whoami
  10. # Distro name: Ubuntu, Debian, Fedora, if not present you get
  11. # "custom-distro", if your distribution does not have the LSB stuff,
  12. # then set this variable when calling make if you don't want "custom-distro"
  13. LSB_ID ?= $(shell if [ -f $(LSB_RELEASE) ]; then \
  14. $(LSB_RELEASE) -i -s; \
  15. else \
  16. echo custom-distro; \
  17. fi)
  18. DISTRO_PRIVKEY ?= ~/.wireless-regdb-$(LSB_ID).key.priv.pem
  19. DISTRO_PUBKEY ?= ~/.wireless-regdb-$(LSB_ID).key.priv.pem
  20. REGDB_AUTHOR ?= $(shell if [ -f $(DISTRO_PRIVKEY) ]; then \
  21. echo $(LSB_ID) ; \
  22. elif [ -f $(WHOAMI) ]; then \
  23. $(WHOAMI); \
  24. else \
  25. echo custom-user; \
  26. fi)
  27. REGDB_PRIVKEY ?= ~/.wireless-regdb-$(REGDB_AUTHOR).key.priv.pem
  28. REGDB_PUBKEY ?= $(REGDB_AUTHOR).key.pub.pem
  29. REGDB_PUBCERT ?= $(REGDB_AUTHOR).x509.pem
  30. REGDB_UPSTREAM_PUBKEY ?= sforshee.key.pub.pem
  31. REGDB_CHANGED = $(shell $(SHA1SUM) -c --status sha1sum.txt >/dev/null 2>&1; \
  32. if [ $$? -ne 0 ]; then \
  33. echo maintainer-clean $(REGDB_PUBKEY) $(REGDB_PUBCERT); \
  34. fi)
  35. .PHONY: all clean mrproper install maintainer-clean install-distro-key
  36. all: $(REGDB_CHANGED) regulatory.bin sha1sum.txt regulatory.db.p7s
  37. clean:
  38. @rm -f *.pyc *.gz
  39. maintainer-clean: clean
  40. @rm -f regulatory.bin regulatory.db regulatory.db.p7s
  41. mrproper: clean maintainer-clean
  42. @echo Removed public key, regulatory.bin, regulatory.db* and compressed man pages
  43. @rm -f $(REGDB_PUBKEY) $(REGDB_PUBCERT) .custom
  44. regulatory.bin: db.txt $(REGDB_PRIVKEY) $(REGDB_PUBKEY)
  45. @echo Generating $@ digitally signed by $(REGDB_AUTHOR)...
  46. ./db2bin.py regulatory.bin db.txt $(REGDB_PRIVKEY)
  47. regulatory.db: db.txt db2fw.py
  48. @echo "Generating $@"
  49. ./db2fw.py regulatory.db db.txt
  50. regulatory.db.p7s: regulatory.db $(REGDB_PRIVKEY) $(REGDB_PUBCERT)
  51. @echo "Signing regulatory.db (by $(REGDB_AUTHOR))..."
  52. @openssl smime -sign \
  53. -signer $(REGDB_PUBCERT) \
  54. -inkey $(REGDB_PRIVKEY) \
  55. -in $< -nosmimecap -binary \
  56. -outform DER -out $@
  57. sha1sum.txt: db.txt
  58. sha1sum $< > $@
  59. $(REGDB_PUBKEY): $(REGDB_PRIVKEY)
  60. @echo "Generating public key for $(REGDB_AUTHOR)..."
  61. openssl rsa -in $(REGDB_PRIVKEY) -out $(REGDB_PUBKEY) -pubout -outform PEM
  62. $(REGDB_PUBCERT): $(REGDB_PRIVKEY)
  63. @echo "Generating certificate for $(REGDB_AUTHOR)..."
  64. ./gen-pubcert.sh $(REGDB_PRIVKEY) $(REGDB_PUBCERT)
  65. @echo $(REGDB_PUBKEY) > .custom
  66. $(REGDB_PRIVKEY):
  67. @echo "Generating private key for $(REGDB_AUTHOR)..."
  68. openssl genrsa -out $(REGDB_PRIVKEY) 2048
  69. ifneq ($(shell test -e $(DISTRO_PRIVKEY) && echo yes),yes)
  70. $(DISTRO_PRIVKEY):
  71. @echo "Generating private key for $(LSB_ID) packager..."
  72. openssl genrsa -out $(DISTRO_PRIVKEY) 2048
  73. endif
  74. install-distro-key: maintainer-clean $(DISTRO_PRIVKEY)
  75. %.gz: %
  76. gzip < $< > $@
  77. # Users should just do:
  78. # sudo make install
  79. #
  80. # Developers should do:
  81. # make maintainer-clean
  82. # make
  83. # sudo make install
  84. #
  85. # Distributions packagers should do only once:
  86. # make install-distro-key
  87. # This will create a private key for you and install it into
  88. # ~/.wireless-regdb-$(LSB_ID).key.priv.pem
  89. # To make new releaes just do:
  90. # make maintainer-clean
  91. # make
  92. # sudo make install
  93. install: regulatory.bin.5.gz regulatory.db.5.gz
  94. install -m 755 -d $(DESTDIR)/$(CRDA_PATH)
  95. install -m 755 -d $(DESTDIR)/$(CRDA_KEY_PATH)
  96. install -m 755 -d $(DESTDIR)/$(FIRMWARE_PATH)
  97. if [ -f .custom ]; then \
  98. install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(shell cat .custom); \
  99. fi
  100. install -m 644 -t $(DESTDIR)/$(CRDA_KEY_PATH)/ $(REGDB_UPSTREAM_PUBKEY)
  101. install -m 644 -t $(DESTDIR)/$(CRDA_PATH)/ regulatory.bin
  102. install -m 644 -t $(DESTDIR)/$(FIRMWARE_PATH) regulatory.db regulatory.db.p7s
  103. install -m 755 -d $(DESTDIR)/$(MANDIR)/man5/
  104. install -m 644 -t $(DESTDIR)/$(MANDIR)/man5/ regulatory.bin.5.gz regulatory.db.5.gz