1{ fetchgit, stdenv, autoconf, automake, libtool
2, machHeaders, hurdHeaders, hurd, headersOnly ? false
3, cross ? null, gccCross ? null, glibcCross ? null }:
4
5assert (cross != null) -> (gccCross != null) && (glibcCross != null);
6assert (!headersOnly) -> (hurd != null);
7
8let
9 date = "20111020";
10
11 # Use the `tschwinge/Peter_Herbolzheimer' branch as prescribed in
12 # <http://www.gnu.org/software/hurd/hurd/building/cross-compiling.html>.
13 rev = "a7b82c3302bf9c47176648eb802a61ae2d9a16f5";
14in
15stdenv.mkDerivation ({
16 name = "libpthread-hurd-${if headersOnly then "headers-" else ""}${date}";
17
18 src = fetchgit {
19 url = "git://git.sv.gnu.org/hurd/libpthread.git";
20 sha256 = "e8300762914d927c0da4168341a5982a1057613e1af363ee68942087b2570b3d";
21 inherit rev;
22 };
23
24 nativeBuildInputs = [ autoconf automake libtool ];
25 buildInputs = [ machHeaders hurdHeaders ]
26 ++ stdenv.lib.optional (!headersOnly) hurd
27 ++ stdenv.lib.optional (gccCross != null) gccCross;
28
29 preConfigure = "autoreconf -vfi";
30
31 meta = {
32 description = "GNU Hurd's libpthread";
33
34 license = stdenv.lib.licenses.lgpl2Plus;
35
36 maintainers = [ stdenv.lib.maintainers.ludo ];
37 };
38}
39
40//
41
42(if headersOnly
43 then {
44 configureFlags =
45 [ "--build=i586-pc-gnu"
46 "ac_cv_lib_ihash_hurd_ihash_create=yes"
47 ];
48
49 dontBuild = true;
50 installPhase = "make install-data-local-headers";
51 }
52 else { })
53
54//
55
56(if cross != null
57 then {
58 # Tell gcc where to find `crt1.o' et al. This is specified in two
59 # different ways: one for gcc as run from `configure', and one for linking
60 # libpthread.so (by default `libtool --mode=link' swallows `-B', hence
61 # this workaround; see
62 # <http://lists.gnu.org/archive/html/bug-libtool/2010-05/msg00012.html>.)
63 LDFLAGS = "-B${glibcCross}/lib";
64 makeFlags = [ "LDFLAGS=-Wc,-B${glibcCross}/lib" ];
65
66 # Help the linker find glibc.
67 CPATH = "${glibcCross}/include";
68 LIBRARY_PATH = "${glibcCross}/lib";
69
70 passthru = {
71 # Extra target LDFLAGS to allow the cross-linker to find the
72 # dependencies of the cross libpthread.so, namely libihash.so.
73 # Note: these are raw `ld' flags, so `-Wl,' must be prepended when using
74 # `gcc'.
75 #
76 # This is actually only useful while building the final cross-gcc, since
77 # afterwards gcc-cross-wrapper should add the relevant flags.
78 TARGET_LDFLAGS = "-rpath-link=${hurd}/lib";
79 };
80 }
81 else { }))