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