[EMAIL PROTECTED] (Michael G Schwern) wrote around 15 Nov 2002
[EMAIL PROTECTED]:">news:[EMAIL PROTECTED]:
> There is now a perl_oneliner() method which given some perl code and
> switches will generate a safe one liner. Overrides have been put in
> MM_Win32, MM_Unix and MM_VMS to do the escapes and quoting appropriate
> for that platform. After playing with it some, I added suport for
> newline escaping (which could probably be improved to use multiple
> -e's) and stripping of leading/trailing newlines.
{snip}
> The end result? Instead of this:
>
> return <<'MAKE_FRAG';
> dist : $(DEFAULT)
> $(NOECHO) $(PERL) -le "print 'Warning: Makefile possibly out
> of date with $(VERSION_FROM)' if -e '$(VERSION_FROM)' and -M
> '$(VERSION_FROM)' < -M '$(MAKEFILE)';"
> MAKE_FRAG
>
> you can do this:
>
> my $date_check = $self->perl_oneliner(<<'CODE', ['-l']);
> print 'Warning: Makefile possibly out of date with $(VERSION_FROM)'
> if -e '$(VERSION_FROM)' and -M '$(VERSION_FROM)' < -M '$(MAKEFILE)';
> CODE
>
> return sprintf <<'MAKE_FRAG', $date_check;
> dist : $(DEFAULT)
> $(NOECHO) %s
> MAKE_FRAG
>
> so the code formatting is natural and you don't have to worry about
> quoting.
>
>
> The end result in the Makefile is icky:
>
> dist : $(DIST_DEFAULT)
> $(NOECHO) $(PERLRUN) -l -e 'print '\''Warning: Makefile
> possibly out of
> date with $(VERSION_FROM)'\''\
> if -e '\''$(VERSION_FROM)'\'' and \
> -M '\''$(VERSION_FROM)'\'' < -M '\''$(MAKEFILE)'\'';'
>
> but its more important that the MakeMaker code is easy to maintain
> than the resulting Makefile.
>
>
> The real win is that with the ability to generate portable one-liners,
> a whole slew of duplicate method overrides in MM_VMS and MM_Win32 that
> are just there to change quoting from ' to " go away.
>
>
> So, if anyone has a little free time you can start running through the
> MM_Unix code and replacing ad-hoc one-liners with perl_oneliner()
> generated code.
This seems like a tremendous advance. Wonderful.
Soren A
--
# Advanced (or lunatic, depending on your pov) examples of Gmake use:
# || MakefileWorkshop: ||
# http://home.att.net/~perlspinr/makefiles/makefileworkshop.html
#########################################################