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