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.

119 lines
4.2KB

  1. RBENV_ROOT ?= ~/.rbenv
  2. RBENV__VERSION := v1.1.2
  3. RUBY_BUILD_VERSION = v20200401
  4. OPENSSL_1_0_VERSION = 1.0.2j
  5. OPENSSL_1_1_VERSION = 1.1.1g
  6. RUBY_1_0_VERSION = 2.3.8
  7. RUBY_1_1_VERSION = 2.6.6
  8. ROOT_DIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
  9. BUILD_DIR = $(ROOT_DIR)/build
  10. LIBRARY_PATH_1_0 = $(BUILD_DIR)/openssl-$(OPENSSL_1_0_VERSION)
  11. C_INCLUDE_PATH_1_0 = $(LIBRARY_PATH_1_0)/include
  12. LIBRARY_PATH_1_1 = $(BUILD_DIR)/openssl-$(OPENSSL_1_1_VERSION)
  13. C_INCLUDE_PATH_1_1 = $(LIBRARY_PATH_1_1)/include
  14. MAKE_OPTS ?= -j $(shell nproc)
  15. .SECONDARY:
  16. clean:
  17. rm -rf build/
  18. $(RBENV_ROOT)/:
  19. git clone https://github.com/rbenv/rbenv/ "$@" -b "$(RBENV__VERSION)" --depth 1
  20. $(RBENV_ROOT)/plugins/ruby-build/: | $(RBENV_ROOT)/
  21. git clone https://github.com/rbenv/ruby-build/ "$@" -b "$(RUBY_BUILD_VERSION)" --depth 1
  22. rbenv: | $(RBENV_ROOT)/plugins/ruby-build/
  23. build/:
  24. mkdir "$@"
  25. build/chacha-poly.patch: | build/
  26. wget -q https://github.com/cloudflare/sslconfig/raw/master/patches/openssl__chacha20_poly1305_draft_and_rfc_ossl102j.patch -O "$@"
  27. build/openssl-%.tar.gz: | build/
  28. wget -q "https://www.openssl.org/source/$(notdir $@)" -O "$@"
  29. build/openssl-$(OPENSSL_1_0_VERSION)/: build/openssl-$(OPENSSL_1_0_VERSION).tar.gz build/chacha-poly.patch
  30. tar -C build -xf "$<"
  31. patch -d "$@" -p1 < build/chacha-poly.patch
  32. for p in patches/openssl/*.patch; do patch -d "$@" -p1 < "$$p"; done
  33. build/openssl-$(OPENSSL_1_1_VERSION)/: build/openssl-$(OPENSSL_1_1_VERSION).tar.gz build/chacha-poly.patch
  34. tar -C build -xf "$<"
  35. .ONESHELL:
  36. build/openssl-%/Makefile: | build/openssl-%/
  37. cd "$(dir $@)"
  38. ./config --prefix=/usr --openssldir=/etc/ssl \
  39. enable-ssl2 enable-ssl3 enable-ssl3-method \
  40. enable-md2 enable-rc5 enable-weak-ssl-ciphers enable-shared
  41. $(MAKE) $(MAKE_OPTS) depend
  42. build/openssl-%/libssl.so build/openssl-%/libcrypto.so: build/openssl-%/Makefile
  43. $(MAKE) -C "$(dir $<)" $(MAKE_OPTS)
  44. openssl-1.0: build/openssl-$(OPENSSL_1_0_VERSION)/libssl.so build/openssl-$(OPENSSL_1_0_VERSION)/libcrypto.so
  45. openssl-1.1: build/openssl-$(OPENSSL_1_1_VERSION)/libssl.so build/openssl-$(OPENSSL_1_1_VERSION)/libcrypto.so
  46. openssl: openssl-1.0 openssl-1.1
  47. build/$(RUBY_1_0_VERSION)-cryptcheck: $(RBENV_ROOT)/plugins/ruby-build/share/ruby-build/$(RUBY_1_0_VERSION)
  48. cp "$<" "$@"
  49. build/$(RUBY_1_1_VERSION)-cryptcheck: $(RBENV_ROOT)/plugins/ruby-build/share/ruby-build/$(RUBY_1_1_VERSION)
  50. cp "$<" "$@"
  51. $(RBENV_ROOT)/versions/$(RUBY_1_0_VERSION)-cryptcheck: build/$(RUBY_1_0_VERSION)-cryptcheck openssl-1.0
  52. cat patches/ruby/*.patch | \
  53. LIBRARY_PATH="$(LIBRARY_PATH_1_0)" \
  54. C_INCLUDE_PATH="$(C_INCLUDE_PATH_1_0)" \
  55. LD_LIBRARY_PATH="$(LIBRARY_PATH_1_0)" \
  56. RUBY_BUILD_CACHE_PATH="$(BUILD_DIR)" \
  57. RUBY_BUILD_DEFINITIONS="$(BUILD_DIR)" \
  58. MAKE_OPTS="$(MAKE_OPTS)" rbenv install -fp "$(notdir $@)"
  59. $(RBENV_ROOT)/versions/$(RUBY_1_1_VERSION)-cryptcheck: build/$(RUBY_1_1_VERSION)-cryptcheck openssl-1.1
  60. cat patches/ciphersuites.patch | \
  61. LIBRARY_PATH="$(LIBRARY_PATH_1_1)" \
  62. C_INCLUDE_PATH="$(C_INCLUDE_PATH_1_1)" \
  63. LD_LIBRARY_PATH="$(LIBRARY_PATH_1_1)" \
  64. RUBY_BUILD_CACHE_PATH="$(BUILD_DIR)" \
  65. RUBY_BUILD_DEFINITIONS="$(BUILD_DIR)" \
  66. MAKE_OPTS="$(MAKE_OPTS)" rbenv install -fp "$(notdir $@)"
  67. ruby-1.0: $(RBENV_ROOT)/versions/$(RUBY_1_0_VERSION)-cryptcheck
  68. ruby-1.1: $(RBENV_ROOT)/versions/$(RUBY_1_1_VERSION)-cryptcheck
  69. ruby: ruby-1.0 ruby-1.1
  70. build/libfaketime.so: spec/faketime/faketime.c spec/faketime/faketime.h
  71. $(CC) $^ -o "$@" -shared -fPIC -ldl -std=c99 -Werror -Wall
  72. faketime: build/libfaketime.so
  73. .PHONY: faketime
  74. test-material:
  75. bin/generate-test-material.rb
  76. test: spec/faketime/libfaketime.so
  77. LD_LIBRARY_PATH="$(LIBRARY_PATH_1_0):$(BUILD_DIR)" bin/rspec
  78. .PHONY: test
  79. docker-1.0:
  80. docker build . --target engine \
  81. -t aeris22/cryptcheck:v2-1.0 \
  82. -t aeris22/cryptcheck:v2.2-1.0 \
  83. -t aeris22/cryptcheck:latest-1.0 \
  84. -t aeris22/cryptcheck:v2 \
  85. -t aeris22/cryptcheck:v2.2 \
  86. -t aeris22/cryptcheck:latest
  87. docker-1.1:
  88. docker build . --target engine \
  89. --build-arg OPENSSL_VERSION=1.1.1g \
  90. --build-arg OPENSSL_BINDING=1.1 \
  91. --build-arg OPENSSL_LIB_VERSION=1.1 \
  92. --build-arg RUBY_VERSION=2.6.6-cryptcheck \
  93. -t aeris22/cryptcheck:v2-1.1 \
  94. -t aeris22/cryptcheck:v2.2-1.1 \
  95. -t aeris22/cryptcheck:latest-1.1
  96. docker: docker-1.0 docker-1.1