Re: Detecting a module to be used by Makefile.PL

[email protected] (Michael G Schwern)
Newsgroups perl.makemaker
Message-ID <[email protected]>
Alberto Simões wrote:
> Adriano Ferreira wrote:
>> On Tue, Mar 18, 2008 at 12:37 PM, Alberto Simões
>> <[email protected]> wrote:
>>> Hi
>>>
>>>  I need to use a non-core, non-standard module on a Makefile.PL.
>>>
>>>   - I would like to abort Makefile.PL run if it is not installed;
>>>   - I would like it to be installed if being run inside CPAN;
>>>
>>>  Hints?
>>
>> Very recent versions of CPAN has support for 'configure_requires',
>> which looks like the right way to do that.
> 
> Hmms... that might be a solution when installing the module through 
> CPAN. But if the user runs Makefile.PL manually she will get a Can't 
> locate module message.
> 
> Not yet the thing I would love.

The "Can't locate module" message would seem to indicate exactly what's wrong 
and clearly suggests what needs to be done to fix it.  If they're installing 
by hand they're used to resolving dependencies by hand anyway.

If it's not a good enough message, make a better one.  Makefile.PL is just a 
program.  Unlike require dependencies, it's ok to die if you're missing 
configuration dependencies because your Makefile.PL would have done that anyway.

	my @missing_deps;
	for my $module (@configure_dependencies) {
		unless( eval qq{require $module} ) {
			push @missing_deps, $module
		}
	}

	die "Makefile.PL requires @{[ join ',', @missing_deps ]}.\n"
		if @missing_deps;


--
54. “Napalm sticks to kids” is *not* a motivational phrase.
     -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
            http://skippyslist.com/list/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.