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       can_run
85
86         use ExtUtils::MM;
87         my $runnable = MM->can_run($Config{make});
88
89       If called in a scalar context it will return the full path to the
90       binary you asked for if it was found, or "undef" if it was not.
91
92       If called in a list context, it will return a list of the full paths to
93       instances of the binary where found in "PATH", or an empty list if it
94       was not found.
95
96       Copied from IPC::Cmd, but modified into a method (and removed
97       $INSTANCES capability).
98
99       can_redirect_error
100
101         $useredirect = MM->can_redirect_error;
102
103       True if on an OS where qx operator (or backticks) can redirect "STDERR"
104       onto "STDOUT".
105
106       is_make_type
107
108           my $is_dmake = $self->is_make_type('dmake');
109
110       Returns true if "$self->make" is the given type; possibilities are:
111
112         gmake    GNU make
113         dmake
114         nmake
115         bsdmake  BSD pmake-derived
116
117       can_dep_space
118
119           my $can_dep_space = $self->can_dep_space;
120
121       Returns true if "make" can handle (probably by quoting) dependencies
122       that contain a space. Currently known true for GNU make, false for BSD
123       pmake derivative.
124
125       quote_dep
126
127         $text = $mm->quote_dep($text);
128
129       Method that protects Makefile single-value constants (mainly
130       filenames), so that make will still treat them as single values even if
131       they inconveniently have spaces in. If the make program being used
132       cannot achieve such protection and the given text would need it, throws
133       an exception.
134
135       split_command
136
137           my @cmds = $MM->split_command($cmd, @args);
138
139       Most OS have a maximum command length they can execute at once.  Large
140       modules can easily generate commands well past that limit.  Its
141       necessary to split long commands up into a series of shorter commands.
142
143       "split_command" will return a series of @cmds each processing part of
144       the args.  Collectively they will process all the arguments.  Each
145       individual line in @cmds will not be longer than the
146       $self->max_exec_len being careful to take into account macro expansion.
147
148       $cmd should include any switches and repeated initial arguments.
149
150       If no @args are given, no @cmds will be returned.
151
152       Pairs of arguments will always be preserved in a single command, this
153       is a heuristic for things like pm_to_blib and pod2man which work on
154       pairs of arguments.  This makes things like this safe:
155
156           $self->split_command($cmd, %pod2man);
157
158       make_type
159
160       Returns a suitable string describing the type of makefile being
161       written.
162
163       stashmeta
164
165           my @recipelines = $MM->stashmeta($text, $file);
166
167       Generates a set of @recipelines which will result in the literal $text
168       ending up in literal $file when the recipe is executed. Call it once,
169       with all the text you want in $file. Make macros will not be expanded,
170       so the locations will be fixed at configure-time, not at build-time.
171
172       echo
173
174           my @commands = $MM->echo($text);
175           my @commands = $MM->echo($text, $file);
176           my @commands = $MM->echo($text, $file, \%opts);
177
178       Generates a set of @commands which print the $text to a $file.
179
180       If $file is not given, output goes to STDOUT.
181
182       If $opts{append} is true the $file will be appended to rather than
183       overwritten.  Default is to overwrite.
184
185       If $opts{allow_variables} is true, make variables of the form "$(...)"
186       will not be escaped.  Other "$" will.  Default is to escape all "$".
187
188       Example of use:
189
190           my $make = join '', map "\t$_\n", $MM->echo($text, $file);
191
192       wraplist
193
194         my $args = $mm->wraplist(@list);
195
196       Takes an array of items and turns them into a well-formatted list of
197       arguments.  In most cases this is simply something like:
198
199           FOO \
200           BAR \
201           BAZ
202
203       maketext_filter
204
205           my $filter_make_text = $mm->maketext_filter($make_text);
206
207       The text of the Makefile is run through this method before writing to
208       disk.  It allows systems a chance to make portability fixes to the
209       Makefile.
210
211       By default it does nothing.
212
213       This method is protected and not intended to be called outside of
214       MakeMaker.
215
216       cd  Abstract
217
218         my $subdir_cmd = $MM->cd($subdir, @cmds);
219
220       This will generate a make fragment which runs the @cmds in the given
221       $dir.  The rough equivalent to this, except cross platform.
222
223         cd $subdir && $cmd
224
225       Currently $dir can only go down one level.  "foo" is fine.  "foo/bar"
226       is not.  "../foo" is right out.
227
228       The resulting $subdir_cmd has no leading tab nor trailing newline.
229       This makes it easier to embed in a make string.  For example.
230
231             my $make = sprintf <<'CODE', $subdir_cmd;
232         foo :
233             $(ECHO) what
234             %s
235             $(ECHO) mouche
236         CODE
237
238       oneliner  Abstract
239
240         my $oneliner = $MM->oneliner($perl_code);
241         my $oneliner = $MM->oneliner($perl_code, \@switches);
242
243       This will generate a perl one-liner safe for the particular platform
244       you're on based on the given $perl_code and @switches (a -e is assumed)
245       suitable for using in a make target.  It will use the proper shell
246       quoting and escapes.
247
248       $(PERLRUN) will be used as perl.
249
250       Any newlines in $perl_code will be escaped.  Leading and trailing
251       newlines will be stripped.  Makes this idiom much easier:
252
253           my $code = $MM->oneliner(<<'CODE', [...switches...]);
254       some code here
255       another line here
256       CODE
257
258       Usage might be something like:
259
260           # an echo emulation
261           $oneliner = $MM->oneliner('print "Foo\n"');
262           $make = '$oneliner > somefile';
263
264       Dollar signs in the $perl_code will be protected from make using the
265       "quote_literal" method, unless they are recognised as being a make
266       variable, "$(varname)", in which case they will be left for make to
267       expand. Remember to quote make macros else it might be used as a
268       bareword. For example:
269
270           # Assign the value of the $(VERSION_FROM) make macro to $vf.
271           $oneliner = $MM->oneliner('$vf = "$(VERSION_FROM)"');
272
273       Its currently very simple and may be expanded sometime in the figure to
274       include more flexible code and switches.
275
276       quote_literal  Abstract
277
278           my $safe_text = $MM->quote_literal($text);
279           my $safe_text = $MM->quote_literal($text, \%options);
280
281       This will quote $text so it is interpreted literally in the shell.
282
283       For example, on Unix this would escape any single-quotes in $text and
284       put single-quotes around the whole thing.
285
286       If $options{allow_variables} is true it will leave '$(FOO)' make
287       variables untouched.  If false they will be escaped like any other "$".
288       Defaults to true.
289
290       escape_dollarsigns
291
292           my $escaped_text = $MM->escape_dollarsigns($text);
293
294       Escapes stray "$" so they are not interpreted as make variables.
295
296       It lets by "$(...)".
297
298       escape_all_dollarsigns
299
300           my $escaped_text = $MM->escape_all_dollarsigns($text);
301
302       Escapes all "$" so they are not interpreted as make variables.
303
304       escape_newlines  Abstract
305
306           my $escaped_text = $MM->escape_newlines($text);
307
308       Shell escapes newlines in $text.
309
310       max_exec_len  Abstract
311
312           my $max_exec_len = $MM->max_exec_len;
313
314       Calculates the maximum command size the OS can exec.  Effectively, this
315       is the max size of a shell command line.
316
317       make
318
319           my $make = $MM->make;
320
321       Returns the make variant we're generating the Makefile for.  This
322       attempts to do some normalization on the information from %Config or
323       the user.
324
325   Targets
326       These are methods which produce make targets.
327
328       all_target
329
330       Generate the default target 'all'.
331
332       blibdirs_target
333
334           my $make_frag = $mm->blibdirs_target;
335
336       Creates the blibdirs target which creates all the directories we use in
337       blib/.
338
339       The blibdirs.ts target is deprecated.  Depend on blibdirs instead.
340
341       clean (o)
342
343       Defines the clean target.
344
345       clean_subdirs_target
346
347         my $make_frag = $MM->clean_subdirs_target;
348
349       Returns the clean_subdirs target.  This is used by the clean target to
350       call clean on any subdirectories which contain Makefiles.
351
352       dir_target
353
354           my $make_frag = $mm->dir_target(@directories);
355
356       Generates targets to create the specified directories and set its
357       permission to PERM_DIR.
358
359       Because depending on a directory to just ensure it exists doesn't work
360       too well (the modified time changes too often) dir_target() creates a
361       .exists file in the created directory.  It is this you should depend
362       on.  For portability purposes you should use the $(DIRFILESEP) macro
363       rather than a '/' to separate the directory from the file.
364
365           yourdirectory$(DIRFILESEP).exists
366
367       distdir
368
369       Defines the scratch directory target that will hold the distribution
370       before tar-ing (or shar-ing).
371
372       dist_test
373
374       Defines a target that produces the distribution in the scratch
375       directory, and runs 'perl Makefile.PL; make ;make test' in that
376       subdirectory.
377
378       xs_dlsyms_arg
379
380       Returns command-line arg(s) to linker for file listing dlsyms to
381       export.  Defaults to returning empty string, can be overridden by e.g.
382       AIX.
383
384       xs_dlsyms_ext
385
386       Returns file-extension for "xs_make_dlsyms" method's output file,
387       including any "." character.
388
389       xs_dlsyms_extra
390
391       Returns any extra text to be prepended to the $extra argument of
392       "xs_make_dlsyms".
393
394       xs_dlsyms_iterator
395
396       Iterates over necessary shared objects, calling "xs_make_dlsyms" method
397       for each with appropriate arguments.
398
399       xs_make_dlsyms
400
401           $self->xs_make_dlsyms(
402               \%attribs, # hashref from %attribs in caller
403               "$self->{BASEEXT}.def", # output file for Makefile target
404               'Makefile.PL', # dependency
405               $self->{NAME}, # shared object's "name"
406               $self->{DLBASE}, # last ::-separated part of name
407               $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}, # various params
408               $attribs{FUNCLIST} || $self->{FUNCLIST} || [],
409               $attribs{IMPORTS} || $self->{IMPORTS} || {},
410               $attribs{DL_VARS} || $self->{DL_VARS} || [],
411               # optional extra param that will be added as param to Mksymlists
412           );
413
414       Utility method that returns Makefile snippet to call "Mksymlists".
415
416       dynamic (o)
417
418       Defines the dynamic target.
419
420       makemakerdflt_target
421
422         my $make_frag = $mm->makemakerdflt_target
423
424       Returns a make fragment with the makemakerdeflt_target specified.  This
425       target is the first target in the Makefile, is the default target and
426       simply points off to 'all' just in case any make variant gets confused
427       or something gets snuck in before the real 'all' target.
428
429       manifypods_target
430
431         my $manifypods_target = $self->manifypods_target;
432
433       Generates the manifypods target.  This target generates man pages from
434       all POD files in MAN1PODS and MAN3PODS.
435
436       metafile_target
437
438           my $target = $mm->metafile_target;
439
440       Generate the metafile target.
441
442       Writes the file META.yml (YAML encoded meta-data) and META.json (JSON
443       encoded meta-data) about the module in the distdir.  The format follows
444       Module::Build's as closely as possible.
445
446       metafile_data
447
448           my $metadata_hashref = $mm->metafile_data(\%meta_add, \%meta_merge);
449
450       Returns the data which MakeMaker turns into the META.yml file and the
451       META.json file. It is always in version 2.0 of the format.
452
453       Values of %meta_add will overwrite any existing metadata in those keys.
454       %meta_merge will be merged with them.
455
456       metafile_file
457
458           my $meta_yml = $mm->metafile_file(@metadata_pairs);
459
460       Turns the @metadata_pairs into YAML.
461
462       This method does not implement a complete YAML dumper, being limited to
463       dump a hash with values which are strings, undef's or nested hashes and
464       arrays of strings. No quoting/escaping is done.
465
466       distmeta_target
467
468           my $make_frag = $mm->distmeta_target;
469
470       Generates the distmeta target to add META.yml and META.json to the
471       MANIFEST in the distdir.
472
473       mymeta
474
475           my $mymeta = $mm->mymeta;
476
477       Generate MYMETA information as a hash either from an existing CPAN Meta
478       file (META.json or META.yml) or from internal data.
479
480       write_mymeta
481
482           $self->write_mymeta( $mymeta );
483
484       Write MYMETA information to MYMETA.json and MYMETA.yml.
485
486       realclean (o)
487
488       Defines the realclean target.
489
490       realclean_subdirs_target
491
492         my $make_frag = $MM->realclean_subdirs_target;
493
494       Returns the realclean_subdirs target.  This is used by the realclean
495       target to call realclean on any subdirectories which contain Makefiles.
496
497       signature_target
498
499           my $target = $mm->signature_target;
500
501       Generate the signature target.
502
503       Writes the file SIGNATURE with "cpansign -s".
504
505       distsignature_target
506
507           my $make_frag = $mm->distsignature_target;
508
509       Generates the distsignature target to add SIGNATURE to the MANIFEST in
510       the distdir.
511
512       special_targets
513
514         my $make_frag = $mm->special_targets
515
516       Returns a make fragment containing any targets which have special
517       meaning to make.  For example, .SUFFIXES and .PHONY.
518
519   Init methods
520       Methods which help initialize the MakeMaker object and macros.
521
522       init_ABSTRACT
523
524           $mm->init_ABSTRACT
525
526       init_INST
527
528           $mm->init_INST;
529
530       Called by init_main.  Sets up all INST_* variables except those related
531       to XS code.  Those are handled in init_xs.
532
533       init_INSTALL
534
535           $mm->init_INSTALL;
536
537       Called by init_main.  Sets up all INSTALL_* variables (except
538       INSTALLDIRS) and *PREFIX.
539
540       init_INSTALL_from_PREFIX
541
542         $mm->init_INSTALL_from_PREFIX;
543
544       init_from_INSTALL_BASE
545
546           $mm->init_from_INSTALL_BASE
547
548       init_VERSION  Abstract
549
550           $mm->init_VERSION
551
552       Initialize macros representing versions of MakeMaker and other tools
553
554       MAKEMAKER: path to the MakeMaker module.
555
556       MM_VERSION: ExtUtils::MakeMaker Version
557
558       MM_REVISION: ExtUtils::MakeMaker version control revision (for
559       backwards
560                    compat)
561
562       VERSION: version of your module
563
564       VERSION_MACRO: which macro represents the version (usually 'VERSION')
565
566       VERSION_SYM: like version but safe for use as an RCS revision number
567
568       DEFINE_VERSION: -D line to set the module version when compiling
569
570       XS_VERSION: version in your .xs file.  Defaults to $(VERSION)
571
572       XS_VERSION_MACRO: which macro represents the XS version.
573
574       XS_DEFINE_VERSION: -D line to set the xs version when compiling.
575
576       Called by init_main.
577
578       init_tools
579
580           $MM->init_tools();
581
582       Initializes the simple macro definitions used by tools_other() and
583       places them in the $MM object.  These use conservative cross platform
584       versions and should be overridden with platform specific versions for
585       performance.
586
587       Defines at least these macros.
588
589         Macro             Description
590
591         NOOP              Do nothing
592         NOECHO            Tell make not to display the command itself
593
594         SHELL             Program used to run shell commands
595
596         ECHO              Print text adding a newline on the end
597         RM_F              Remove a file
598         RM_RF             Remove a directory
599         TOUCH             Update a file's timestamp
600         TEST_F            Test for a file's existence
601         TEST_S            Test the size of a file
602         CP                Copy a file
603         CP_NONEMPTY       Copy a file if it is not empty
604         MV                Move a file
605         CHMOD             Change permissions on a file
606         FALSE             Exit with non-zero
607         TRUE              Exit with zero
608
609         UMASK_NULL        Nullify umask
610         DEV_NULL          Suppress all command output
611
612       init_others
613
614           $MM->init_others();
615
616       Initializes the macro definitions having to do with compiling and
617       linking used by tools_other() and places them in the $MM object.
618
619       If there is no description, its the same as the parameter to
620       WriteMakefile() documented in ExtUtils::MakeMaker.
621
622       tools_other
623
624           my $make_frag = $MM->tools_other;
625
626       Returns a make fragment containing definitions for the macros
627       init_others() initializes.
628
629       init_DIRFILESEP  Abstract
630
631         $MM->init_DIRFILESEP;
632         my $dirfilesep = $MM->{DIRFILESEP};
633
634       Initializes the DIRFILESEP macro which is the separator between the
635       directory and filename in a filepath.  ie. / on Unix, \ on Win32 and
636       nothing on VMS.
637
638       For example:
639
640           # instead of $(INST_ARCHAUTODIR)/extralibs.ld
641           $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
642
643       Something of a hack but it prevents a lot of code duplication between
644       MM_* variants.
645
646       Do not use this as a separator between directories.  Some operating
647       systems use different separators between subdirectories as between
648       directories and filenames (for example:  VOLUME:[dir1.dir2]file on
649       VMS).
650
651       init_linker  Abstract
652
653           $mm->init_linker;
654
655       Initialize macros which have to do with linking.
656
657       PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
658       extensions.
659
660       PERL_ARCHIVE_AFTER: path to a library which should be put on the linker
661       command line after the external libraries to be linked to dynamic
662       extensions.  This may be needed if the linker is one-pass, and Perl
663       includes some overrides for C RTL functions, such as malloc().
664
665       EXPORT_LIST: name of a file that is passed to linker to define symbols
666       to be exported.
667
668       Some OSes do not need these in which case leave it blank.
669
670       init_platform
671
672           $mm->init_platform
673
674       Initialize any macros which are for platform specific use only.
675
676       A typical one is the version number of your OS specific module.  (ie.
677       MM_Unix_VERSION or MM_VMS_VERSION).
678
679       init_MAKE
680
681           $mm->init_MAKE
682
683       Initialize MAKE from either a MAKE environment variable or
684       $Config{make}.
685
686   Tools
687       A grab bag of methods to generate specific macros and commands.
688
689       manifypods
690
691       Defines targets and routines to translate the pods into manpages and
692       put them into the INST_* directories.
693
694       POD2MAN_macro
695
696         my $pod2man_macro = $self->POD2MAN_macro
697
698       Returns a definition for the POD2MAN macro.  This is a program which
699       emulates the pod2man utility.  You can add more switches to the command
700       by simply appending them on the macro.
701
702       Typical usage:
703
704           $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
705
706       test_via_harness
707
708         my $command = $mm->test_via_harness($perl, $tests);
709
710       Returns a $command line which runs the given set of $tests with
711       Test::Harness and the given $perl.
712
713       Used on the t/*.t files.
714
715       test_via_script
716
717         my $command = $mm->test_via_script($perl, $script);
718
719       Returns a $command line which just runs a single test without
720       Test::Harness.  No checks are done on the results, they're just
721       printed.
722
723       Used for test.pl, since they don't always follow Test::Harness
724       formatting.
725
726       tool_autosplit
727
728       Defines a simple perl call that runs autosplit. May be deprecated by
729       pm_to_blib soon.
730
731       arch_check
732
733           my $arch_ok = $mm->arch_check(
734               $INC{"Config.pm"},
735               File::Spec->catfile($Config{archlibexp}, "Config.pm")
736           );
737
738       A sanity check that what Perl thinks the architecture is and what
739       Config thinks the architecture is are the same.  If they're not it will
740       return false and show a diagnostic message.
741
742       When building Perl it will always return true, as nothing is installed
743       yet.
744
745       The interface is a bit odd because this is the result of a quick
746       refactoring.  Don't rely on it.
747
748   File::Spec wrappers
749       ExtUtils::MM_Any is a subclass of File::Spec.  The methods noted here
750       override File::Spec.
751
752       catfile
753
754       File::Spec <= 0.83 has a bug where the file part of catfile is not
755       canonicalized.  This override fixes that bug.
756
757   Misc
758       Methods I can't really figure out where they should go yet.
759
760       find_tests
761
762         my $test = $mm->find_tests;
763
764       Returns a string suitable for feeding to the shell to return all tests
765       in t/*.t.
766
767       find_tests_recursive
768
769         my $tests = $mm->find_tests_recursive;
770
771       Returns a string suitable for feeding to the shell to return all tests
772       in t/ but recursively. Equivalent to
773
774         my $tests = $mm->find_tests_recursive_in('t');
775
776       find_tests_recursive_in
777
778         my $tests = $mm->find_tests_recursive_in($dir);
779
780       Returns a string suitable for feeding to the shell to return all tests
781       in $dir recursively.
782
783       extra_clean_files
784
785           my @files_to_clean = $MM->extra_clean_files;
786
787       Returns a list of OS specific files to be removed in the clean target
788       in addition to the usual set.
789
790       installvars
791
792           my @installvars = $mm->installvars;
793
794       A list of all the INSTALL* variables without the INSTALL prefix.
795       Useful for iteration or building related variable sets.
796
797       libscan
798
799         my $wanted = $self->libscan($path);
800
801       Takes a path to a file or dir and returns an empty string if we don't
802       want to include this file in the library.  Otherwise it returns the the
803       $path unchanged.
804
805       Mainly used to exclude version control administrative directories and
806       base-level README.pod from installation.
807
808       platform_constants
809
810           my $make_frag = $mm->platform_constants
811
812       Returns a make fragment defining all the macros initialized in
813       init_platform() rather than put them in constants().
814
815       post_constants (o)
816
817       Returns an empty string per default. Dedicated to overrides from within
818       Makefile.PL after all constants have been defined.
819
820       post_initialize (o)
821
822       Returns an empty string per default. Used in Makefile.PLs to add some
823       chunk of text to the Makefile after the object is initialized.
824
825       postamble (o)
826
827       Returns an empty string. Can be used in Makefile.PLs to write some text
828       to the Makefile at the end.
829

AUTHOR

831       Michael G Schwern <schwern@pobox.com> and the denizens of
832       makemaker@perl.org with code from ExtUtils::MM_Unix and
833       ExtUtils::MM_Win32.
834
835
836
837perl v5.32.1                      2021-04-14               ExtUtils::MM_Any(3)
Impressum