From dd4841e8335ab3c16f01499433baa08b9f09a3e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Thu, 1 Dec 2011 10:59:26 +0000
Subject: [PATCH] OpenSSL: Fix compilation on x86_64-freebsd.

svn path=/nixpkgs/trunk/; revision=30642
---
 pkgs/development/libraries/openssl/default.nix   |  4 +++-
 .../libraries/openssl/freebsd-x86_64-asm.patch   | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 pkgs/development/libraries/openssl/freebsd-x86_64-asm.patch

diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix
index c8b7aece86eb..45d269a918b3 100644
--- a/pkgs/development/libraries/openssl/default.nix
+++ b/pkgs/development/libraries/openssl/default.nix
@@ -21,7 +21,9 @@ stdenv.mkDerivation {
     sha256 = "1nr0cf6pf8i4qsnx31kqhiqv402xgn76yhjhlbdri8ma1hgislcj";
   };
 
-  patches = stdenv.lib.optional stdenv.isDarwin ./darwin-arch.patch;
+  patches =
+    stdenv.lib.optional stdenv.isDarwin ./darwin-arch.patch
+    ++ stdenv.lib.optional (stdenv.system == "x86_64-freebsd") ./freebsd-x86_64-asm.patch;
 
   buildNativeInputs = [ perl ];
 
diff --git a/pkgs/development/libraries/openssl/freebsd-x86_64-asm.patch b/pkgs/development/libraries/openssl/freebsd-x86_64-asm.patch
new file mode 100644
index 000000000000..f52e4dac25f5
--- /dev/null
+++ b/pkgs/development/libraries/openssl/freebsd-x86_64-asm.patch
@@ -0,0 +1,16 @@
+Patch for <http://rt.openssl.org/Ticket/Display.html?id=2435&user=guest&pass=guest>.
+Fixes compilation on FreeBSD 8.2 with GNU Make 3.81.
+
+diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl
+index e47116b..dc500ae 100755
+--- a/crypto/perlasm/x86_64-xlate.pl
++++ b/crypto/perlasm/x86_64-xlate.pl
+@@ -66,7 +66,7 @@ if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
+   my ($outdev,$outino,@junk)=stat($output);
+ 
+     open STDOUT,">$output" || die "can't open $output: $!"
+-	if ($stddev!=$outdev || $stdino!=$outino);
++	if (!defined($outdev) || $stddev!=$outdev || $stdino!=$outino);
+ }
+ 
+ my $gas=1;	$gas=0 if ($output =~ /\.asm$/);