develooper Front page | perl.perl5.porters | Postings from July 2001

[PATCH] Print CONFIGURE params in ExtUtils::MakeMaker output

From:
David D. Kilzer
Date:
July 23, 2001 13:56
Subject:
[PATCH] Print CONFIGURE params in ExtUtils::MakeMaker output
Message ID:
20010723113217.A28614@elbonia.lubricants-oil.com
Below is a patch for ExtUtils::MakeMaker.pm (against v5.45) that will
print out any parameters returned from a 'CONFIGURE' directive in the
'Makefile' that is generated.  I found this useful when using the
'CONFIGURE' directive in a Makefile.PL for Bugzilla (still working on
it).

Hope you find it useful!

Dave
--
David D. Kilzer
Senior Systems & Software Engineer
Competetive Solutions, Inc.
ddkilzer@lubricants-oil.com


diff -u ExtUtils/MakeMaker.pm.orig ExtUtils/MakeMaker.pm
--- ExtUtils/MakeMaker.pm.orig	Mon Feb 26 09:39:36 2001
+++ ExtUtils/MakeMaker.pm	Mon Jul 23 11:20:26 2001
@@ -326,7 +326,8 @@
 
     check_hints($self);
 
-    my(%initial_att) = %$self; # record initial attributes
+    my %configure_att;		# record &{$self->{CONFIGURE}} attributes
+    my(%initial_att) = %$self;	# record initial attributes
 
     my($prereq);
     foreach $prereq (sort keys %{$self->{PREREQ_PM}}) {
@@ -365,7 +366,8 @@
 
     if (defined $self->{CONFIGURE}) {
 	if (ref $self->{CONFIGURE} eq 'CODE') {
-	    $self = { %$self, %{&{$self->{CONFIGURE}}}};
+	    %configure_att = %{&{$self->{CONFIGURE}}};
+	    $self = { %$self, %configure_att };
 	} else {
 	    Carp::croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
 	}
@@ -470,6 +472,27 @@
 	$v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
 	$v =~ tr/\n/ /s;
 	push @{$self->{RESULT}}, "#	$key => $v";
+    }
+    undef %initial_att;	# free memory
+
+    if (defined $self->{CONFIGURE}) {
+	push @{$self->{RESULT}}, <<END;
+
+#   MakeMaker 'CONFIGURE' Parameters:
+END
+        if (scalar(keys %configure_att) > 0) {
+            foreach $key (sort keys %configure_att){
+	        my($v) = neatvalue($configure_att{$key});
+	        $v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
+	        $v =~ tr/\n/ /s;
+	        push @{$self->{RESULT}}, "#	$key => $v";
+            }
+        }
+        else
+        {
+	    push @{$self->{RESULT}}, "#	no values returned";
+        }
+        undef %configure_att;	# free memory
     }
 
     # turn the SKIP array into a SKIPHASH hash




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About