+(define-public glibc/hurd
+ ;; The Hurd's libc variant.
+ (package (inherit glibc/linux)
+ (name "glibc-hurd")
+ (version "2.23")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "http://alpha.gnu.org/gnu/hurd/glibc-"
+ version "-hurd+libpthread-20161218" ".tar.gz"))
+ (sha256
+ (base32
+ "0vpdv05j6j3ria5bw8gp468i64gij94cslxkxj9xkfgi6p615b8p"))))
+
+ ;; Libc provides <hurd.h>, which includes a bunch of Hurd and Mach headers,
+ ;; so both should be propagated.
+ (propagated-inputs `(("hurd-core-headers" ,hurd-core-headers)))
+ (native-inputs
+ `(,@(package-native-inputs glibc/linux)
+ ("mig" ,mig)
+ ("perl" ,perl)))
+
+ (arguments
+ (substitute-keyword-arguments (package-arguments glibc/linux)
+ ((#:phases original-phases)
+ ;; Add libmachuser.so and libhurduser.so to libc.so's search path.
+ ;; See <http://lists.gnu.org/archive/html/bug-hurd/2015-07/msg00051.html>.
+ `(alist-cons-after
+ 'install 'augment-libc.so
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out")))
+ (substitute* (string-append out "/lib/libc.so")
+ (("/[^ ]+/lib/libc.so.0.3")
+ (string-append out "/lib/libc.so.0.3" " libmachuser.so" " libhurduser.so"))))
+ #t)
+ (alist-cons-after
+ 'pre-configure 'pre-configure-set-pwd
+ (lambda _
+ ;; Use the right 'pwd'.
+ (substitute* "configure"
+ (("/bin/pwd") "pwd")))
+ ,original-phases)))
+ ((#:configure-flags original-configure-flags)
+ `(append (list "--host=i586-pc-gnu"
+
+ ;; We need this to get a working openpty() function.
+ "--enable-pt_chown"
+
+ ;; <https://lists.gnu.org/archive/html/bug-hurd/2016-10/msg00033.html>
+ "--disable-werror"
+
+ ;; nscd fails to build for GNU/Hurd:
+ ;; <https://lists.gnu.org/archive/html/bug-hurd/2014-07/msg00006.html>.
+ ;; Disable it.
+ "--disable-nscd")
+ (filter (lambda (flag)
+ (not (string-prefix? "--enable-kernel=" flag)))
+ ,original-configure-flags)))))
+ (synopsis "The GNU C Library (GNU Hurd variant)")
+ (supported-systems %hurd-systems)))
+
+(define* (glibc-for-target #:optional
+ (target (or (%current-target-system)
+ (%current-system))))
+ "Return the glibc for TARGET, GLIBC/LINUX for a Linux host or
+GLIBC/HURD for a Hurd host"
+ (match target
+ ((or "i586-pc-gnu" "i586-gnu") glibc/hurd)
+ (_ glibc/linux)))
+
+(define-syntax glibc
+ (identifier-syntax (glibc-for-target)))
+
+;; Below are old libc versions, which we use mostly to build locale data in
+;; the old format (which the new libc cannot cope with.)
+
+(define-public glibc-2.23
+ (package
+ (inherit glibc)
+ (version "2.23")
+ (source (origin
+ (inherit (package-source glibc))
+ (uri (string-append "mirror://gnu/glibc/glibc-"
+ version ".tar.xz"))
+ (sha256
+ (base32
+ "1s8krs3y2n6pzav7ic59dz41alqalphv7vww4138ag30wh0fpvwl"))))))
+
+(define-public glibc-2.22
+ (package
+ (inherit glibc)
+ (version "2.22")
+ (source (origin
+ (inherit (package-source glibc))
+ (uri (string-append "mirror://gnu/glibc/glibc-"
+ version ".tar.xz"))
+ (sha256
+ (base32
+ "0j49682pm2nh4qbdw35bas82p1pgfnz4d2l7iwfyzvrvj0318wzb"))
+ (patches (search-patches "glibc-ldd-x86_64.patch"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments glibc)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-before 'configure 'fix-pwd
+ (lambda _
+ ;; Use `pwd' instead of `/bin/pwd' for glibc-2.21
+ (substitute* "configure"
+ (("/bin/pwd") "pwd"))))))))))
+
+(define-public glibc-2.21
+ (package
+ (inherit glibc-2.22)
+ (version "2.21")
+ (source (origin
+ (inherit (package-source glibc))
+ (uri (string-append "mirror://gnu/glibc/glibc-"
+ version ".tar.xz"))
+ (sha256
+ (base32
+ "1f135546j34s9bfkydmx2nhh9vwxlx60jldi80zmsnln6wj3dsxf"))
+ (patches (search-patches "glibc-ldd-x86_64.patch"))))))
+