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