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.

82 lines
2.6KB

  1. PWD = $(shell pwd)
  2. export CPATH = $(PWD)/openssl/include
  3. export LIBRARY_PATH = $(PWD)/openssl
  4. OPENSSL_LIB_VERSION = 1.0.0
  5. OPENSSL_VERSION = 1.0.2g
  6. #OPENSSL_LIB_VERSION = 1.1
  7. #OPENSSL_VERSION = 1.1.0-pre5
  8. OPENSSL_NAME = openssl-$(OPENSSL_VERSION)
  9. OPENSSL_DIR = build/$(OPENSSL_NAME)
  10. #OPENSSL_DIR = openssl
  11. RUBY_MAJOR_VERSION = 2.3
  12. RUBY_VERSION = $(RUBY_MAJOR_VERSION).1
  13. RUBY_NAME = ruby-$(RUBY_VERSION)
  14. RUBY_DIR = build/$(RUBY_NAME)
  15. RUBY_OPENSSL_EXT_DIR = $(RUBY_DIR)/ext/openssl
  16. export LIBRARY_PATH = $(PWD)/lib
  17. export C_INCLUDE_PATH = $(PWD)/$(OPENSSL_DIR)/include
  18. .SECONDARY:
  19. all: libs ext
  20. clean: clean-libs clean-ext
  21. clean-libs:
  22. [ -d $(OPENSSL_DIR) ] \
  23. && find $(OPENSSL_DIR) \( -name "*.o" -o -name "*.so" \) -delete \
  24. || true
  25. rm -f lib/libcrypto.so* lib/libssl.so* $(OPENSSL_DIR)/Makefile
  26. clean-ext:
  27. [ -d $(RUBY_OPENSSL_EXT_DIR) ] \
  28. && find $(RUBY_OPENSSL_EXT_DIR) \( -name "*.o" -o -name "*.so" \) -delete \
  29. || true
  30. rm -f lib/openssl.so
  31. mr-proper:
  32. rm -rf lib/libcrypto.so* lib/libssl.so* lib/openssl.so build
  33. build/:
  34. mkdir $@
  35. build/chacha-poly.patch: | build/
  36. wget https://github.com/cloudflare/sslconfig/raw/master/patches/openssl__chacha20_poly1305_draft_and_rfc_ossl102g.patch -O $@
  37. build/$(OPENSSL_NAME).tar.gz: | build/
  38. wget https://www.openssl.org/source/$(OPENSSL_NAME).tar.gz -O $@
  39. $(OPENSSL_DIR)/: build/$(OPENSSL_NAME).tar.gz build/chacha-poly.patch
  40. tar -C build -xf build/$(OPENSSL_NAME).tar.gz
  41. patch -d $(OPENSSL_DIR) -p1 < build/chacha-poly.patch
  42. $(OPENSSL_DIR)/Makefile: | $(OPENSSL_DIR)/
  43. cd $(OPENSSL_DIR) && ./Configure enable-ssl2 enable-ssl3 enable-weak-ssl-ciphers enable-shared linux-x86_64
  44. $(OPENSSL_DIR)/libssl.so \
  45. $(OPENSSL_DIR)/libcrypto.so: $(OPENSSL_DIR)/Makefile
  46. $(MAKE) -C $(OPENSSL_DIR)
  47. lib/%.so: $(OPENSSL_DIR)/%.so
  48. cp $< $@
  49. lib/%.so.$(OPENSSL_LIB_VERSION): lib/%.so
  50. ln -fs $(notdir $(subst .$(OPENSSL_LIB_VERSION),,$@)) $@
  51. libs: lib/libssl.so lib/libcrypto.so lib/libssl.so.$(OPENSSL_LIB_VERSION) lib/libcrypto.so.$(OPENSSL_LIB_VERSION)
  52. build/$(RUBY_NAME).tar.gz: | build/
  53. wget http://cache.ruby-lang.org/pub/ruby/$(RUBY_MAJOR_VERSION)/$(RUBY_NAME).tar.gz -O $@
  54. $(RUBY_DIR)/: build/$(RUBY_NAME).tar.gz
  55. tar -C build -xf $<
  56. $(RUBY_OPENSSL_EXT_DIR)/Makefile: libs | $(RUBY_DIR)/
  57. patch -d $(RUBY_DIR)/ -p1 < tmp_key.patch
  58. patch -d $(RUBY_DIR)/ -p1 < set_ecdh_curves.patch
  59. patch -d $(RUBY_DIR)/ -p1 < fallback_scsv.patch
  60. cd $(RUBY_OPENSSL_EXT_DIR) && ruby extconf.rb
  61. $(RUBY_OPENSSL_EXT_DIR)/openssl.so: libs $(RUBY_OPENSSL_EXT_DIR)/Makefile
  62. top_srcdir=../.. $(MAKE) -C $(RUBY_OPENSSL_EXT_DIR)
  63. lib/openssl.so: $(RUBY_OPENSSL_EXT_DIR)/openssl.so
  64. cp $< $@
  65. ext: lib/openssl.so