Blame SOURCES/Net-LibIDN-0.12-Respect-Config-s-cc-ccflags-and-ldflags.patch

e5c5ec
From 3bd67bf63ee68c88cc05a66607a79c5cd314a6d2 Mon Sep 17 00:00:00 2001
e5c5ec
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
e5c5ec
Date: Tue, 14 Jul 2015 14:25:57 +0200
e5c5ec
Subject: [PATCH] Respect Config's cc ccflags and ldflags
e5c5ec
MIME-Version: 1.0
e5c5ec
Content-Type: text/plain; charset=UTF-8
e5c5ec
Content-Transfer-Encoding: 8bit
e5c5ec
e5c5ec
The ExtUils::MakeMaker expects LIBS contains only libs and INC contain
e5c5ec
only include paths. Thus you cannot put ldflags od ccflags there. They
e5c5ec
will be injected later when generating the Makefile.
e5c5ec
e5c5ec
However to use the flags when checking for libidn, you have to use
e5c5ec
apply them manually only for the manual check.
e5c5ec
e5c5ec
This patch adds cc and ccflags into consideration as some systems
e5c5ec
needs them when using cusotm ldflags.
e5c5ec
e5c5ec
Signed-off-by: Petr Písař <ppisar@redhat.com>
e5c5ec
---
e5c5ec
 Makefile.PL | 31 +++++++++++++++++++------------
e5c5ec
 1 file changed, 19 insertions(+), 12 deletions(-)
e5c5ec
e5c5ec
diff --git a/Makefile.PL b/Makefile.PL
e5c5ec
index 6709fe1..47f63db 100644
e5c5ec
--- a/Makefile.PL
e5c5ec
+++ b/Makefile.PL
e5c5ec
@@ -47,23 +47,17 @@ sub InitMakeParams
e5c5ec
 		"disable-tld" => \$disable_tld
e5c5ec
 	);
e5c5ec
 
e5c5ec
+	$Params{LIBS} = '';
e5c5ec
 	if ($libdir)
e5c5ec
 	{
e5c5ec
-		$Params{LIBS} = "-L$libdir -lidn";
e5c5ec
-	}
e5c5ec
-	else
e5c5ec
-	{
e5c5ec
-		$Params{LIBS} = $Config{ldflags} . ' -lidn';
e5c5ec
+		$Params{LIBS} .= "-L$libdir ";
e5c5ec
 	}
e5c5ec
+	$Params{LIBS} .= '-lidn';
e5c5ec
 
e5c5ec
 	if ($incdir)
e5c5ec
 	{
e5c5ec
 		$Params{INC} = "-I$incdir";
e5c5ec
 	}
e5c5ec
-	else
e5c5ec
-	{
e5c5ec
-		$Params{INC} = '';
e5c5ec
-	}
e5c5ec
 
e5c5ec
 	my $libidn = CheckLibidn($Params{INC}, $Params{LIBS});
e5c5ec
 
e5c5ec
@@ -146,11 +140,24 @@ sub FilterTLD
e5c5ec
 	}
e5c5ec
 }
e5c5ec
 
e5c5ec
+sub concat {
e5c5ec
+	my ($a, $b) = @_;
e5c5ec
+	if (!defined $a)
e5c5ec
+	{
e5c5ec
+		$a = '';
e5c5ec
+	}
e5c5ec
+	if (!defined $b)
e5c5ec
+	{
e5c5ec
+		$b = '';
e5c5ec
+	};
e5c5ec
+	return ($a . ' ' . $b);
e5c5ec
+}
e5c5ec
+
e5c5ec
 sub CheckCCode
e5c5ec
 {
e5c5ec
 	my $code = shift;
e5c5ec
-	my $cflags = shift;
e5c5ec
-	my $ldflags = shift;
e5c5ec
+	my $cflags = concat($Config{ccflags}, shift);
e5c5ec
+	my $ldflags = concat($Config{ldflags}, shift);
e5c5ec
 	my $output = shift;
e5c5ec
 	my $test = '__test'.$testno++;
e5c5ec
 	local * FILE;
e5c5ec
@@ -165,7 +172,7 @@ sub CheckCCode
e5c5ec
 		return 0;
e5c5ec
 	}
e5c5ec
 
e5c5ec
-	foreach my $cc (qw/cc gcc/)
e5c5ec
+	foreach my $cc ($Config{cc}, qw/cc gcc/)
e5c5ec
 	{
e5c5ec
 		unlink($test);
e5c5ec
 		system "$cc $cflags -o $test $test.c $ldflags";
e5c5ec
-- 
e5c5ec
2.4.3
e5c5ec