Big change. constants(), the method which contains the big list of macros
and was repeated in almost all the MM_* modules, has been cleaned up and in
order to clean it up I had to change some things.
The goal was to eliminate the redundant code in constants() in each of the
MM_* modules.
I started with the easiest, MM_Win32. It turns out it was only doing two
things differently than MM_Unix. \ instead of / in filepaths and added a
..USESHELL special target for dmake. Everything else was exactly the same.
MM_NW5->constants did what MM_Win32's did and added a bunch of Netware
specific macros.
MM_MacOS added a bunch of MacPerl specific macros, tweaked some existing
macros to eliminate gross Unixisms, added a special .INCLUDE target and
had an out of date macro name (MODULES instead of TO_INST_PM).
MM_VMS tweaked some existing macros, added some VMS specific ones,
and altered the definition of the .SUFFIXES special target.
So after looking at what all the overrides were *really* changing I came up
with this:
tweaking existing macro values
adding OS specific macros
adding special make targets
changing filepaths (/ to \).
added stuff outside of constants() to handle it (see below) and largely
eliminated constants().
The important things to note are:
Lots of code just got shuffled around. Be sure to sync up.
As much as possible, macros should be initialized in an init_* method.
Its likely I broke something, especially since I don't have any non-Unix
machines to test with at the moment.
Looking at each in turn:
Tweaking macros
---------------
Most macro values are initialized in an init_* method and placed into
$self->{SOME_MACRO}. This means you can override the value by overriding
just the init_* method and with something as simple as:
sub init_foo {
my $self = shift;
$self->SUPER::init_foo;
$self->{SOMETHING} = 'something else';
}
and some method later on will actually print out that macro.
Some of the stuff in constants() didn't do this. Instead, the value was
figured out inside constants(). So the only way to change the value was to
override all of constants.
Solution? Make sure all the macros in constants() are initialized in init_*
methods. Rather than piling this into the already crowded init_* methods,
I've added init_VERSION, init_DIRFILESEP, init_linker and init_platform.
Adding OS specific macros
-------------------------
Since the list of macros to print out in constants() was hard-coded, it was
necessary to override it to change what keys of $self got printed out as
macros. This made it difficult to add new macros which are used just
for a single platform.
As a solution I've added a seperate pair of methods to initialize and
print out OS specific macros. init_platform and platform_constants.
Adding special make targets
---------------------------
constants() was printing out special make targets because often these make
targets are sensitive to the order they appear in the Makefile. So they
were thrown into constants() because it was run before any targets were
generated. They don't really belong there, so I added a new method,
special_targets() which is run early in the Makefile generation process and
simply prints out special targets like .SUFFIXES and .PHONY.
Changing filepaths (/ to \)
---------------------------
There's lots of code in MakeMaker which is duplicated merely to change / to
\ or to VMS style filepaths. Some of it can be eliminated by File::Spec,
but some can't or its prohibitively annoying.
Fortunately, most of these locations are $(SOME_DIRECTORY)/$(SOME_FILE) and
in this case we can get away with a simple hack. A $(DIRFILESEP) macro
representing the seperator between the directory part and file part of a
filepath. ie. / for Unix, \ for Windows, : for MacOS and nothing for VMS.
Normally its not safe to assume that the directory seperator is the same as
the file seperator and that you can just shove two filepaths together and
get something valid. On Unix you can take 'foo/bar' and 'baz/yar' put a /
between them and get 'foo/bar/baz/yar' but it doesn't work that way on VMS.
'[foo.bar]' and '[baz.yar]'. There's no simple way to append them. The
proper concatenation is '[foo.bar.baz.yar]'. But you can safely stick a
filename on the end of a directory. 'foo/bar' plus 'moo.txt' gives
'foo/bar/moo.txt' '[foo.bar]' plus 'moo.txt' gives '[foo.bar]moo.txt' which
is valid.
So the $(DIRFILESEP) macro is a simple hack to allow things like:
'$(INST_LIB)$(DIRFILESEP).exists' to generate the .exists file.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
That which stirs me, stirs everything.
-- Squonk Opera, "Spoon"