From b00779863f9a58870eed5a03c040ec1d570116b1 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 23 May 2018 20:46:39 -0600 Subject: [PATCH] fix Windows OpenSSL native library build --- racket/src/native-libs/build.rkt | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/racket/src/native-libs/build.rkt b/racket/src/native-libs/build.rkt index edff5da8de..2f4d0b1e74 100644 --- a/racket/src/native-libs/build.rkt +++ b/racket/src/native-libs/build.rkt @@ -171,6 +171,17 @@ ;; Adapt inline-function handling for an old gcc (define-runtime-path gmp-inline-patch "patches/gmp-inline.patch") +;; -------------------------------------------------- + +(define (replace-in-file file orig new) + (define rx (regexp-quote orig)) + (define-values (i o) (open-input-output-file file #:exists 'update)) + (define pos (caar (regexp-match-positions rx i))) + (file-position o pos) + (write-bytes new o) + (close-output-port o) + (close-input-port i)) + ;; -------------------------------------------------- ;; General environment and flag configuration: @@ -281,7 +292,8 @@ #:setup [setup null] #:patches [patches null] #:post-patches [post-patches null] - #:fixup [fixup #f]) + #:fixup [fixup #f] + #:fixup-proc [fixup-proc #f]) (for ([d (in-list (append (if (or (equal? package-name "pkg-config") (equal? package-name "sed")) '() @@ -291,7 +303,7 @@ deps))]) (unless (file-exists? (build-path dest "stamps" d)) (error 'build "prerequisite needed: ~a" d))) - (values env exe args make make-install setup patches post-patches fixup)) + (values env exe args make make-install setup patches post-patches fixup fixup-proc)) (define path-flags (list (list "CPPFLAGS" (~a "-I" dest "/include")) @@ -308,9 +320,9 @@ (define (linux-only) (unless linux? (error (format "build ~a only for Linux" package-name)))) - + (define-values (extra-env configure-exe extra-args make-command make-install-command - setup patches post-patches fixup) + setup patches post-patches fixup fixup-proc) (case package-name [("pkg-config") (config #:configure (list "--with-internal-glib"))] [("sed") (config)] @@ -354,7 +366,12 @@ #:fixup (and win? (~a "cd " (build-path dest "bin") " && mv libssl-1_1" (if m32? "" "-x64") ".dll ssleay32.dll" - " && mv libcrypto-1_1" (if m32? "" "-x64") ".dll libeay32.dll")))] + " && mv libcrypto-1_1" (if m32? "" "-x64") ".dll libeay32.dll")) + #:fixup-proc (and win? + (lambda () + (replace-in-file (build-path dest "bin" "ssleay32.dll") + (bytes-append #"libcrypto-1_1" (if m32? #"" #"-x64") #".dll\0") + #"libeay32.dll\0"))))] [("expat") (config)] [("gettext") (config #:depends (if win? '("libiconv") '()) #:configure '("--enable-languages=c") @@ -578,5 +595,7 @@ (system/show make-install-command) (when fixup (system/show fixup)) + (when fixup-proc + (fixup-proc)) (stamp package-name) (displayln "Success!"))