aboutsummaryrefslogtreecommitdiff
path: root/guix/utils.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/utils.scm')
-rw-r--r--guix/utils.scm24
1 files changed, 22 insertions, 2 deletions
diff --git a/guix/utils.scm b/guix/utils.scm
index d0d2e8a3d4..1c619c3ef9 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2013, 2014, 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
;;;
@@ -61,6 +61,7 @@
location-column
source-properties->location
+ nix-system->gnu-triplet
gnu-triplet->nix-system
%current-system
%current-target-system
@@ -476,6 +477,23 @@ previous value of the keyword argument."
(()
(reverse before)))))))
+(define* (nix-system->gnu-triplet
+ #:optional (system (%current-system)) (vendor "unknown"))
+ "Return a guess of the GNU triplet corresponding to Nix system
+identifier SYSTEM."
+ (match system
+ ("armhf-linux"
+ (string-append "arm-" vendor "-linux-gnueabihf"))
+ (_
+ (let* ((dash (string-index system #\-))
+ (arch (substring system 0 dash))
+ (os (substring system (+ 1 dash))))
+ (string-append arch
+ "-" vendor "-"
+ (if (string=? os "linux")
+ "linux-gnu"
+ os))))))
+
(define (gnu-triplet->nix-system triplet)
"Return the Nix system type corresponding to TRIPLET, a GNU triplet as
returned by `config.guess'."
@@ -484,7 +502,9 @@ returned by `config.guess'."
(lambda (m)
(string-append "i686-" (match:substring m 1))))
(else triplet))))
- (cond ((string-match "^([^-]+)-([^-]+-)?linux-gnu.*" triplet)
+ (cond ((string-match "^arm[^-]*-([^-]+-)?linux-gnueabihf" triplet)
+ "armhf-linux")
+ ((string-match "^([^-]+)-([^-]+-)?linux-gnu.*" triplet)
=>
(lambda (m)
;; Nix omits `-gnu' for GNU/Linux.