gnu: Add function libiconv-if-needed.
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 3 May 2016 16:49:33 +0000 (18:49 +0200)
committerLudovic Courtès <ludo@gnu.org>
Wed, 7 Dec 2016 09:23:16 +0000 (10:23 +0100)
* gnu/packages/base.scm (libiconv-if-needed): New function.

gnu/packages/base.scm

index 1c01874..8b8134c 100644 (file)
@@ -46,7 +46,8 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (ice-9 match)
-  #:export (glibc))
+  #:export (glibc
+            libiconv-if-needed))
 
 ;;; Commentary:
 ;;;
@@ -1032,6 +1033,16 @@ program.  It supports a wide variety of different encodings.")
     (home-page "http://www.gnu.org/software/libiconv/")
     (license lgpl3+)))
 
+(define* (libiconv-if-needed #:optional (target (%current-target-system)))
+  "Return either a libiconv package specification to include in a dependency
+list for platforms that have an incomplete libc, or the empty list.  If a
+package needs iconv ,@(libiconv-if-needed) should be added."
+  ;; POSIX C libraries provide iconv.  Platforms with an incomplete libc
+  ;; without iconv, such as MinGW, must return the then clause.
+  (if (target-mingw? target)
+      `(("libiconv" ,libiconv))
+      '()))
+
 (define-public (canonical-package package)
   ;; Avoid circular dependency by lazily resolving 'commencement'.
   (let* ((iface (resolve-interface '(gnu packages commencement)))