1ExtUtils::MM_Any(3)   User Contributed Perl Documentation  ExtUtils::MM_Any(3)
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
26       temporary 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       These are methods which help writing cross-platform code.
35
36       os_flavor  Abstract
37
38           my @os_flavor = $mm->os_flavor;
39
40       @os_flavor is the style of operating system this is, usually
41       corresponding to the MM_*.pm file we're using.
42
43       The first element of @os_flavor is the major family (ie. Unix, Windows,
44       VMS, OS/2, etc...) and the rest are sub families.
45
46       Some examples:
47
48           Cygwin98       ('Unix',  'Cygwin', 'Cygwin9x')
49           Windows        ('Win32')
50           Win98          ('Win32', 'Win9x')
51           Linux          ('Unix',  'Linux')
52           MacOS X        ('Unix',  'Darwin', 'MacOS', 'MacOS X')
53           OS/2           ('OS/2')
54
55       This is used to write code for styles of operating system.  See
56       os_flavor_is() for use.
57
58       os_flavor_is
59
60           my $is_this_flavor = $mm->os_flavor_is($this_flavor);
61           my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);
62
63       Checks to see if the current operating system is one of the given
64       flavors.
65
66       This is useful for code like:
67
68           if( $mm->os_flavor_is('Unix') ) {
69               $out = `foo 2>&1`;
70           }
71           else {
72               $out = `foo`;
73           }
74
75       can_load_xs
76
77           my $can_load_xs = $self->can_load_xs;
78
79       Returns true if we have the ability to load XS.
80
81       This is important because miniperl, used to build XS modules in the
82       core, can not load XS.
83
84       split_command
85
86           my @cmds = $MM->split_command($cmd, @args);
87
88       Most OS have a maximum command length they can execute at once.  Large
89       modules can easily generate commands well past that limit.  Its
90       necessary to split long commands up into a series of shorter commands.
91
92       "split_command" will return a series of @cmds each processing part of
93       the args.  Collectively they will process all the arguments.  Each
94       individual line in @cmds will not be longer than the
95       $self->max_exec_len being careful to take into account macro expansion.
96
97       $cmd should include any switches and repeated initial arguments.
98
99       If no @args are given, no @cmds will be returned.
100
101       Pairs of arguments will always be preserved in a single command, this
102       is a heuristic for things like pm_to_blib and pod2man which work on
103       pairs of arguments.  This makes things like this safe:
104
105           $self->split_command($cmd, %pod2man);
106
107       echo
108
109           my @commands = $MM->echo($text);
110           my @commands = $MM->echo($text, $file);
111           my @commands = $MM->echo($text, $file, \%opts);
112
113       Generates a set of @commands which print the $text to a $file.
114
115       If $file is not given, output goes to STDOUT.
116
117       If $opts{append} is true the $file will be appended to rather than
118       overwritten.  Default is to overwrite.
119
120       If $opts{allow_variables} is true, make variables of the form "$(...)"
121       will not be escaped.  Other "$" will.  Default is to escape all "$".
122
123       Example of use:
124
125           my $make = map "\t$_\n", $MM->echo($text, $file);
126
127       wraplist
128
129         my $args = $mm->wraplist(@list);
130
131       Takes an array of items and turns them into a well-formatted list of
132       arguments.  In most cases this is simply something like:
133
134           FOO \
135           BAR \
136           BAZ
137
138       maketext_filter
139
140           my $filter_make_text = $mm->maketext_filter($make_text);
141
142       The text of the Makefile is run through this method before writing to
143       disk.  It allows systems a chance to make portability fixes to the
144       Makefile.
145
146       By default it does nothing.
147
148       This method is protected and not intended to be called outside of
149       MakeMaker.
150
151       cd  Abstract
152
153         my $subdir_cmd = $MM->cd($subdir, @cmds);
154
155       This will generate a make fragment which runs the @cmds in the given
156       $dir.  The rough equivalent to this, except cross platform.
157
158         cd $subdir && $cmd
159
160       Currently $dir can only go down one level.  "foo" is fine.  "foo/bar"
161       is not.  "../foo" is right out.
162
163       The resulting $subdir_cmd has no leading tab nor trailing newline.
164       This makes it easier to embed in a make string.  For example.
165
166             my $make = sprintf <<'CODE', $subdir_cmd;
167         foo :
168             $(ECHO) what
169             %s
170             $(ECHO) mouche
171         CODE
172
173       oneliner  Abstract
174
175         my $oneliner = $MM->oneliner($perl_code);
176         my $oneliner = $MM->oneliner($perl_code, \@switches);
177
178       This will generate a perl one-liner safe for the particular platform
179       you're on based on the given $perl_code and @switches (a -e is assumed)
180       suitable for using in a make target.  It will use the proper shell
181       quoting and escapes.
182
183       $(PERLRUN) will be used as perl.
184
185       Any newlines in $perl_code will be escaped.  Leading and trailing
186       newlines will be stripped.  Makes this idiom much easier:
187
188           my $code = $MM->oneliner(<<'CODE', [...switches...]);
189       some code here
190       another line here
191       CODE
192
193       Usage might be something like:
194
195           # an echo emulation
196           $oneliner = $MM->oneliner('print "Foo\n"');
197           $make = '$oneliner > somefile';
198
199       All dollar signs must be doubled in the $perl_code if you expect them
200       to be interpreted normally, otherwise it will be considered a make
201       macro.  Also remember to quote make macros else it might be used as a
202       bareword.  For example:
203
204           # Assign the value of the $(VERSION_FROM) make macro to $vf.
205           $oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"');
206
207       Its currently very simple and may be expanded sometime in the figure to
208       include more flexible code and switches.
209
210       quote_literal  Abstract
211
212           my $safe_text = $MM->quote_literal($text);
213           my $safe_text = $MM->quote_literal($text, \%options);
214
215       This will quote $text so it is interpreted literally in the shell.
216
217       For example, on Unix this would escape any single-quotes in $text and
218       put single-quotes around the whole thing.
219
220       If $options{allow_variables} is true it will leave '$(FOO)' make
221       variables untouched.  If false they will be escaped like any other "$".
222       Defaults to true.
223
224       escape_dollarsigns
225
226           my $escaped_text = $MM->escape_dollarsigns($text);
227
228       Escapes stray "$" so they are not interpreted as make variables.
229
230       It lets by "$(...)".
231
232       escape_all_dollarsigns
233
234           my $escaped_text = $MM->escape_all_dollarsigns($text);
235
236       Escapes all "$" so they are not interpreted as make variables.
237
238       escape_newlines  Abstract
239
240           my $escaped_text = $MM->escape_newlines($text);
241
242       Shell escapes newlines in $text.
243
244       max_exec_len  Abstract
245
246           my $max_exec_len = $MM->max_exec_len;
247
248       Calculates the maximum command size the OS can exec.  Effectively, this
249       is the max size of a shell command line.
250
251       make
252
253           my $make = $MM->make;
254
255       Returns the make variant we're generating the Makefile for.  This
256       attempts to do some normalization on the information from %Config or
257       the user.
258
259   Targets
260       These are methods which produce make targets.
261
262       all_target
263
264       Generate the default target 'all'.
265
266       blibdirs_target
267
268           my $make_frag = $mm->blibdirs_target;
269
270       Creates the blibdirs target which creates all the directories we use in
271       blib/.
272
273       The blibdirs.ts target is deprecated.  Depend on blibdirs instead.
274
275       clean (o)
276
277       Defines the clean target.
278
279       clean_subdirs_target
280
281         my $make_frag = $MM->clean_subdirs_target;
282
283       Returns the clean_subdirs target.  This is used by the clean target to
284       call clean on any subdirectories which contain Makefiles.
285
286       dir_target
287
288           my $make_frag = $mm->dir_target(@directories);
289
290       Generates targets to create the specified directories and set its
291       permission to PERM_DIR.
292
293       Because depending on a directory to just ensure it exists doesn't work
294       too well (the modified time changes too often) dir_target() creates a
295       .exists file in the created directory.  It is this you should depend
296       on.  For portability purposes you should use the $(DIRFILESEP) macro
297       rather than a '/' to separate the directory from the file.
298
299           yourdirectory$(DIRFILESEP).exists
300
301       distdir
302
303       Defines the scratch directory target that will hold the distribution
304       before tar-ing (or shar-ing).
305
306       dist_test
307
308       Defines a target that produces the distribution in the scratch
309       directory, and runs 'perl Makefile.PL; make ;make test' in that
310       subdirectory.
311
312       dynamic (o)
313
314       Defines the dynamic target.
315
316       makemakerdflt_target
317
318         my $make_frag = $mm->makemakerdflt_target
319
320       Returns a make fragment with the makemakerdeflt_target specified.  This
321       target is the first target in the Makefile, is the default target and
322       simply points off to 'all' just in case any make variant gets confused
323       or something gets snuck in before the real 'all' target.
324
325       manifypods_target
326
327         my $manifypods_target = $self->manifypods_target;
328
329       Generates the manifypods target.  This target generates man pages from
330       all POD files in MAN1PODS and MAN3PODS.
331
332       metafile_target
333
334           my $target = $mm->metafile_target;
335
336       Generate the metafile target.
337
338       Writes the file META.yml YAML encoded meta-data about the module in the
339       distdir.  The format follows Module::Build's as closely as possible.
340
341       metafile_data
342
343           my @metadata_pairs = $mm->metafile_data(\%meta_add, \%meta_merge);
344
345       Returns the data which MakeMaker turns into the META.yml file.
346
347       Values of %meta_add will overwrite any existing metadata in those keys.
348       %meta_merge will be merged with them.
349
350       metafile_file
351
352           my $meta_yml = $mm->metafile_file(@metadata_pairs);
353
354       Turns the @metadata_pairs into YAML.
355
356       This method does not implement a complete YAML dumper, being limited to
357       dump a hash with values which are strings, undef's or nested hashes and
358       arrays of strings. No quoting/escaping is done.
359
360       distmeta_target
361
362           my $make_frag = $mm->distmeta_target;
363
364       Generates the distmeta target to add META.yml to the MANIFEST in the
365       distdir.
366
367       mymeta
368
369           my $mymeta = $mm->mymeta;
370
371       Generate MYMETA information as a hash either from an existing META.yml
372       or from internal data.
373
374       write_mymeta
375
376           $self->write_mymeta( $mymeta );
377
378       Write MYMETA information to MYMETA.yml.
379
380       This will probably be refactored into a more generic YAML dumping
381       method.
382
383       realclean (o)
384
385       Defines the realclean target.
386
387       realclean_subdirs_target
388
389         my $make_frag = $MM->realclean_subdirs_target;
390
391       Returns the realclean_subdirs target.  This is used by the realclean
392       target to call realclean on any subdirectories which contain Makefiles.
393
394       signature_target
395
396           my $target = $mm->signature_target;
397
398       Generate the signature target.
399
400       Writes the file SIGNATURE with "cpansign -s".
401
402       distsignature_target
403
404           my $make_frag = $mm->distsignature_target;
405
406       Generates the distsignature target to add SIGNATURE to the MANIFEST in
407       the distdir.
408
409       special_targets
410
411         my $make_frag = $mm->special_targets
412
413       Returns a make fragment containing any targets which have special
414       meaning to make.  For example, .SUFFIXES and .PHONY.
415
416   Init methods
417       Methods which help initialize the MakeMaker object and macros.
418
419       init_ABSTRACT
420
421           $mm->init_ABSTRACT
422
423       init_INST
424
425           $mm->init_INST;
426
427       Called by init_main.  Sets up all INST_* variables except those related
428       to XS code.  Those are handled in init_xs.
429
430       init_INSTALL
431
432           $mm->init_INSTALL;
433
434       Called by init_main.  Sets up all INSTALL_* variables (except
435       INSTALLDIRS) and *PREFIX.
436
437       init_INSTALL_from_PREFIX
438
439         $mm->init_INSTALL_from_PREFIX;
440
441       init_from_INSTALL_BASE
442
443           $mm->init_from_INSTALL_BASE
444
445       init_VERSION  Abstract
446
447           $mm->init_VERSION
448
449       Initialize macros representing versions of MakeMaker and other tools
450
451       MAKEMAKER: path to the MakeMaker module.
452
453       MM_VERSION: ExtUtils::MakeMaker Version
454
455       MM_REVISION: ExtUtils::MakeMaker version control revision (for
456       backwards
457                    compat)
458
459       VERSION: version of your module
460
461       VERSION_MACRO: which macro represents the version (usually 'VERSION')
462
463       VERSION_SYM: like version but safe for use as an RCS revision number
464
465       DEFINE_VERSION: -D line to set the module version when compiling
466
467       XS_VERSION: version in your .xs file.  Defaults to $(VERSION)
468
469       XS_VERSION_MACRO: which macro represents the XS version.
470
471       XS_DEFINE_VERSION: -D line to set the xs version when compiling.
472
473       Called by init_main.
474
475       init_tools
476
477           $MM->init_tools();
478
479       Initializes the simple macro definitions used by tools_other() and
480       places them in the $MM object.  These use conservative cross platform
481       versions and should be overridden with platform specific versions for
482       performance.
483
484       Defines at least these macros.
485
486         Macro             Description
487
488         NOOP              Do nothing
489         NOECHO            Tell make not to display the command itself
490
491         SHELL             Program used to run shell commands
492
493         ECHO              Print text adding a newline on the end
494         RM_F              Remove a file
495         RM_RF             Remove a directory
496         TOUCH             Update a file's timestamp
497         TEST_F            Test for a file's existence
498         CP                Copy a file
499         MV                Move a file
500         CHMOD             Change permissions on a file
501         FALSE             Exit with non-zero
502         TRUE              Exit with zero
503
504         UMASK_NULL        Nullify umask
505         DEV_NULL          Suppress all command output
506
507       init_others
508
509           $MM->init_others();
510
511       Initializes the macro definitions having to do with compiling and
512       linking used by tools_other() and places them in the $MM object.
513
514       If there is no description, its the same as the parameter to
515       WriteMakefile() documented in ExtUtils::MakeMaker.
516
517       tools_other
518
519           my $make_frag = $MM->tools_other;
520
521       Returns a make fragment containing definitions for the macros
522       init_others() initializes.
523
524       init_DIRFILESEP  Abstract
525
526         $MM->init_DIRFILESEP;
527         my $dirfilesep = $MM->{DIRFILESEP};
528
529       Initializes the DIRFILESEP macro which is the separator between the
530       directory and filename in a filepath.  ie. / on Unix, \ on Win32 and
531       nothing on VMS.
532
533       For example:
534
535           # instead of $(INST_ARCHAUTODIR)/extralibs.ld
536           $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
537
538       Something of a hack but it prevents a lot of code duplication between
539       MM_* variants.
540
541       Do not use this as a separator between directories.  Some operating
542       systems use different separators between subdirectories as between
543       directories and filenames (for example:  VOLUME:[dir1.dir2]file on
544       VMS).
545
546       init_linker  Abstract
547
548           $mm->init_linker;
549
550       Initialize macros which have to do with linking.
551
552       PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
553       extensions.
554
555       PERL_ARCHIVE_AFTER: path to a library which should be put on the linker
556       command line after the external libraries to be linked to dynamic
557       extensions.  This may be needed if the linker is one-pass, and Perl
558       includes some overrides for C RTL functions, such as malloc().
559
560       EXPORT_LIST: name of a file that is passed to linker to define symbols
561       to be exported.
562
563       Some OSes do not need these in which case leave it blank.
564
565       init_platform
566
567           $mm->init_platform
568
569       Initialize any macros which are for platform specific use only.
570
571       A typical one is the version number of your OS specific module.  (ie.
572       MM_Unix_VERSION or MM_VMS_VERSION).
573
574       init_MAKE
575
576           $mm->init_MAKE
577
578       Initialize MAKE from either a MAKE environment variable or
579       $Config{make}.
580
581   Tools
582       A grab bag of methods to generate specific macros and commands.
583
584       manifypods
585
586       Defines targets and routines to translate the pods into manpages and
587       put them into the INST_* directories.
588
589       POD2MAN_macro
590
591         my $pod2man_macro = $self->POD2MAN_macro
592
593       Returns a definition for the POD2MAN macro.  This is a program which
594       emulates the pod2man utility.  You can add more switches to the command
595       by simply appending them on the macro.
596
597       Typical usage:
598
599           $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
600
601       test_via_harness
602
603         my $command = $mm->test_via_harness($perl, $tests);
604
605       Returns a $command line which runs the given set of $tests with
606       Test::Harness and the given $perl.
607
608       Used on the t/*.t files.
609
610       test_via_script
611
612         my $command = $mm->test_via_script($perl, $script);
613
614       Returns a $command line which just runs a single test without
615       Test::Harness.  No checks are done on the results, they're just
616       printed.
617
618       Used for test.pl, since they don't always follow Test::Harness
619       formatting.
620
621       tool_autosplit
622
623       Defines a simple perl call that runs autosplit. May be deprecated by
624       pm_to_blib soon.
625
626       arch_check
627
628           my $arch_ok = $mm->arch_check(
629               $INC{"Config.pm"},
630               File::Spec->catfile($Config{archlibexp}, "Config.pm")
631           );
632
633       A sanity check that what Perl thinks the architecture is and what
634       Config thinks the architecture is are the same.  If they're not it will
635       return false and show a diagnostic message.
636
637       When building Perl it will always return true, as nothing is installed
638       yet.
639
640       The interface is a bit odd because this is the result of a quick
641       refactoring.  Don't rely on it.
642
643   File::Spec wrappers
644       ExtUtils::MM_Any is a subclass of File::Spec.  The methods noted here
645       override File::Spec.
646
647       catfile
648
649       File::Spec <= 0.83 has a bug where the file part of catfile is not
650       canonicalized.  This override fixes that bug.
651
652   Misc
653       Methods I can't really figure out where they should go yet.
654
655       find_tests
656
657         my $test = $mm->find_tests;
658
659       Returns a string suitable for feeding to the shell to return all tests
660       in t/*.t.
661
662       extra_clean_files
663
664           my @files_to_clean = $MM->extra_clean_files;
665
666       Returns a list of OS specific files to be removed in the clean target
667       in addition to the usual set.
668
669       installvars
670
671           my @installvars = $mm->installvars;
672
673       A list of all the INSTALL* variables without the INSTALL prefix.
674       Useful for iteration or building related variable sets.
675
676       libscan
677
678         my $wanted = $self->libscan($path);
679
680       Takes a path to a file or dir and returns an empty string if we don't
681       want to include this file in the library.  Otherwise it returns the the
682       $path unchanged.
683
684       Mainly used to exclude version control administrative directories from
685       installation.
686
687       platform_constants
688
689           my $make_frag = $mm->platform_constants
690
691       Returns a make fragment defining all the macros initialized in
692       init_platform() rather than put them in constants().
693

AUTHOR

695       Michael G Schwern <schwern@pobox.com> and the denizens of
696       makemaker@perl.org with code from ExtUtils::MM_Unix and
697       ExtUtils::MM_Win32.
698
699
700
701perl v5.16.3                      2013-06-14               ExtUtils::MM_Any(3)
Impressum