1ExtUtils::MM_Any(3pm)  Perl Programmers Reference Guide  ExtUtils::MM_Any(3pm)
2
3
4

NAME

6       ExtUtils::MM_Any - Platform-agnostic MM methods
7

SYNOPSIS

9         FOR INTERNAL USE ONLY!
10
11         package ExtUtils::MM_SomeOS;
12
13         # Temporarily, you have to subclass both.  Put MM_Any first.
14         require ExtUtils::MM_Any;
15         require ExtUtils::MM_Unix;
16         @ISA = qw(ExtUtils::MM_Any ExtUtils::Unix);
17

DESCRIPTION

19       FOR INTERNAL USE ONLY!
20
21       ExtUtils::MM_Any is a superclass for the ExtUtils::MM_* set of modules.
22       It contains methods which are either inherently cross-platform or are
23       written in a cross-platform manner.
24
25       Subclass off of ExtUtils::MM_Any and ExtUtils::MM_Unix.  This is a tem‐
26       porary solution.
27
28       THIS MAY BE TEMPORARY!
29

METHODS

31       Any methods marked Abstract must be implemented by subclasses.
32
33       Cross-platform helper methods
34
35       These are methods which help writing cross-platform code.
36
37       os_flavor  Abstract
38
39           my @os_flavor = $mm->os_flavor;
40
41       @os_flavor is the style of operating system this is, usually corre‐
42       sponding to the MM_*.pm file we're using.
43
44       The first element of @os_flavor is the major family (ie. Unix, Windows,
45       VMS, OS/2, etc...) and the rest are sub families.
46
47       Some examples:
48
49           Cygwin98       ('Unix',  'Cygwin', 'Cygwin9x')
50           Windows NT     ('Win32', 'WinNT')
51           Win98          ('Win32', 'Win9x')
52           Linux          ('Unix',  'Linux')
53           MacOS X        ('Unix',  'Darwin', 'MacOS', 'MacOS X')
54           OS/2           ('OS/2')
55
56       This is used to write code for styles of operating system.  See os_fla‐
57       vor_is() for use.
58
59       os_flavor_is
60
61           my $is_this_flavor = $mm->os_flavor_is($this_flavor);
62           my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);
63
64       Checks to see if the current operating system is one of the given fla‐
65       vors.
66
67       This is useful for code like:
68
69           if( $mm->os_flavor_is('Unix') ) {
70               $out = `foo 2>&1`;
71           }
72           else {
73               $out = `foo`;
74           }
75
76       split_command
77
78           my @cmds = $MM->split_command($cmd, @args);
79
80       Most OS have a maximum command length they can execute at once.  Large
81       modules can easily generate commands well past that limit.  Its neces‐
82       sary to split long commands up into a series of shorter commands.
83
84       "split_command" will return a series of @cmds each processing part of
85       the args.  Collectively they will process all the arguments.  Each
86       individual line in @cmds will not be longer than the
87       $self->max_exec_len being careful to take into account macro expansion.
88
89       $cmd should include any switches and repeated initial arguments.
90
91       If no @args are given, no @cmds will be returned.
92
93       Pairs of arguments will always be preserved in a single command, this
94       is a heuristic for things like pm_to_blib and pod2man which work on
95       pairs of arguments.  This makes things like this safe:
96
97           $self->split_command($cmd, %pod2man);
98
99       echo
100
101           my @commands = $MM->echo($text);
102           my @commands = $MM->echo($text, $file);
103           my @commands = $MM->echo($text, $file, $appending);
104
105       Generates a set of @commands which print the $text to a $file.
106
107       If $file is not given, output goes to STDOUT.
108
109       If $appending is true the $file will be appended to rather than over‐
110       written.
111
112       wraplist
113
114         my $args = $mm->wraplist(@list);
115
116       Takes an array of items and turns them into a well-formatted list of
117       arguments.  In most cases this is simply something like:
118
119           FOO \
120           BAR \
121           BAZ
122
123       cd  Abstract
124
125         my $subdir_cmd = $MM->cd($subdir, @cmds);
126
127       This will generate a make fragment which runs the @cmds in the given
128       $dir.  The rough equivalent to this, except cross platform.
129
130         cd $subdir && $cmd
131
132       Currently $dir can only go down one level.  "foo" is fine.  "foo/bar"
133       is not.  "../foo" is right out.
134
135       The resulting $subdir_cmd has no leading tab nor trailing newline.
136       This makes it easier to embed in a make string.  For example.
137
138             my $make = sprintf <<'CODE', $subdir_cmd;
139         foo :
140             $(ECHO) what
141             %s
142             $(ECHO) mouche
143         CODE
144
145       oneliner  Abstract
146
147         my $oneliner = $MM->oneliner($perl_code);
148         my $oneliner = $MM->oneliner($perl_code, \@switches);
149
150       This will generate a perl one-liner safe for the particular platform
151       you're on based on the given $perl_code and @switches (a -e is assumed)
152       suitable for using in a make target.  It will use the proper shell
153       quoting and escapes.
154
155       $(PERLRUN) will be used as perl.
156
157       Any newlines in $perl_code will be escaped.  Leading and trailing new‐
158       lines will be stripped.  Makes this idiom much easier:
159
160           my $code = $MM->oneliner(<<'CODE', [...switches...]);
161       some code here
162       another line here
163       CODE
164
165       Usage might be something like:
166
167           # an echo emulation
168           $oneliner = $MM->oneliner('print "Foo\n"');
169           $make = '$oneliner > somefile';
170
171       All dollar signs must be doubled in the $perl_code if you expect them
172       to be interpreted normally, otherwise it will be considered a make
173       macro.  Also remember to quote make macros else it might be used as a
174       bareword.  For example:
175
176           # Assign the value of the $(VERSION_FROM) make macro to $vf.
177           $oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"');
178
179       Its currently very simple and may be expanded sometime in the figure to
180       include more flexible code and switches.
181
182       quote_literal  Abstract
183
184           my $safe_text = $MM->quote_literal($text);
185
186       This will quote $text so it is interpreted literally in the shell.
187
188       For example, on Unix this would escape any single-quotes in $text and
189       put single-quotes around the whole thing.
190
191       escape_newlines  Abstract
192
193           my $escaped_text = $MM->escape_newlines($text);
194
195       Shell escapes newlines in $text.
196
197       max_exec_len  Abstract
198
199           my $max_exec_len = $MM->max_exec_len;
200
201       Calculates the maximum command size the OS can exec.  Effectively, this
202       is the max size of a shell command line.
203
204       Targets
205
206       These are methods which produce make targets.
207
208       all_target
209
210       Generate the default target 'all'.
211
212       blibdirs_target
213
214           my $make_frag = $mm->blibdirs_target;
215
216       Creates the blibdirs target which creates all the directories we use in
217       blib/.
218
219       The blibdirs.ts target is deprecated.  Depend on blibdirs instead.
220
221       clean (o)
222
223       Defines the clean target.
224
225       clean_subdirs_target
226
227         my $make_frag = $MM->clean_subdirs_target;
228
229       Returns the clean_subdirs target.  This is used by the clean target to
230       call clean on any subdirectories which contain Makefiles.
231
232       dir_target
233
234           my $make_frag = $mm->dir_target(@directories);
235
236       Generates targets to create the specified directories and set its per‐
237       mission to 0755.
238
239       Because depending on a directory to just ensure it exists doesn't work
240       too well (the modified time changes too often) dir_target() creates a
241       .exists file in the created directory.  It is this you should depend
242       on.  For portability purposes you should use the $(DIRFILESEP) macro
243       rather than a '/' to seperate the directory from the file.
244
245           yourdirectory$(DIRFILESEP).exists
246
247       distdir
248
249       Defines the scratch directory target that will hold the distribution
250       before tar-ing (or shar-ing).
251
252       dist_test
253
254       Defines a target that produces the distribution in the scratchdirec‐
255       tory, and runs 'perl Makefile.PL; make ;make test' in that subdirec‐
256       tory.
257
258       dynamic (o)
259
260       Defines the dynamic target.
261
262       makemakerdflt_target
263
264         my $make_frag = $mm->makemakerdflt_target
265
266       Returns a make fragment with the makemakerdeflt_target specified.  This
267       target is the first target in the Makefile, is the default target and
268       simply points off to 'all' just in case any make variant gets confused
269       or something gets snuck in before the real 'all' target.
270
271       manifypods_target
272
273         my $manifypods_target = $self->manifypods_target;
274
275       Generates the manifypods target.  This target generates man pages from
276       all POD files in MAN1PODS and MAN3PODS.
277
278       metafile_target
279
280           my $target = $mm->metafile_target;
281
282       Generate the metafile target.
283
284       Writes the file META.yml YAML encoded meta-data about the module in the
285       distdir.  The format follows Module::Build's as closely as possible.
286       Additionally, we include:
287
288           version_from
289           installdirs
290
291       distmeta_target
292
293           my $make_frag = $mm->distmeta_target;
294
295       Generates the distmeta target to add META.yml to the MANIFEST in the
296       distdir.
297
298       realclean (o)
299
300       Defines the realclean target.
301
302       realclean_subdirs_target
303
304         my $make_frag = $MM->realclean_subdirs_target;
305
306       Returns the realclean_subdirs target.  This is used by the realclean
307       target to call realclean on any subdirectories which contain Makefiles.
308
309       signature_target
310
311           my $target = $mm->signature_target;
312
313       Generate the signature target.
314
315       Writes the file SIGNATURE with "cpansign -s".
316
317       distsignature_target
318
319           my $make_frag = $mm->distsignature_target;
320
321       Generates the distsignature target to add SIGNATURE to the MANIFEST in
322       the distdir.
323
324       special_targets
325
326         my $make_frag = $mm->special_targets
327
328       Returns a make fragment containing any targets which have special mean‐
329       ing to make.  For example, .SUFFIXES and .PHONY.
330
331       Init methods
332
333       Methods which help initialize the MakeMaker object and macros.
334
335       init_INST
336
337           $mm->init_INST;
338
339       Called by init_main.  Sets up all INST_* variables except those related
340       to XS code.  Those are handled in init_xs.
341
342       init_INSTALL
343
344           $mm->init_INSTALL;
345
346       Called by init_main.  Sets up all INSTALL_* variables (except
347       INSTALLDIRS) and *PREFIX.
348
349       init_INSTALL_from_PREFIX
350
351         $mm->init_INSTALL_from_PREFIX;
352
353       init_from_INSTALLBASE
354
355           $mm->init_from_INSTALLBASE
356
357       init_VERSION  Abstract
358
359           $mm->init_VERSION
360
361       Initialize macros representing versions of MakeMaker and other tools
362
363       MAKEMAKER: path to the MakeMaker module.
364
365       MM_VERSION: ExtUtils::MakeMaker Version
366
367       MM_REVISION: ExtUtils::MakeMaker version control revision (for back‐
368       wards
369                    compat)
370
371       VERSION: version of your module
372
373       VERSION_MACRO: which macro represents the version (usually 'VERSION')
374
375       VERSION_SYM: like version but safe for use as an RCS revision number
376
377       DEFINE_VERSION: -D line to set the module version when compiling
378
379       XS_VERSION: version in your .xs file.  Defaults to $(VERSION)
380
381       XS_VERSION_MACRO: which macro represents the XS version.
382
383       XS_DEFINE_VERSION: -D line to set the xs version when compiling.
384
385       Called by init_main.
386
387       init_others  Abstract
388
389           $MM->init_others();
390
391       Initializes the macro definitions used by tools_other() and places them
392       in the $MM object.
393
394       If there is no description, its the same as the parameter to WriteMake‐
395       file() documented in ExtUtils::MakeMaker.
396
397       Defines at least these macros.
398
399         Macro             Description
400
401         NOOP              Do nothing
402         NOECHO            Tell make not to display the command itself
403
404         MAKEFILE
405         FIRST_MAKEFILE
406         MAKEFILE_OLD
407         MAKE_APERL_FILE   File used by MAKE_APERL
408
409         SHELL             Program used to run
410                           shell commands
411
412         ECHO              Print text adding a newline on the end
413         RM_F              Remove a file
414         RM_RF             Remove a directory
415         TOUCH             Update a file's timestamp
416         TEST_F            Test for a file's existence
417         CP                Copy a file
418         MV                Move a file
419         CHMOD             Change permissions on a
420                           file
421
422         UMASK_NULL        Nullify umask
423         DEV_NULL          Supress all command output
424
425       init_DIRFILESEP  Abstract
426
427         $MM->init_DIRFILESEP;
428         my $dirfilesep = $MM->{DIRFILESEP};
429
430       Initializes the DIRFILESEP macro which is the seperator between the
431       directory and filename in a filepath.  ie. / on Unix, \ on Win32 and
432       nothing on VMS.
433
434       For example:
435
436           # instead of $(INST_ARCHAUTODIR)/extralibs.ld
437           $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
438
439       Something of a hack but it prevents a lot of code duplication between
440       MM_* variants.
441
442       Do not use this as a seperator between directories.  Some operating
443       systems use different seperators between subdirectories as between
444       directories and filenames (for example:  VOLUME:[dir1.dir2]file on
445       VMS).
446
447       init_linker  Abstract
448
449           $mm->init_linker;
450
451       Initialize macros which have to do with linking.
452
453       PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
454       extensions.
455
456       PERL_ARCHIVE_AFTER: path to a library which should be put on the linker
457       command line after the external libraries to be linked to dynamic
458       extensions.  This may be needed if the linker is one-pass, and Perl
459       includes some overrides for C RTL functions, such as malloc().
460
461       EXPORT_LIST: name of a file that is passed to linker to define symbols
462       to be exported.
463
464       Some OSes do not need these in which case leave it blank.
465
466       init_platform
467
468           $mm->init_platform
469
470       Initialize any macros which are for platform specific use only.
471
472       A typical one is the version number of your OS specific mocule.  (ie.
473       MM_Unix_VERSION or MM_VMS_VERSION).
474
475       Tools
476
477       A grab bag of methods to generate specific macros and commands.
478
479       manifypods
480
481       Defines targets and routines to translate the pods into manpages and
482       put them into the INST_* directories.
483
484       POD2MAN_macro
485
486         my $pod2man_macro = $self->POD2MAN_macro
487
488       Returns a definition for the POD2MAN macro.  This is a program which
489       emulates the pod2man utility.  You can add more switches to the command
490       by simply appending them on the macro.
491
492       Typical usage:
493
494           $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
495
496       test_via_harness
497
498         my $command = $mm->test_via_harness($perl, $tests);
499
500       Returns a $command line which runs the given set of $tests with
501       Test::Harness and the given $perl.
502
503       Used on the t/*.t files.
504
505       test_via_script
506
507         my $command = $mm->test_via_script($perl, $script);
508
509       Returns a $command line which just runs a single test without
510       Test::Harness.  No checks are done on the results, they're just
511       printed.
512
513       Used for test.pl, since they don't always follow Test::Harness format‐
514       ting.
515
516       tool_autosplit
517
518       Defines a simple perl call that runs autosplit. May be deprecated by
519       pm_to_blib soon.
520
521       File::Spec wrappers
522
523       ExtUtils::MM_Any is a subclass of File::Spec.  The methods noted here
524       override File::Spec.
525
526       catfile
527
528       File::Spec <= 0.83 has a bug where the file part of catfile is not
529       canonicalized.  This override fixes that bug.
530
531       Misc
532
533       Methods I can't really figure out where they should go yet.
534
535       find_tests
536
537         my $test = $mm->find_tests;
538
539       Returns a string suitable for feeding to the shell to return all tests
540       in t/*.t.
541
542       extra_clean_files
543
544           my @files_to_clean = $MM->extra_clean_files;
545
546       Returns a list of OS specific files to be removed in the clean target
547       in addition to the usual set.
548
549       installvars
550
551           my @installvars = $mm->installvars;
552
553       A list of all the INSTALL* variables without the INSTALL prefix.  Use‐
554       ful for iteration or building related variable sets.
555
556       libscan
557
558         my $wanted = $self->libscan($path);
559
560       Takes a path to a file or dir and returns an empty string if we don't
561       want to include this file in the library.  Otherwise it returns the the
562       $path unchanged.
563
564       Mainly used to exclude version control administrative directories from
565       installation.
566
567       platform_constants
568
569           my $make_frag = $mm->platform_constants
570
571       Returns a make fragment defining all the macros initialized in
572       init_platform() rather than put them in constants().
573

AUTHOR

575       Michael G Schwern <schwern@pobox.com> and the denizens of make‐
576       maker@perl.org with code from ExtUtils::MM_Unix and ExtUtils::MM_Win32.
577
578
579
580perl v5.8.8                       2001-09-21             ExtUtils::MM_Any(3pm)
Impressum