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 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. RBENV_DIR = $(RBENV_ROOT)/versions/$(RUBY_VERSION)-cryptcheck
  12. RUBY_LIB_DIR = $(RBENV_DIR)/lib/ruby/$(RUBY_MAJOR_VERSION).0
  13. RBENV_ROOT ?= ~/.rbenv
  14. export LIBRARY_PATH ?= $(PWD)/lib
  15. export C_INCLUDE_PATH ?= $(PWD)/$(OPENSSL_DIR)/include
  16. export LD_LIBRARY_PATH ?= $(PWD)/lib
  17. .SECONDARY:
  18. .SUFFIXES:
  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. patch -d $(OPENSSL_DIR) -p1 < disable_digest_check.patch
  43. $(OPENSSL_DIR)/Makefile: | $(OPENSSL_DIR)/
  44. #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
  45. #cd $(OPENSSL_DIR) && ./config enable-ssl2 enable-ssl3 enable-md2 enable-rc5 enable-weak-ssl-ciphers shared
  46. cd $(OPENSSL_DIR) && ./config enable-ssl2 enable-ssl3 enable-ssl3-method enable-md2 enable-rc5 enable-weak-ssl-ciphers enable-shared
  47. $(OPENSSL_DIR)/libssl.so \
  48. $(OPENSSL_DIR)/libcrypto.so: $(OPENSSL_DIR)/Makefile
  49. $(MAKE) -C $(OPENSSL_DIR)
  50. install-openssl: $(OPENSSL_DIR)/Makefile
  51. $(MAKE) -C $(OPENSSL_DIR) install
  52. LIBS = lib/libssl.so lib/libcrypto.so lib/libssl.so.$(OPENSSL_LIB_VERSION) lib/libcrypto.so.$(OPENSSL_LIB_VERSION)
  53. lib/%.so: $(OPENSSL_DIR)/%.so
  54. cp $< $@
  55. lib/%.so.$(OPENSSL_LIB_VERSION): lib/%.so
  56. ln -fs $(notdir $(subst .$(OPENSSL_LIB_VERSION),,$@)) $@
  57. libs: $(LIBS)
  58. $(RBENV_ROOT)/:
  59. git clone https://github.com/rbenv/rbenv/ $@ -b v1.1.1 --depth 1
  60. $(RBENV_ROOT)/plugins/ruby-build/: | $(RBENV_ROOT)/
  61. git clone https://github.com/rbenv/ruby-build/ $@ -b v20171215 --depth 1
  62. $(RBENV_ROOT)/plugins/ruby-build/share/ruby-build/$(RUBY_VERSION): | $(RBENV_ROOT)/plugins/ruby-build/
  63. build/$(RUBY_VERSION)-cryptcheck: $(RBENV_ROOT)/plugins/ruby-build/share/ruby-build/$(RUBY_VERSION)
  64. cp $< $@
  65. install-rbenv: build/$(RUBY_VERSION)-cryptcheck
  66. install-rbenv-cryptcheck: build/$(RUBY_VERSION)-cryptcheck $(LIBS) | $(OPENSSL_DIR)/
  67. cat tmp_key.patch set_ecdh_curves.patch fallback_scsv.patch multiple_certs.patch | \
  68. RUBY_BUILD_CACHE_PATH=$(PWD)/build \
  69. RUBY_BUILD_DEFINITIONS=$(PWD)/build \
  70. rbenv install -fp $(RUBY_VERSION)-cryptcheck
  71. # rbenv sequester $(RUBY_VERSION)-cryptcheck
  72. rbenv local $(RUBY_VERSION)-cryptcheck
  73. gem install bundler
  74. bundle install --without test development
  75. $(RUBY_LIB_DIR)/openssl/ssl.rb: $(RUBY_OPENSSL_EXT_DIR)/lib/openssl/ssl.rb
  76. cp $< $@
  77. $(RUBY_LIB_DIR)/x86_64-linux/openssl.so: $(RUBY_OPENSSL_EXT_DIR)/openssl.so
  78. cp $< $@
  79. sync-ruby: $(RUBY_LIB_DIR)/openssl/ssl.rb $(RUBY_LIB_DIR)/x86_64-linux/openssl.so
  80. build/$(RUBY_NAME).tar.xz: | build/
  81. wget http://cache.ruby-lang.org/pub/ruby/$(RUBY_MAJOR_VERSION)/$(RUBY_NAME).tar.xz -O $@
  82. $(RUBY_DIR)/: build/$(RUBY_NAME).tar.xz
  83. tar -C build -xf $<
  84. patch -d $@ -p1 < tmp_key.patch
  85. patch -d $@ -p1 < set_ecdh_curves.patch
  86. patch -d $@ -p1 < fallback_scsv.patch
  87. patch -d $@ -p1 < multiple_certs.patch
  88. $(RUBY_OPENSSL_EXT_DIR)/Makefile: libs | $(RUBY_DIR)/
  89. cd $(RUBY_OPENSSL_EXT_DIR) && ruby extconf.rb
  90. $(RUBY_OPENSSL_EXT_DIR)/openssl.so: $(LIBS) $(RUBY_OPENSSL_EXT_DIR)/Makefile
  91. top_srcdir=../.. $(MAKE) -C $(RUBY_OPENSSL_EXT_DIR)
  92. lib/openssl.so: $(RUBY_OPENSSL_EXT_DIR)/openssl.so
  93. cp $< $@
  94. ext: lib/openssl.so
  95. install-ruby: $(RUBY_DIR)/
  96. cd $(RUBY_DIR)/ && ./configure --enable-shared --disable-install-rdoc && make install
  97. spec/faketime/libfaketime.so: spec/faketime/faketime.c spec/faketime/faketime.h
  98. $(CC) $^ -o $@ -shared -fPIC -ldl -std=c99 -Werror -Wall
  99. lib/libfaketime.so: spec/faketime/libfaketime.so
  100. ln -fs ../$< $@
  101. faketime: lib/libfaketime.so
  102. test-material:
  103. bin/generate-test-material.rb
  104. test: spec/faketime/libfaketime.so
  105. bin/rspec