You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. PWD = $(shell pwd)
  2. OPENSSL_LIB_VERSION = 1.0.0
  3. OPENSSL_VERSION = 1.0.2g
  4. OPENSSL_NAME = openssl-$(OPENSSL_VERSION)
  5. OPENSSL_DIR = build/$(OPENSSL_NAME)
  6. RUBY_MAJOR_VERSION = 2.3
  7. RUBY_VERSION = $(RUBY_MAJOR_VERSION).3
  8. RUBY_NAME = ruby-$(RUBY_VERSION)
  9. RUBY_DIR = build/$(RUBY_NAME)
  10. RUBY_OPENSSL_EXT_DIR = $(RUBY_DIR)/ext/openssl
  11. RUBY_LIB_DIR = $(RBENV_ROOT)/versions/$(RUBY_VERSION)-cryptcheck/lib/ruby/$(RUBY_MAJOR_VERSION).0
  12. RBENV_ROOT ?= ~/.rbenv
  13. export LIBRARY_PATH = $(PWD)/lib
  14. export C_INCLUDE_PATH = $(PWD)/$(OPENSSL_DIR)/include
  15. export LD_LIBRARY_PATH = $(PWD)/lib
  16. .SECONDARY:
  17. all: libs ext
  18. clean: clean-libs clean-ext
  19. clean-libs:
  20. [ -d $(OPENSSL_DIR) ] \
  21. && find $(OPENSSL_DIR) \( -name "*.o" -o -name "*.so" \) -delete \
  22. || true
  23. rm -f lib/libcrypto.so* lib/libssl.so* $(OPENSSL_DIR)/Makefile
  24. clean-ext:
  25. [ -d $(RUBY_OPENSSL_EXT_DIR) ] \
  26. && find $(RUBY_OPENSSL_EXT_DIR) \( -name "*.o" -o -name "*.so" \) -delete \
  27. || true
  28. rm -f lib/openssl.so
  29. mr-proper:
  30. rm -rf lib/libcrypto.so* lib/libssl.so* lib/openssl.so build
  31. build/:
  32. mkdir $@
  33. build/chacha-poly.patch: | build/
  34. wget https://github.com/cloudflare/sslconfig/raw/master/patches/openssl__chacha20_poly1305_draft_and_rfc_ossl102g.patch -O $@
  35. build/$(OPENSSL_NAME).tar.gz: | build/
  36. wget https://www.openssl.org/source/$(OPENSSL_NAME).tar.gz -O $@
  37. $(OPENSSL_DIR)/: build/$(OPENSSL_NAME).tar.gz build/chacha-poly.patch
  38. tar -C build -xf build/$(OPENSSL_NAME).tar.gz
  39. #patch -d $(OPENSSL_DIR) -p1 < build/chacha-poly.patch
  40. $(OPENSSL_DIR)/Makefile: | $(OPENSSL_DIR)/
  41. #cd $(OPENSSL_DIR) && ./Configure enable-ssl2 enable-ssl3 enable-weak-ssl-ciphers enable-zlib enable-rc5 enable-rc2 enable-gost enable-md2 enable-mdc2 enable-shared linux-x86_64
  42. #cd $(OPENSSL_DIR) && ./config enable-ssl2 enable-ssl3 enable-md2 enable-rc5 enable-weak-ssl-ciphers shared
  43. cd $(OPENSSL_DIR) && ./config enable-ssl2 enable-ssl3 enable-ssl3-method enable-md2 enable-rc5 enable-weak-ssl-ciphers enable-shared
  44. $(OPENSSL_DIR)/libssl.so \
  45. $(OPENSSL_DIR)/libcrypto.so: $(OPENSSL_DIR)/Makefile
  46. $(MAKE) -C $(OPENSSL_DIR)
  47. LIBS = lib/libssl.so lib/libcrypto.so lib/libssl.so.$(OPENSSL_LIB_VERSION) lib/libcrypto.so.$(OPENSSL_LIB_VERSION)
  48. lib/%.so: $(OPENSSL_DIR)/%.so
  49. cp $< $@
  50. lib/%.so.$(OPENSSL_LIB_VERSION): lib/%.so
  51. ln -fs $(notdir $(subst .$(OPENSSL_LIB_VERSION),,$@)) $@
  52. libs: $(LIBS)
  53. build/$(RUBY_VERSION)-cryptcheck: $(RBENV_ROOT)/plugins/ruby-build/share/ruby-build/$(RUBY_VERSION)
  54. cp $< $@
  55. install-ruby: build/$(RUBY_VERSION)-cryptcheck $(LIBS) | $(OPENSSL_DIR)/
  56. cat tmp_key.patch set_ecdh_curves.patch fallback_scsv.patch | \
  57. RUBY_BUILD_CACHE_PATH=$(PWD)/build \
  58. RUBY_BUILD_DEFINITIONS=$(PWD)/build \
  59. rbenv install -fp $(RUBY_VERSION)-cryptcheck
  60. rbenv sequester $(RUBY_VERSION)-cryptcheck
  61. rbenv local $(RUBY_VERSION)-cryptcheck
  62. gem install bundler
  63. bundle
  64. $(RUBY_LIB_DIR)/openssl/ssl.rb: $(RUBY_OPENSSL_EXT_DIR)/lib/openssl/ssl.rb
  65. cp $< $@
  66. $(RUBY_LIB_DIR)/x86_64-linux/openssl.so: $(RUBY_OPENSSL_EXT_DIR)/openssl.so
  67. cp $< $@
  68. sync-ruby: $(RUBY_LIB_DIR)/openssl/ssl.rb $(RUBY_LIB_DIR)/x86_64-linux/openssl.so
  69. build/$(RUBY_NAME).tar.xz: | build/
  70. wget http://cache.ruby-lang.org/pub/ruby/$(RUBY_MAJOR_VERSION)/$(RUBY_NAME).tar.xz -O $@
  71. $(RUBY_DIR)/: build/$(RUBY_NAME).tar.xz
  72. tar -C build -xf $<
  73. $(RUBY_OPENSSL_EXT_DIR)/Makefile: libs | $(RUBY_DIR)/
  74. patch -d $(RUBY_DIR)/ -p1 < tmp_key.patch
  75. patch -d $(RUBY_DIR)/ -p1 < set_ecdh_curves.patch
  76. patch -d $(RUBY_DIR)/ -p1 < fallback_scsv.patch
  77. cd $(RUBY_OPENSSL_EXT_DIR) && ruby extconf.rb
  78. $(RUBY_OPENSSL_EXT_DIR)/openssl.so: $(LIBS) $(RUBY_OPENSSL_EXT_DIR)/Makefile
  79. top_srcdir=../.. $(MAKE) -C $(RUBY_OPENSSL_EXT_DIR)
  80. lib/openssl.so: $(RUBY_OPENSSL_EXT_DIR)/openssl.so
  81. cp $< $@
  82. ext: lib/openssl.so