From e5995e0703de588af9d71e636eea7ddb1c695af0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 28 Jan 2014 11:56:14 +0100 Subject: [PATCH] junixsocket: Support Darwin Patch borrowed from Rob Vermaas. --- .../libraries/java/junixsocket/darwin.patch | 20 +++++++++++++++++++ .../libraries/java/junixsocket/default.nix | 14 +++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/libraries/java/junixsocket/darwin.patch diff --git a/pkgs/development/libraries/java/junixsocket/darwin.patch b/pkgs/development/libraries/java/junixsocket/darwin.patch new file mode 100644 index 000000000000..97fd42d0b81b --- /dev/null +++ b/pkgs/development/libraries/java/junixsocket/darwin.patch @@ -0,0 +1,20 @@ +diff -rc junixsocket-1.3/src/main/org/newsclub/net/unix/NativeUnixSocket.java junixsocket-1.3-new/src/main/org/newsclub/net/unix/NativeUnixSocket.java +*** junixsocket-1.3/src/main/org/newsclub/net/unix/NativeUnixSocket.java Tue Jul 20 14:59:41 2010 +--- junixsocket-1.3-new/src/main/org/newsclub/net/unix/NativeUnixSocket.java Sun May 27 22:26:15 2012 +*************** +*** 43,49 **** + String prefix = "lib"; + String suffix = ".so"; + String os = osName.replaceAll("[^A-Za-z0-9]", "").toLowerCase(); +! if ("macosx".equals(os)) { + suffix = ".dylib"; + } else if ("linux".equals(os) || "freebsd".equals(os) + || "sunos".equals(os)) { +--- 43,49 ---- + String prefix = "lib"; + String suffix = ".so"; + String os = osName.replaceAll("[^A-Za-z0-9]", "").toLowerCase(); +! if ("macosx".equals(os) || "darwin".equals(os)) { + suffix = ".dylib"; + } else if ("linux".equals(os) || "freebsd".equals(os) + || "sunos".equals(os)) { diff --git a/pkgs/development/libraries/java/junixsocket/default.nix b/pkgs/development/libraries/java/junixsocket/default.nix index 911cc6dd40d4..e49e626aa001 100644 --- a/pkgs/development/libraries/java/junixsocket/default.nix +++ b/pkgs/development/libraries/java/junixsocket/default.nix @@ -8,11 +8,15 @@ stdenv.mkDerivation rec { sha256 = "0c6p8vmiv5nk8i6g1hgivnl3mpb2k3lhjjz0ss9dlirisfrxf1ym"; }; + patches = [ ./darwin.patch ]; + buildInputs = [ ant jdk junit ]; preConfigure = '' - sed -i 's|/usr/bin/||' build.xml + substituteInPlace build.xml \ + --replace /usr/bin/ "" \ + --replace macosx darwin substituteInPlace src/main/org/newsclub/net/unix/NativeUnixSocketConfig.java \ --replace /opt/newsclub/lib-native $out/lib ''; @@ -20,8 +24,10 @@ stdenv.mkDerivation rec { buildPhase = "ant"; ANT_ARGS = - "-Dskip32=true -Dant.build.javac.source=1.6" - + stdenv.lib.optionalString stdenv.isDarwin " -DisMac=true"; + # Note that our OpenJDK on Darwin is currently 32-bit, so we have to build a 32-bit dylib. + (if stdenv.is64bit && !stdenv.isDarwin then [ "-Dskip32=true" ] else [ "-Dskip64=true" ]) + ++ [ "-Dgcc=cc" "-Dant.build.javac.source=1.6" ] + ++ stdenv.lib.optional stdenv.isDarwin "-DisMac=true"; installPhase = '' @@ -34,6 +40,6 @@ stdenv.mkDerivation rec { description = "A Java/JNI library for using Unix Domain Sockets from Java"; homepage = https://code.google.com/p/junixsocket/; license = stdenv.lib.licenses.asl20; - platforms = stdenv.lib.platforms.linux; + platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; }; }