summary refs log tree commit diff
path: root/gnu/packages/tls.scm
diff options
context:
space:
mode:
authorMaxime Devos <maximedevos@telenet.be>2021-07-14 13:13:02 +0200
committerMathieu Othacehe <othacehe@gnu.org>2021-07-14 15:57:40 +0200
commit7fabe9c845ea576a660bc555d8024302b62b455c (patch)
tree0ec7c11139ea00b8b800074c225f716642861ada /gnu/packages/tls.scm
parent3e42c2bfbb3d0fc60f2f3473f3c8669c749b94b3 (diff)
downloadguix-7fabe9c845ea576a660bc555d8024302b62b455c.tar.gz
openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
By computing this value outside the build code, new targets
can be added without causing rebuilds for other targets.

* gnu/packages/tls.scm
  (target->openssl-target): New procedure.
  (openssl)[arguments]<#:phases>{set-cross-compile}: Use it.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Diffstat (limited to 'gnu/packages/tls.scm')
-rw-r--r--gnu/packages/tls.scm46
1 files changed, 27 insertions, 19 deletions
diff --git a/gnu/packages/tls.scm b/gnu/packages/tls.scm
index b58cb9459d..49f5dd115d 100644
--- a/gnu/packages/tls.scm
+++ b/gnu/packages/tls.scm
@@ -311,6 +311,31 @@ required structures.")
 (define-public guile3.0-gnutls
   (deprecated-package "guile3.0-gnutls" gnutls))
 
+(define (target->openssl-target target)
+  "Return the value to set CONFIGURE_TARGET_ARCH to when cross-compiling
+OpenSSL for TARGET."
+  ;; Keep this code outside the build code,
+  ;; such that new targets can be added
+  ;; without causing rebuilds for other targets.
+  (cond ((string-prefix? "i586" target)
+         "hurd-x86")
+        ((string-prefix? "i686" target)
+         "linux-x86")
+        ((string-prefix? "x86_64" target)
+         "linux-x86_64")
+        ((string-prefix? "mips64el" target)
+         "linux-mips64")
+        ((string-prefix? "arm" target)
+         "linux-armv4")
+        ((string-prefix? "aarch64" target)
+         "linux-aarch64")
+        ((string-prefix? "powerpc64le" target)
+         "linux-ppc64le")
+        ((string-prefix? "powerpc64" target)
+         "linux-ppc64")
+        ((string-prefix? "powerpc" target)
+         "linux-ppc")))
+
 (define-public openssl
   (package
     (name "openssl")
@@ -349,25 +374,8 @@ required structures.")
                      (lambda* (#:key target #:allow-other-keys)
                        (setenv "CROSS_COMPILE" (string-append target "-"))
                        (setenv "CONFIGURE_TARGET_ARCH"
-                               (cond
-                                ((string-prefix? "i586" target)
-                                 "hurd-x86")
-                                ((string-prefix? "i686" target)
-                                 "linux-x86")
-                                ((string-prefix? "x86_64" target)
-                                 "linux-x86_64")
-                                ((string-prefix? "mips64el" target)
-                                 "linux-mips64")
-                                ((string-prefix? "arm" target)
-                                 "linux-armv4")
-                                ((string-prefix? "aarch64" target)
-                                 "linux-aarch64")
-                                ((string-prefix? "powerpc64le" target)
-                                 "linux-ppc64le")
-                                ((string-prefix? "powerpc64" target)
-                                 "linux-ppc64")
-                                ((string-prefix? "powerpc" target)
-                                 "linux-ppc"))))))
+                               #$(target->openssl-target
+                                  (%current-target-system))))))
                 #~())
          (replace 'configure
            (lambda* (#:key configure-flags #:allow-other-keys)