git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] The Makefile.PL will now find .pm files itself.

From
Michael G. Schwern <schwern@pobox.com>
Date
Jul 25, 2012, 03:21 UTC
Message-ID
<1343186471-1024-4-git-send-email-schwern@pobox.com>
In-Reply-To
<1343186471-1024-1-git-send-email-schwern@pobox.com>
From: "Michael G. Schwern" <schwern@pobox.com>

It is no longer necessary to manually add new .pm files to the Makefile.PL. This makes it easier to add modules.

It is still necessary to add them to the Makefile, but that extra work should be removed at a future date.

Signed-off-by: Michael G Schwern <schwern@pobox.com>
---
 perl/Makefile.PL | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/perl/Makefile.PL b/perl/Makefile.PL
index 887fa1b..3f29ba9 100644
--- a/perl/Makefile.PL
+++ b/perl/Makefile.PL
@@ -2,6 +2,10 @@ use strict;
 use warnings;
 use ExtUtils::MakeMaker;
 use Getopt::Long;
+use File::Find;
+
+# Don't forget to update the perl/Makefile, too.
+# Don't forget to test with NO_PERL_MAKEMAKER=YesPlease
 
 # Sanity: die at first unknown option
 Getopt::Long::Configure qw/ pass_through /;
@@ -25,19 +29,18 @@ endif
 MAKE_FRAG
 }
 
-# XXX. When editing this list:
-#
-# * Please update perl/Makefile, too.
-# * Don't forget to test with NO_PERL_MAKEMAKER=YesPlease
-my %pm = (
-	'Git.pm' => '$(INST_LIBDIR)/Git.pm',
-	'Git/I18N.pm' => '$(INST_LIBDIR)/Git/I18N.pm',
-	'Git/SVN/Memoize/YAML.pm' => '$(INST_LIBDIR)/Git/SVN/Memoize/YAML.pm',
-	'Git/SVN/Fetcher.pm' => '$(INST_LIBDIR)/Git/SVN/Fetcher.pm',
-	'Git/SVN/Editor.pm' => '$(INST_LIBDIR)/Git/SVN/Editor.pm',
-	'Git/SVN/Prompt.pm' => '$(INST_LIBDIR)/Git/SVN/Prompt.pm',
-	'Git/SVN/Ra.pm' => '$(INST_LIBDIR)/Git/SVN/Ra.pm',
-);
+# Find all the .pm files in "Git/" and Git.pm
+my %pm;
+find sub {
+	return unless /\.pm$/;
+
+	# sometimes File::Find prepends a ./  Strip it.
+	my $pm_path = $File::Find::name;
+	$pm_path =~ s{^\./}{};
+
+	$pm{$pm_path} = '$(INST_LIBDIR)/'.$pm_path;
+}, "Git", "Git.pm";
+
 
 # We come with our own bundled Error.pm. It's not in the set of default
 # Perl modules so install it if it's not available on the system yet.
-- 
1.7.11.1
Previous: Michael G. SchwernNext: Jonathan Nieder
Message 4 of 16 in “Teach Makefile.PL to find .pm files on its own”
  1. Michael G. SchwernJul 25, 2012
  2. 1/3 Quiet warning if Makefile.PL is run with -w and no --localedirMichael G. Schwern, Jul 25, 2012
  3. 2/3 Don't lose Error.pm if $@ gets clobbered.Michael G. Schwern, Jul 25, 2012
  4. 3/3 The Makefile.PL will now find .pm files itself.Michael G. Schwern, Jul 25, 2012
  5. Jonathan NiederJul 25, 2012
  6. Jonathan NiederJul 25, 2012
  7. Michael G SchwernJul 25, 2012
  8. Jonathan NiederJul 25, 2012
  9. Junio C HamanoJul 25, 2012
  10. Michael G SchwernJul 25, 2012
  11. Junio C HamanoJul 25, 2012
  12. Michael G SchwernJul 25, 2012
  13. Junio C HamanoJul 25, 2012
  14. Michael G SchwernJul 25, 2012
  15. Junio C HamanoJul 25, 2012
  16. Eric WongJul 25, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.