1{ stdenv, fetchurl, ant, jdk, junit }:
2
3stdenv.mkDerivation rec {
4 name = "junixsocket-1.3";
5
6 src = fetchurl {
7 url = "http://junixsocket.googlecode.com/files/${name}-src.tar.bz2";
8 sha256 = "0c6p8vmiv5nk8i6g1hgivnl3mpb2k3lhjjz0ss9dlirisfrxf1ym";
9 };
10
11 patches = [ ./darwin.patch ];
12
13 buildInputs = [ ant jdk junit ];
14
15 preConfigure =
16 ''
17 substituteInPlace src/main/org/newsclub/net/unix/NativeUnixSocketConfig.java \
18 --replace /opt/newsclub/lib-native $out/lib
19 '';
20
21 buildPhase = "ant";
22
23 ANT_ARGS =
24 # Note that our OpenJDK on Darwin is currently 32-bit, so we have to build a 32-bit dylib.
25 (if stdenv.is64bit then [ "-Dskip32=true" ] else [ "-Dskip64=true" ])
26 ++ [ "-Dgcc=cc" "-Dant.build.javac.source=1.6" ]
27 ++ stdenv.lib.optional stdenv.isDarwin "-DisMac=true";
28
29 installPhase =
30 ''
31 mkdir -p $out/share/java $out/lib
32 cp -v dist/*.jar $out/share/java
33 cp -v lib-native/*.so lib-native/*.dylib $out/lib/
34 '';
35
36 meta = {
37 description = "A Java/JNI library for using Unix Domain Sockets from Java";
38 homepage = https://code.google.com/p/junixsocket/;
39 license = stdenv.lib.licenses.asl20;
40 platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
41 };
42}