Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2309 lines
72 KiB

  1. # MM_VMS.pm
  2. # MakeMaker default methods for VMS
  3. # This package is inserted into @ISA of MakeMaker's MM before the
  4. # built-in ExtUtils::MM_Unix methods if MakeMaker.pm is run under VMS.
  5. #
  6. # Author: Charles Bailey [email protected]
  7. package ExtUtils::MM_VMS;
  8. use Carp qw( &carp );
  9. use Config;
  10. require Exporter;
  11. use VMS::Filespec;
  12. use File::Basename;
  13. use File::Spec;
  14. our($Revision, @ISA);
  15. $Revision = '5.56 (27-Apr-1999)';
  16. @ISA = qw( File::Spec );
  17. unshift @MM::ISA, 'ExtUtils::MM_VMS';
  18. Exporter::import('ExtUtils::MakeMaker', '$Verbose', '&neatvalue');
  19. =head1 NAME
  20. ExtUtils::MM_VMS - methods to override UN*X behaviour in ExtUtils::MakeMaker
  21. =head1 SYNOPSIS
  22. use ExtUtils::MM_VMS; # Done internally by ExtUtils::MakeMaker if needed
  23. =head1 DESCRIPTION
  24. See ExtUtils::MM_Unix for a documentation of the methods provided
  25. there. This package overrides the implementation of these methods, not
  26. the semantics.
  27. =head2 Methods always loaded
  28. =over
  29. =item wraplist
  30. Converts a list into a string wrapped at approximately 80 columns.
  31. =cut
  32. sub wraplist {
  33. my($self) = shift;
  34. my($line,$hlen) = ('',0);
  35. my($word);
  36. foreach $word (@_) {
  37. # Perl bug -- seems to occasionally insert extra elements when
  38. # traversing array (scalar(@array) doesn't show them, but
  39. # foreach(@array) does) (5.00307)
  40. next unless $word =~ /\w/;
  41. $line .= ' ' if length($line);
  42. if ($hlen > 80) { $line .= "\\\n\t"; $hlen = 0; }
  43. $line .= $word;
  44. $hlen += length($word) + 2;
  45. }
  46. $line;
  47. }
  48. =item rootdir (override)
  49. Returns a string representing of the root directory.
  50. =cut
  51. sub rootdir {
  52. return '';
  53. }
  54. package ExtUtils::MM_VMS;
  55. sub ExtUtils::MM_VMS::ext;
  56. sub ExtUtils::MM_VMS::guess_name;
  57. sub ExtUtils::MM_VMS::find_perl;
  58. sub ExtUtils::MM_VMS::path;
  59. sub ExtUtils::MM_VMS::maybe_command;
  60. sub ExtUtils::MM_VMS::maybe_command_in_dirs;
  61. sub ExtUtils::MM_VMS::perl_script;
  62. sub ExtUtils::MM_VMS::file_name_is_absolute;
  63. sub ExtUtils::MM_VMS::replace_manpage_separator;
  64. sub ExtUtils::MM_VMS::init_others;
  65. sub ExtUtils::MM_VMS::constants;
  66. sub ExtUtils::MM_VMS::cflags;
  67. sub ExtUtils::MM_VMS::const_cccmd;
  68. sub ExtUtils::MM_VMS::pm_to_blib;
  69. sub ExtUtils::MM_VMS::tool_autosplit;
  70. sub ExtUtils::MM_VMS::tool_xsubpp;
  71. sub ExtUtils::MM_VMS::xsubpp_version;
  72. sub ExtUtils::MM_VMS::tools_other;
  73. sub ExtUtils::MM_VMS::dist;
  74. sub ExtUtils::MM_VMS::c_o;
  75. sub ExtUtils::MM_VMS::xs_c;
  76. sub ExtUtils::MM_VMS::xs_o;
  77. sub ExtUtils::MM_VMS::top_targets;
  78. sub ExtUtils::MM_VMS::dlsyms;
  79. sub ExtUtils::MM_VMS::dynamic_lib;
  80. sub ExtUtils::MM_VMS::dynamic_bs;
  81. sub ExtUtils::MM_VMS::static_lib;
  82. sub ExtUtils::MM_VMS::manifypods;
  83. sub ExtUtils::MM_VMS::processPL;
  84. sub ExtUtils::MM_VMS::installbin;
  85. sub ExtUtils::MM_VMS::subdir_x;
  86. sub ExtUtils::MM_VMS::clean;
  87. sub ExtUtils::MM_VMS::realclean;
  88. sub ExtUtils::MM_VMS::dist_basics;
  89. sub ExtUtils::MM_VMS::dist_core;
  90. sub ExtUtils::MM_VMS::dist_dir;
  91. sub ExtUtils::MM_VMS::dist_test;
  92. sub ExtUtils::MM_VMS::install;
  93. sub ExtUtils::MM_VMS::perldepend;
  94. sub ExtUtils::MM_VMS::makefile;
  95. sub ExtUtils::MM_VMS::test;
  96. sub ExtUtils::MM_VMS::test_via_harness;
  97. sub ExtUtils::MM_VMS::test_via_script;
  98. sub ExtUtils::MM_VMS::makeaperl;
  99. sub ExtUtils::MM_VMS::ext;
  100. sub ExtUtils::MM_VMS::nicetext;
  101. #use SelfLoader;
  102. sub AUTOLOAD {
  103. my $code;
  104. if (defined fileno(DATA)) {
  105. my $fh = select DATA;
  106. my $o = $/; # For future reads from the file.
  107. $/ = "\n__END__\n";
  108. $code = <DATA>;
  109. $/ = $o;
  110. select $fh;
  111. close DATA;
  112. eval $code;
  113. if ($@) {
  114. $@ =~ s/ at .*\n//;
  115. Carp::croak $@;
  116. }
  117. } else {
  118. warn "AUTOLOAD called unexpectedly for $AUTOLOAD";
  119. }
  120. defined(&$AUTOLOAD) or die "Myloader inconsistency error";
  121. goto &$AUTOLOAD;
  122. }
  123. 1;
  124. #__DATA__
  125. # This isn't really an override. It's just here because ExtUtils::MM_VMS
  126. # appears in @MM::ISA before ExtUtils::Liblist::Kid, so if there isn't an ext()
  127. # in MM_VMS, then AUTOLOAD is called, and bad things happen. So, we just
  128. # mimic inheritance here and hand off to ExtUtils::Liblist::Kid.
  129. sub ext {
  130. require ExtUtils::Liblist;
  131. ExtUtils::Liblist::Kid::ext(@_);
  132. }
  133. =back
  134. =head2 SelfLoaded methods
  135. Those methods which override default MM_Unix methods are marked
  136. "(override)", while methods unique to MM_VMS are marked "(specific)".
  137. For overridden methods, documentation is limited to an explanation
  138. of why this method overrides the MM_Unix method; see the ExtUtils::MM_Unix
  139. documentation for more details.
  140. =over
  141. =item guess_name (override)
  142. Try to determine name of extension being built. We begin with the name
  143. of the current directory. Since VMS filenames are case-insensitive,
  144. however, we look for a F<.pm> file whose name matches that of the current
  145. directory (presumably the 'main' F<.pm> file for this extension), and try
  146. to find a C<package> statement from which to obtain the Mixed::Case
  147. package name.
  148. =cut
  149. sub guess_name {
  150. my($self) = @_;
  151. my($defname,$defpm,@pm,%xs,$pm);
  152. local *PM;
  153. $defname = basename(fileify($ENV{'DEFAULT'}));
  154. $defname =~ s![\d\-_]*\.dir.*$!!; # Clip off .dir;1 suffix, and package version
  155. $defpm = $defname;
  156. # Fallback in case for some reason a user has copied the files for an
  157. # extension into a working directory whose name doesn't reflect the
  158. # extension's name. We'll use the name of a unique .pm file, or the
  159. # first .pm file with a matching .xs file.
  160. if (not -e "${defpm}.pm") {
  161. @pm = map { s/.pm$//; $_ } glob('*.pm');
  162. if (@pm == 1) { ($defpm = $pm[0]) =~ s/.pm$//; }
  163. elsif (@pm) {
  164. %xs = map { s/.xs$//; ($_,1) } glob('*.xs');
  165. if (%xs) { foreach $pm (@pm) { $defpm = $pm, last if exists $xs{$pm}; } }
  166. }
  167. }
  168. if (open(PM,"${defpm}.pm")){
  169. while (<PM>) {
  170. if (/^\s*package\s+([^;]+)/i) {
  171. $defname = $1;
  172. last;
  173. }
  174. }
  175. print STDOUT "Warning (non-fatal): Couldn't find package name in ${defpm}.pm;\n\t",
  176. "defaulting package name to $defname\n"
  177. if eof(PM);
  178. close PM;
  179. }
  180. else {
  181. print STDOUT "Warning (non-fatal): Couldn't find ${defpm}.pm;\n\t",
  182. "defaulting package name to $defname\n";
  183. }
  184. $defname =~ s#[\d.\-_]+$##;
  185. $defname;
  186. }
  187. =item find_perl (override)
  188. Use VMS file specification syntax and CLI commands to find and
  189. invoke Perl images.
  190. =cut
  191. sub find_perl {
  192. my($self, $ver, $names, $dirs, $trace) = @_;
  193. my($name,$dir,$vmsfile,@sdirs,@snames,@cand);
  194. my($rslt);
  195. my($inabs) = 0;
  196. local *TCF;
  197. # Check in relative directories first, so we pick up the current
  198. # version of Perl if we're running MakeMaker as part of the main build.
  199. @sdirs = sort { my($absa) = $self->file_name_is_absolute($a);
  200. my($absb) = $self->file_name_is_absolute($b);
  201. if ($absa && $absb) { return $a cmp $b }
  202. else { return $absa ? 1 : ($absb ? -1 : ($a cmp $b)); }
  203. } @$dirs;
  204. # Check miniperl before perl, and check names likely to contain
  205. # version numbers before "generic" names, so we pick up an
  206. # executable that's less likely to be from an old installation.
  207. @snames = sort { my($ba) = $a =~ m!([^:>\]/]+)$!; # basename
  208. my($bb) = $b =~ m!([^:>\]/]+)$!;
  209. my($ahasdir) = (length($a) - length($ba) > 0);
  210. my($bhasdir) = (length($b) - length($bb) > 0);
  211. if ($ahasdir and not $bhasdir) { return 1; }
  212. elsif ($bhasdir and not $ahasdir) { return -1; }
  213. else { $bb =~ /\d/ <=> $ba =~ /\d/
  214. or substr($ba,0,1) cmp substr($bb,0,1)
  215. or length($bb) <=> length($ba) } } @$names;
  216. # Image names containing Perl version use '_' instead of '.' under VMS
  217. foreach $name (@snames) { $name =~ s/\.(\d+)$/_$1/; }
  218. if ($trace >= 2){
  219. print "Looking for perl $ver by these names:\n";
  220. print "\t@snames,\n";
  221. print "in these dirs:\n";
  222. print "\t@sdirs\n";
  223. }
  224. foreach $dir (@sdirs){
  225. next unless defined $dir; # $self->{PERL_SRC} may be undefined
  226. $inabs++ if $self->file_name_is_absolute($dir);
  227. if ($inabs == 1) {
  228. # We've covered relative dirs; everything else is an absolute
  229. # dir (probably an installed location). First, we'll try potential
  230. # command names, to see whether we can avoid a long MCR expression.
  231. foreach $name (@snames) { push(@cand,$name) if $name =~ /^[\w\-\$]+$/; }
  232. $inabs++; # Should happen above in next $dir, but just in case . . .
  233. }
  234. foreach $name (@snames){
  235. if ($name !~ m![/:>\]]!) { push(@cand,$self->catfile($dir,$name)); }
  236. else { push(@cand,$self->fixpath($name,0)); }
  237. }
  238. }
  239. foreach $name (@cand) {
  240. print "Checking $name\n" if ($trace >= 2);
  241. # If it looks like a potential command, try it without the MCR
  242. if ($name =~ /^[\w\-\$]+$/) {
  243. open(TCF,">temp_mmvms.com") || die('unable to open temp file');
  244. print TCF "\$ set message/nofacil/nosever/noident/notext\n";
  245. print TCF "\$ $name -e \"require $ver; print \"\"VER_OK\\n\"\"\"\n";
  246. close TCF;
  247. $rslt = `\@temp_mmvms.com` ;
  248. unlink('temp_mmvms.com');
  249. if ($rslt =~ /VER_OK/) {
  250. print "Using PERL=$name\n" if $trace;
  251. return $name;
  252. }
  253. }
  254. next unless $vmsfile = $self->maybe_command($name);
  255. $vmsfile =~ s/;[\d\-]*$//; # Clip off version number; we can use a newer version as well
  256. print "Executing $vmsfile\n" if ($trace >= 2);
  257. open(TCF,">temp_mmvms.com") || die('unable to open temp file');
  258. print TCF "\$ set message/nofacil/nosever/noident/notext\n";
  259. print TCF "\$ mcr $vmsfile -e \"require $ver; print \"\"VER_OK\\n\"\"\" \n";
  260. close TCF;
  261. $rslt = `\@temp_mmvms.com`;
  262. unlink('temp_mmvms.com');
  263. if ($rslt =~ /VER_OK/) {
  264. print "Using PERL=MCR $vmsfile\n" if $trace;
  265. return "MCR $vmsfile";
  266. }
  267. }
  268. print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
  269. 0; # false and not empty
  270. }
  271. =item path (override)
  272. Translate logical name DCL$PATH as a searchlist, rather than trying
  273. to C<split> string value of C<$ENV{'PATH'}>.
  274. =cut
  275. sub path {
  276. my(@dirs,$dir,$i);
  277. while ($dir = $ENV{'DCL$PATH;' . $i++}) { push(@dirs,$dir); }
  278. @dirs;
  279. }
  280. =item maybe_command (override)
  281. Follows VMS naming conventions for executable files.
  282. If the name passed in doesn't exactly match an executable file,
  283. appends F<.Exe> (or equivalent) to check for executable image, and F<.Com>
  284. to check for DCL procedure. If this fails, checks directories in DCL$PATH
  285. and finally F<Sys$System:> for an executable file having the name specified,
  286. with or without the F<.Exe>-equivalent suffix.
  287. =cut
  288. sub maybe_command {
  289. my($self,$file) = @_;
  290. return $file if -x $file && ! -d _;
  291. my(@dirs) = ('');
  292. my(@exts) = ('',$Config{'exe_ext'},'.exe','.com');
  293. my($dir,$ext);
  294. if ($file !~ m![/:>\]]!) {
  295. for (my $i = 0; defined $ENV{"DCL\$PATH;$i"}; $i++) {
  296. $dir = $ENV{"DCL\$PATH;$i"};
  297. $dir .= ':' unless $dir =~ m%[\]:]$%;
  298. push(@dirs,$dir);
  299. }
  300. push(@dirs,'Sys$System:');
  301. foreach $dir (@dirs) {
  302. my $sysfile = "$dir$file";
  303. foreach $ext (@exts) {
  304. return $file if -x "$sysfile$ext" && ! -d _;
  305. }
  306. }
  307. }
  308. return 0;
  309. }
  310. =item maybe_command_in_dirs (override)
  311. Uses DCL argument quoting on test command line.
  312. =cut
  313. sub maybe_command_in_dirs { # $ver is optional argument if looking for perl
  314. my($self, $names, $dirs, $trace, $ver) = @_;
  315. my($name, $dir);
  316. foreach $dir (@$dirs){
  317. next unless defined $dir; # $self->{PERL_SRC} may be undefined
  318. foreach $name (@$names){
  319. my($abs,$tryabs);
  320. if ($self->file_name_is_absolute($name)) {
  321. $abs = $name;
  322. } else {
  323. $abs = $self->catfile($dir, $name);
  324. }
  325. print "Checking $abs for $name\n" if ($trace >= 2);
  326. next unless $tryabs = $self->maybe_command($abs);
  327. print "Substituting $tryabs instead of $abs\n"
  328. if ($trace >= 2 and $tryabs ne $abs);
  329. $abs = $tryabs;
  330. if (defined $ver) {
  331. print "Executing $abs\n" if ($trace >= 2);
  332. if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
  333. print "Using $abs\n" if $trace;
  334. return $abs;
  335. }
  336. } else { # Do not look for perl
  337. return $abs;
  338. }
  339. }
  340. }
  341. }
  342. =item perl_script (override)
  343. If name passed in doesn't specify a readable file, appends F<.com> or
  344. F<.pl> and tries again, since it's customary to have file types on all files
  345. under VMS.
  346. =cut
  347. sub perl_script {
  348. my($self,$file) = @_;
  349. return $file if -r $file && ! -d _;
  350. return "$file.com" if -r "$file.com";
  351. return "$file.pl" if -r "$file.pl";
  352. return '';
  353. }
  354. =item file_name_is_absolute (override)
  355. Checks for VMS directory spec as well as Unix separators.
  356. =cut
  357. sub file_name_is_absolute {
  358. my($self,$file) = @_;
  359. # If it's a logical name, expand it.
  360. $file = $ENV{$file} while $file =~ /^[\w\$\-]+$/ and $ENV{$file};
  361. $file =~ m!^/! or $file =~ m![<\[][^.\-\]>]! or $file =~ /:[^<\[]/;
  362. }
  363. =item replace_manpage_separator
  364. Use as separator a character which is legal in a VMS-syntax file name.
  365. =cut
  366. sub replace_manpage_separator {
  367. my($self,$man) = @_;
  368. $man = unixify($man);
  369. $man =~ s#/+#__#g;
  370. $man;
  371. }
  372. =item init_others (override)
  373. Provide VMS-specific forms of various utility commands, then hand
  374. off to the default MM_Unix method.
  375. =cut
  376. sub init_others {
  377. my($self) = @_;
  378. $self->{NOOP} = 'Continue';
  379. $self->{FIRST_MAKEFILE} ||= 'Descrip.MMS';
  380. $self->{MAKE_APERL_FILE} ||= 'Makeaperl.MMS';
  381. $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
  382. $self->{NOECHO} ||= '@ ';
  383. $self->{RM_F} = '$(PERL) -e "foreach (@ARGV) { 1 while ( -d $_ ? rmdir $_ : unlink $_)}"';
  384. $self->{RM_RF} = '$(PERL) "-I$(PERL_LIB)" -e "use File::Path; @dirs = map(VMS::Filespec::unixify($_),@ARGV); rmtree(\@dirs,0,0)"';
  385. $self->{TOUCH} = '$(PERL) -e "$t=time; foreach (@ARGV) { -e $_ ? utime($t,$t,@ARGV) : (open(F,qq(>$_)),close F)}"';
  386. $self->{CHMOD} = '$(PERL) -e "chmod @ARGV"'; # expect Unix syntax from MakeMaker
  387. $self->{CP} = 'Copy/NoConfirm';
  388. $self->{MV} = 'Rename/NoConfirm';
  389. $self->{UMASK_NULL} = '! ';
  390. &ExtUtils::MM_Unix::init_others;
  391. }
  392. =item constants (override)
  393. Fixes up numerous file and directory macros to insure VMS syntax
  394. regardless of input syntax. Also adds a few VMS-specific macros
  395. and makes lists of files comma-separated.
  396. =cut
  397. sub constants {
  398. my($self) = @_;
  399. my(@m,$def,$macro);
  400. # Be kind about case for pollution
  401. for (@ARGV) { $_ = uc($_) if /POLLUTE/i; }
  402. if ($self->{DEFINE} ne '') {
  403. my(@terms) = split(/\s+/,$self->{DEFINE});
  404. my(@defs,@udefs);
  405. foreach $def (@terms) {
  406. next unless $def;
  407. my $targ = \@defs;
  408. if ($def =~ s/^-([DU])//) { # If it was a Unix-style definition
  409. if ($1 eq 'U') { $targ = \@udefs; }
  410. $def =~ s/='(.*)'$/=$1/; # then remove shell-protection ''
  411. $def =~ s/^'(.*)'$/$1/; # from entire term or argument
  412. }
  413. if ($def =~ /=/) {
  414. $def =~ s/"/""/g; # Protect existing " from DCL
  415. $def = qq["$def"]; # and quote to prevent parsing of =
  416. }
  417. push @$targ, $def;
  418. }
  419. $self->{DEFINE} = '';
  420. if (@defs) { $self->{DEFINE} = '/Define=(' . join(',',@defs) . ')'; }
  421. if (@udefs) { $self->{DEFINE} .= '/Undef=(' . join(',',@udefs) . ')'; }
  422. }
  423. if ($self->{OBJECT} =~ /\s/) {
  424. $self->{OBJECT} =~ s/(\\)?\n+\s+/ /g;
  425. $self->{OBJECT} = $self->wraplist(map($self->fixpath($_,0),split(/,?\s+/,$self->{OBJECT})));
  426. }
  427. $self->{LDFROM} = $self->wraplist(map($self->fixpath($_,0),split(/,?\s+/,$self->{LDFROM})));
  428. # Fix up directory specs
  429. $self->{ROOTEXT} = $self->{ROOTEXT} ? $self->fixpath($self->{ROOTEXT},1)
  430. : '[]';
  431. foreach $macro ( qw [
  432. INST_BIN INST_SCRIPT INST_LIB INST_ARCHLIB INST_EXE INSTALLPRIVLIB
  433. INSTALLARCHLIB INSTALLSCRIPT INSTALLBIN PERL_LIB PERL_ARCHLIB
  434. PERL_INC PERL_SRC FULLEXT INST_MAN1DIR INSTALLMAN1DIR
  435. INST_MAN3DIR INSTALLMAN3DIR INSTALLSITELIB INSTALLSITEARCH
  436. SITELIBEXP SITEARCHEXP ] ) {
  437. next unless defined $self->{$macro};
  438. $self->{$macro} = $self->fixpath($self->{$macro},1);
  439. }
  440. $self->{PERL_VMS} = $self->catdir($self->{PERL_SRC},q(VMS))
  441. if ($self->{PERL_SRC});
  442. # Fix up file specs
  443. foreach $macro ( qw[LIBPERL_A FIRST_MAKEFILE MAKE_APERL_FILE MYEXTLIB] ) {
  444. next unless defined $self->{$macro};
  445. $self->{$macro} = $self->fixpath($self->{$macro},0);
  446. }
  447. foreach $macro (qw/
  448. AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION VERSION_SYM XS_VERSION
  449. INST_BIN INST_EXE INST_LIB INST_ARCHLIB INST_SCRIPT PREFIX
  450. INSTALLDIRS INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
  451. INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
  452. PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
  453. FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC PERL_VMS
  454. PERL_INC PERL FULLPERL
  455. / ) {
  456. next unless defined $self->{$macro};
  457. push @m, "$macro = $self->{$macro}\n";
  458. }
  459. push @m, q[
  460. VERSION_MACRO = VERSION
  461. DEFINE_VERSION = "$(VERSION_MACRO)=""$(VERSION)"""
  462. XS_VERSION_MACRO = XS_VERSION
  463. XS_DEFINE_VERSION = "$(XS_VERSION_MACRO)=""$(XS_VERSION)"""
  464. MAKEMAKER = ],$self->catfile($self->{PERL_LIB},'ExtUtils','MakeMaker.pm'),qq[
  465. MM_VERSION = $ExtUtils::MakeMaker::VERSION
  466. MM_REVISION = $ExtUtils::MakeMaker::Revision
  467. MM_VMS_REVISION = $ExtUtils::MM_VMS::Revision
  468. # FULLEXT = Pathname for extension directory (eg DBD/Oracle).
  469. # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  470. # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
  471. # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
  472. ];
  473. for $tmp (qw/
  474. FULLEXT VERSION_FROM OBJECT LDFROM
  475. / ) {
  476. next unless defined $self->{$tmp};
  477. push @m, "$tmp = ",$self->fixpath($self->{$tmp},0),"\n";
  478. }
  479. for $tmp (qw/
  480. BASEEXT PARENT_NAME DLBASE INC DEFINE LINKTYPE
  481. / ) {
  482. next unless defined $self->{$tmp};
  483. push @m, "$tmp = $self->{$tmp}\n";
  484. }
  485. for $tmp (qw/ XS MAN1PODS MAN3PODS PM /) {
  486. next unless defined $self->{$tmp};
  487. my(%tmp,$key);
  488. for $key (keys %{$self->{$tmp}}) {
  489. $tmp{$self->fixpath($key,0)} = $self->fixpath($self->{$tmp}{$key},0);
  490. }
  491. $self->{$tmp} = \%tmp;
  492. }
  493. for $tmp (qw/ C O_FILES H /) {
  494. next unless defined $self->{$tmp};
  495. my(@tmp,$val);
  496. for $val (@{$self->{$tmp}}) {
  497. push(@tmp,$self->fixpath($val,0));
  498. }
  499. $self->{$tmp} = \@tmp;
  500. }
  501. push @m,'
  502. # Handy lists of source code files:
  503. XS_FILES = ',$self->wraplist(sort keys %{$self->{XS}}),'
  504. C_FILES = ',$self->wraplist(@{$self->{C}}),'
  505. O_FILES = ',$self->wraplist(@{$self->{O_FILES}} ),'
  506. H_FILES = ',$self->wraplist(@{$self->{H}}),'
  507. MAN1PODS = ',$self->wraplist(sort keys %{$self->{MAN1PODS}}),'
  508. MAN3PODS = ',$self->wraplist(sort keys %{$self->{MAN3PODS}}),'
  509. ';
  510. for $tmp (qw/
  511. INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
  512. /) {
  513. next unless defined $self->{$tmp};
  514. push @m, "$tmp = $self->{$tmp}\n";
  515. }
  516. push @m,"
  517. .SUFFIXES :
  518. .SUFFIXES : \$(OBJ_EXT) .c .cpp .cxx .xs
  519. # Here is the Config.pm that we are using/depend on
  520. CONFIGDEP = \$(PERL_ARCHLIB)Config.pm, \$(PERL_INC)config.h \$(VERSION_FROM)
  521. # Where to put things:
  522. INST_LIBDIR = $self->{INST_LIBDIR}
  523. INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}
  524. INST_AUTODIR = $self->{INST_AUTODIR}
  525. INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}
  526. ";
  527. if ($self->has_link_code()) {
  528. push @m,'
  529. INST_STATIC = $(INST_ARCHAUTODIR)$(BASEEXT)$(LIB_EXT)
  530. INST_DYNAMIC = $(INST_ARCHAUTODIR)$(DLBASE).$(DLEXT)
  531. INST_BOOT = $(INST_ARCHAUTODIR)$(BASEEXT).bs
  532. ';
  533. } else {
  534. my $shr = $Config{'dbgprefix'} . 'PERLSHR';
  535. push @m,'
  536. INST_STATIC =
  537. INST_DYNAMIC =
  538. INST_BOOT =
  539. EXPORT_LIST = $(BASEEXT).opt
  540. PERL_ARCHIVE = ',($ENV{$shr} ? $ENV{$shr} : "Sys\$Share:$shr.$Config{'dlext'}"),'
  541. ';
  542. }
  543. $self->{TO_INST_PM} = [ sort keys %{$self->{PM}} ];
  544. $self->{PM_TO_BLIB} = [ %{$self->{PM}} ];
  545. push @m,'
  546. TO_INST_PM = ',$self->wraplist(@{$self->{TO_INST_PM}}),'
  547. PM_TO_BLIB = ',$self->wraplist(@{$self->{PM_TO_BLIB}}),'
  548. ';
  549. join('',@m);
  550. }
  551. =item cflags (override)
  552. Bypass shell script and produce qualifiers for CC directly (but warn
  553. user if a shell script for this extension exists). Fold multiple
  554. /Defines into one, since some C compilers pay attention to only one
  555. instance of this qualifier on the command line.
  556. =cut
  557. sub cflags {
  558. my($self,$libperl) = @_;
  559. my($quals) = $self->{CCFLAGS} || $Config{'ccflags'};
  560. my($definestr,$undefstr,$flagoptstr) = ('','','');
  561. my($incstr) = '/Include=($(PERL_INC)';
  562. my($name,$sys,@m);
  563. ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
  564. print STDOUT "Unix shell script ".$Config{"$self->{'BASEEXT'}_cflags"}.
  565. " required to modify CC command for $self->{'BASEEXT'}\n"
  566. if ($Config{$name});
  567. if ($quals =~ / -[DIUOg]/) {
  568. while ($quals =~ / -([Og])(\d*)\b/) {
  569. my($type,$lvl) = ($1,$2);
  570. $quals =~ s/ -$type$lvl\b\s*//;
  571. if ($type eq 'g') { $flagoptstr = '/NoOptimize'; }
  572. else { $flagoptstr = '/Optimize' . (defined($lvl) ? "=$lvl" : ''); }
  573. }
  574. while ($quals =~ / -([DIU])(\S+)/) {
  575. my($type,$def) = ($1,$2);
  576. $quals =~ s/ -$type$def\s*//;
  577. $def =~ s/"/""/g;
  578. if ($type eq 'D') { $definestr .= qq["$def",]; }
  579. elsif ($type eq 'I') { $incstr .= ',' . $self->fixpath($def,1); }
  580. else { $undefstr .= qq["$def",]; }
  581. }
  582. }
  583. if (length $quals and $quals !~ m!/!) {
  584. warn "MM_VMS: Ignoring unrecognized CCFLAGS elements \"$quals\"\n";
  585. $quals = '';
  586. }
  587. $definestr .= q["PERL_POLLUTE",] if $self->{POLLUTE};
  588. if (length $definestr) { chop($definestr); $quals .= "/Define=($definestr)"; }
  589. if (length $undefstr) { chop($undefstr); $quals .= "/Undef=($undefstr)"; }
  590. # Deal with $self->{DEFINE} here since some C compilers pay attention
  591. # to only one /Define clause on command line, so we have to
  592. # conflate the ones from $Config{'ccflags'} and $self->{DEFINE}
  593. # ($self->{DEFINE} has already been VMSified in constants() above)
  594. if ($self->{DEFINE}) { $quals .= $self->{DEFINE}; }
  595. for $type (qw(Def Undef)) {
  596. my(@terms);
  597. while ($quals =~ m:/${type}i?n?e?=([^/]+):ig) {
  598. my $term = $1;
  599. $term =~ s:^\((.+)\)$:$1:;
  600. push @terms, $term;
  601. }
  602. if ($type eq 'Def') {
  603. push @terms, qw[ $(DEFINE_VERSION) $(XS_DEFINE_VERSION) ];
  604. }
  605. if (@terms) {
  606. $quals =~ s:/${type}i?n?e?=[^/]+::ig;
  607. $quals .= "/${type}ine=(" . join(',',@terms) . ')';
  608. }
  609. }
  610. $libperl or $libperl = $self->{LIBPERL_A} || "libperl.olb";
  611. # Likewise with $self->{INC} and /Include
  612. if ($self->{'INC'}) {
  613. my(@includes) = split(/\s+/,$self->{INC});
  614. foreach (@includes) {
  615. s/^-I//;
  616. $incstr .= ','.$self->fixpath($_,1);
  617. }
  618. }
  619. $quals .= "$incstr)";
  620. # $quals =~ s/,,/,/g; $quals =~ s/\(,/(/g;
  621. $self->{CCFLAGS} = $quals;
  622. $self->{OPTIMIZE} ||= $flagoptstr || $Config{'optimize'};
  623. if ($self->{OPTIMIZE} !~ m!/!) {
  624. if ($self->{OPTIMIZE} =~ m!-g!) { $self->{OPTIMIZE} = '/Debug/NoOptimize' }
  625. elsif ($self->{OPTIMIZE} =~ /-O(\d*)/) {
  626. $self->{OPTIMIZE} = '/Optimize' . (defined($1) ? "=$1" : '');
  627. }
  628. else {
  629. warn "MM_VMS: Can't parse OPTIMIZE \"$self->{OPTIMIZE}\"; using default\n" if length $self->{OPTIMIZE};
  630. $self->{OPTIMIZE} = '/Optimize';
  631. }
  632. }
  633. return $self->{CFLAGS} = qq{
  634. CCFLAGS = $self->{CCFLAGS}
  635. OPTIMIZE = $self->{OPTIMIZE}
  636. PERLTYPE = $self->{PERLTYPE}
  637. SPLIT =
  638. LARGE =
  639. };
  640. }
  641. =item const_cccmd (override)
  642. Adds directives to point C preprocessor to the right place when
  643. handling #include E<lt>sys/foo.hE<gt> directives. Also constructs CC
  644. command line a bit differently than MM_Unix method.
  645. =cut
  646. sub const_cccmd {
  647. my($self,$libperl) = @_;
  648. my(@m);
  649. return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
  650. return '' unless $self->needs_linking();
  651. if ($Config{'vms_cc_type'} eq 'gcc') {
  652. push @m,'
  653. .FIRST
  654. ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" Then Define/NoLog SYS GNU_CC_Include:[VMS]';
  655. }
  656. elsif ($Config{'vms_cc_type'} eq 'vaxc') {
  657. push @m,'
  658. .FIRST
  659. ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("VAXC$Include").eqs."" Then Define/NoLog SYS Sys$Library
  660. ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("VAXC$Include").nes."" Then Define/NoLog SYS VAXC$Include';
  661. }
  662. else {
  663. push @m,'
  664. .FIRST
  665. ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("DECC$System_Include").eqs."" Then Define/NoLog SYS ',
  666. ($Config{'arch'} eq 'VMS_AXP' ? 'Sys$Library' : 'DECC$Library_Include'),'
  667. ',$self->{NOECHO},'If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("DECC$System_Include").nes."" Then Define/NoLog SYS DECC$System_Include';
  668. }
  669. push(@m, "\n\nCCCMD = $Config{'cc'} \$(CCFLAGS)\$(OPTIMIZE)\n");
  670. $self->{CONST_CCCMD} = join('',@m);
  671. }
  672. =item pm_to_blib (override)
  673. DCL I<still> accepts a maximum of 255 characters on a command
  674. line, so we write the (potentially) long list of file names
  675. to a temp file, then persuade Perl to read it instead of the
  676. command line to find args.
  677. =cut
  678. sub pm_to_blib {
  679. my($self) = @_;
  680. my($line,$from,$to,@m);
  681. my($autodir) = $self->catdir('$(INST_LIB)','auto');
  682. my(@files) = @{$self->{PM_TO_BLIB}};
  683. push @m, q{
  684. # Dummy target to match Unix target name; we use pm_to_blib.ts as
  685. # timestamp file to avoid repeated invocations under VMS
  686. pm_to_blib : pm_to_blib.ts
  687. $(NOECHO) $(NOOP)
  688. # As always, keep under DCL's 255-char limit
  689. pm_to_blib.ts : $(TO_INST_PM)
  690. $(NOECHO) $(PERL) -e "print '},shift(@files),q{ },shift(@files),q{'" >.MM_tmp
  691. };
  692. $line = ''; # avoid uninitialized var warning
  693. while ($from = shift(@files),$to = shift(@files)) {
  694. $line .= " $from $to";
  695. if (length($line) > 128) {
  696. push(@m,"\t\$(NOECHO) \$(PERL) -e \"print '$line'\" >>.MM_tmp\n");
  697. $line = '';
  698. }
  699. }
  700. push(@m,"\t\$(NOECHO) \$(PERL) -e \"print '$line'\" >>.MM_tmp\n") if $line;
  701. push(@m,q[ $(PERL) "-I$(PERL_LIB)" "-MExtUtils::Install" -e "pm_to_blib({split(' ',<STDIN>)},'].$autodir.q[','$(PM_FILTER)')" <.MM_tmp]);
  702. push(@m,qq[
  703. \$(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;
  704. \$(NOECHO) \$(TOUCH) pm_to_blib.ts
  705. ]);
  706. join('',@m);
  707. }
  708. =item tool_autosplit (override)
  709. Use VMS-style quoting on command line.
  710. =cut
  711. sub tool_autosplit{
  712. my($self, %attribs) = @_;
  713. my($asl) = "";
  714. $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
  715. q{
  716. # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
  717. AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use AutoSplit;}.$asl.q{ AutoSplit::autosplit($ARGV[0], $ARGV[1], 0, 1, 1) ;"
  718. };
  719. }
  720. =item tool_sxubpp (override)
  721. Use VMS-style quoting on xsubpp command line.
  722. =cut
  723. sub tool_xsubpp {
  724. my($self) = @_;
  725. return '' unless $self->needs_linking;
  726. my($xsdir) = $self->catdir($self->{PERL_LIB},'ExtUtils');
  727. # drop back to old location if xsubpp is not in new location yet
  728. $xsdir = $self->catdir($self->{PERL_SRC},'ext') unless (-f $self->catfile($xsdir,'xsubpp'));
  729. my(@tmdeps) = '$(XSUBPPDIR)typemap';
  730. if( $self->{TYPEMAPS} ){
  731. my $typemap;
  732. foreach $typemap (@{$self->{TYPEMAPS}}){
  733. if( ! -f $typemap ){
  734. warn "Typemap $typemap not found.\n";
  735. }
  736. else{
  737. push(@tmdeps, $self->fixpath($typemap,0));
  738. }
  739. }
  740. }
  741. push(@tmdeps, "typemap") if -f "typemap";
  742. my(@tmargs) = map("-typemap $_", @tmdeps);
  743. if( exists $self->{XSOPT} ){
  744. unshift( @tmargs, $self->{XSOPT} );
  745. }
  746. if ($Config{'ldflags'} &&
  747. $Config{'ldflags'} =~ m!/Debug!i &&
  748. (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)) {
  749. unshift(@tmargs,'-nolinenumbers');
  750. }
  751. my $xsubpp_version = $self->xsubpp_version($self->catfile($xsdir,'xsubpp'));
  752. # What are the correct thresholds for version 1 && 2 Paul?
  753. if ( $xsubpp_version > 1.923 ){
  754. $self->{XSPROTOARG} = '' unless defined $self->{XSPROTOARG};
  755. } else {
  756. if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
  757. print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
  758. Your version of xsubpp is $xsubpp_version and cannot handle this.
  759. Please upgrade to a more recent version of xsubpp.
  760. };
  761. } else {
  762. $self->{XSPROTOARG} = "";
  763. }
  764. }
  765. "
  766. XSUBPPDIR = $xsdir
  767. XSUBPP = \$(PERL) \"-I\$(PERL_ARCHLIB)\" \"-I\$(PERL_LIB)\" \$(XSUBPPDIR)xsubpp
  768. XSPROTOARG = $self->{XSPROTOARG}
  769. XSUBPPDEPS = @tmdeps
  770. XSUBPPARGS = @tmargs
  771. ";
  772. }
  773. =item xsubpp_version (override)
  774. Test xsubpp exit status according to VMS rules ($sts & 1 ==E<gt> good)
  775. rather than Unix rules ($sts == 0 ==E<gt> good).
  776. =cut
  777. sub xsubpp_version
  778. {
  779. my($self,$xsubpp) = @_;
  780. my ($version) ;
  781. return '' unless $self->needs_linking;
  782. # try to figure out the version number of the xsubpp on the system
  783. # first try the -v flag, introduced in 1.921 & 2.000a2
  784. my $command = "$self->{PERL} \"-I$self->{PERL_LIB}\" $xsubpp -v";
  785. print "Running: $command\n" if $Verbose;
  786. $version = `$command` ;
  787. if ($?) {
  788. use vmsish 'status';
  789. warn "Running '$command' exits with status $?";
  790. }
  791. chop $version ;
  792. return $1 if $version =~ /^xsubpp version (.*)/ ;
  793. # nope, then try something else
  794. my $counter = '000';
  795. my ($file) = 'temp' ;
  796. $counter++ while -e "$file$counter"; # don't overwrite anything
  797. $file .= $counter;
  798. local(*F);
  799. open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
  800. print F <<EOM ;
  801. MODULE = fred PACKAGE = fred
  802. int
  803. fred(a)
  804. int a;
  805. EOM
  806. close F ;
  807. $command = "$self->{PERL} $xsubpp $file";
  808. print "Running: $command\n" if $Verbose;
  809. my $text = `$command` ;
  810. if ($?) {
  811. use vmsish 'status';
  812. warn "Running '$command' exits with status $?";
  813. }
  814. unlink $file ;
  815. # gets 1.2 -> 1.92 and 2.000a1
  816. return $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ;
  817. # it is either 1.0 or 1.1
  818. return 1.1 if $text =~ /^Warning: ignored semicolon/ ;
  819. # none of the above, so 1.0
  820. return "1.0" ;
  821. }
  822. =item tools_other (override)
  823. Adds a few MM[SK] macros, and shortens some the installatin commands,
  824. in order to stay under DCL's 255-character limit. Also changes
  825. EQUALIZE_TIMESTAMP to set revision date of target file to one second
  826. later than source file, since MMK interprets precisely equal revision
  827. dates for a source and target file as a sign that the target needs
  828. to be updated.
  829. =cut
  830. sub tools_other {
  831. my($self) = @_;
  832. qq!
  833. # Assumes \$(MMS) invokes MMS or MMK
  834. # (It is assumed in some cases later that the default makefile name
  835. # (Descrip.MMS for MM[SK]) is used.)
  836. USEMAKEFILE = /Descrip=
  837. USEMACROS = /Macro=(
  838. MACROEND = )
  839. MAKEFILE = Descrip.MMS
  840. SHELL = Posix
  841. TOUCH = $self->{TOUCH}
  842. CHMOD = $self->{CHMOD}
  843. CP = $self->{CP}
  844. MV = $self->{MV}
  845. RM_F = $self->{RM_F}
  846. RM_RF = $self->{RM_RF}
  847. SAY = Write Sys\$Output
  848. UMASK_NULL = $self->{UMASK_NULL}
  849. NOOP = $self->{NOOP}
  850. NOECHO = $self->{NOECHO}
  851. MKPATH = Create/Directory
  852. EQUALIZE_TIMESTAMP = \$(PERL) -we "open F,qq{>\$ARGV[1]};close F;utime(0,(stat(\$ARGV[0]))[9]+1,\$ARGV[1])"
  853. !. ($self->{PARENT} ? '' :
  854. qq!WARN_IF_OLD_PACKLIST = \$(PERL) -e "if (-f \$ARGV[0]){print qq[WARNING: Old package found (\$ARGV[0]); please check for collisions\\n]}"
  855. MOD_INSTALL = \$(PERL) "-I\$(PERL_LIB)" "-MExtUtils::Install" -e "install({split(' ',<STDIN>)},1);"
  856. DOC_INSTALL = \$(PERL) -e "\@ARGV=split(/\\|/,<STDIN>);print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];while(\$key=shift && \$val=shift){print qq[=item *\\n\\nC<\$key: \$val>\\n\\n];}print qq[=back\\n\\n]"
  857. UNINSTALL = \$(PERL) "-I\$(PERL_LIB)" "-MExtUtils::Install" -e "uninstall(\$ARGV[0],1,1);"
  858. !);
  859. }
  860. =item dist (override)
  861. Provide VMSish defaults for some values, then hand off to
  862. default MM_Unix method.
  863. =cut
  864. sub dist {
  865. my($self, %attribs) = @_;
  866. $attribs{VERSION} ||= $self->{VERSION_SYM};
  867. $attribs{NAME} ||= $self->{DISTNAME};
  868. $attribs{ZIPFLAGS} ||= '-Vu';
  869. $attribs{COMPRESS} ||= 'gzip';
  870. $attribs{SUFFIX} ||= '-gz';
  871. $attribs{SHAR} ||= 'vms_share';
  872. $attribs{DIST_DEFAULT} ||= 'zipdist';
  873. # Sanitize these for use in $(DISTVNAME) filespec
  874. $attribs{VERSION} =~ s/[^\w\$]/_/g;
  875. $attribs{NAME} =~ s/[^\w\$]/-/g;
  876. return ExtUtils::MM_Unix::dist($self,%attribs);
  877. }
  878. =item c_o (override)
  879. Use VMS syntax on command line. In particular, $(DEFINE) and
  880. $(PERL_INC) have been pulled into $(CCCMD). Also use MM[SK] macros.
  881. =cut
  882. sub c_o {
  883. my($self) = @_;
  884. return '' unless $self->needs_linking();
  885. '
  886. .c$(OBJ_EXT) :
  887. $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).c
  888. .cpp$(OBJ_EXT) :
  889. $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).cpp
  890. .cxx$(OBJ_EXT) :
  891. $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).cxx
  892. ';
  893. }
  894. =item xs_c (override)
  895. Use MM[SK] macros.
  896. =cut
  897. sub xs_c {
  898. my($self) = @_;
  899. return '' unless $self->needs_linking();
  900. '
  901. .xs.c :
  902. $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(MMS$TARGET_NAME).xs >$(MMS$TARGET)
  903. ';
  904. }
  905. =item xs_o (override)
  906. Use MM[SK] macros, and VMS command line for C compiler.
  907. =cut
  908. sub xs_o { # many makes are too dumb to use xs_c then c_o
  909. my($self) = @_;
  910. return '' unless $self->needs_linking();
  911. '
  912. .xs$(OBJ_EXT) :
  913. $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(MMS$TARGET_NAME).xs >$(MMS$TARGET_NAME).c
  914. $(CCCMD) $(CCCDLFLAGS) $(MMS$TARGET_NAME).c
  915. ';
  916. }
  917. =item top_targets (override)
  918. Use VMS quoting on command line for Version_check.
  919. =cut
  920. sub top_targets {
  921. my($self) = shift;
  922. my(@m);
  923. push @m, '
  924. all :: pure_all manifypods
  925. $(NOECHO) $(NOOP)
  926. pure_all :: config pm_to_blib subdirs linkext
  927. $(NOECHO) $(NOOP)
  928. subdirs :: $(MYEXTLIB)
  929. $(NOECHO) $(NOOP)
  930. config :: $(MAKEFILE) $(INST_LIBDIR).exists
  931. $(NOECHO) $(NOOP)
  932. config :: $(INST_ARCHAUTODIR).exists
  933. $(NOECHO) $(NOOP)
  934. config :: $(INST_AUTODIR).exists
  935. $(NOECHO) $(NOOP)
  936. ';
  937. push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
  938. if (%{$self->{MAN1PODS}}) {
  939. push @m, q[
  940. config :: $(INST_MAN1DIR).exists
  941. $(NOECHO) $(NOOP)
  942. ];
  943. push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
  944. }
  945. if (%{$self->{MAN3PODS}}) {
  946. push @m, q[
  947. config :: $(INST_MAN3DIR).exists
  948. $(NOECHO) $(NOOP)
  949. ];
  950. push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
  951. }
  952. push @m, '
  953. $(O_FILES) : $(H_FILES)
  954. ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
  955. push @m, q{
  956. help :
  957. perldoc ExtUtils::MakeMaker
  958. };
  959. push @m, q{
  960. Version_check :
  961. $(NOECHO) $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -
  962. "-MExtUtils::MakeMaker=Version_check" -e "&Version_check('$(MM_VERSION)')"
  963. };
  964. join('',@m);
  965. }
  966. =item dlsyms (override)
  967. Create VMS linker options files specifying universal symbols for this
  968. extension's shareable image, and listing other shareable images or
  969. libraries to which it should be linked.
  970. =cut
  971. sub dlsyms {
  972. my($self,%attribs) = @_;
  973. return '' unless $self->needs_linking();
  974. my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
  975. my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
  976. my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
  977. my(@m);
  978. unless ($self->{SKIPHASH}{'dynamic'}) {
  979. push(@m,'
  980. dynamic :: $(INST_ARCHAUTODIR)$(BASEEXT).opt
  981. $(NOECHO) $(NOOP)
  982. ');
  983. }
  984. push(@m,'
  985. static :: $(INST_ARCHAUTODIR)$(BASEEXT).opt
  986. $(NOECHO) $(NOOP)
  987. ') unless $self->{SKIPHASH}{'static'};
  988. push @m,'
  989. $(INST_ARCHAUTODIR)$(BASEEXT).opt : $(BASEEXT).opt
  990. $(CP) $(MMS$SOURCE) $(MMS$TARGET)
  991. $(BASEEXT).opt : Makefile.PL
  992. $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Mksymlists;" -
  993. ',qq[-e "Mksymlists('NAME' => '$self->{NAME}', 'DL_FUNCS' => ],
  994. neatvalue($funcs),q[, 'DL_VARS' => ],neatvalue($vars),
  995. q[, 'FUNCLIST' => ],neatvalue($funclist),qq[)"\n];
  996. push @m, ' $(PERL) -e "print ""$(INST_STATIC)/Include=';
  997. if ($self->{OBJECT} =~ /\bBASEEXT\b/ or
  998. $self->{OBJECT} =~ /\b$self->{BASEEXT}\b/i) {
  999. push @m, ($Config{d_vms_case_sensitive_symbols}
  1000. ? uc($self->{BASEEXT}) :'$(BASEEXT)');
  1001. }
  1002. else { # We don't have a "main" object file, so pull 'em all in
  1003. # Upcase module names if linker is being case-sensitive
  1004. my($upcase) = $Config{d_vms_case_sensitive_symbols};
  1005. my(@omods) = map { s/\.[^.]*$//; # Trim off file type
  1006. s[\$\(\w+_EXT\)][]; # even as a macro
  1007. s/.*[:>\/\]]//; # Trim off dir spec
  1008. $upcase ? uc($_) : $_;
  1009. } split ' ', $self->eliminate_macros($self->{OBJECT});
  1010. my($tmp,@lines,$elt) = '';
  1011. $tmp = shift @omods;
  1012. foreach $elt (@omods) {
  1013. $tmp .= ",$elt";
  1014. if (length($tmp) > 80) { push @lines, $tmp; $tmp = ''; }
  1015. }
  1016. push @lines, $tmp;
  1017. push @m, '(', join( qq[, -\\n\\t"";" >>\$(MMS\$TARGET)\n\t\$(PERL) -e "print ""], @lines),')';
  1018. }
  1019. push @m, '\n$(INST_STATIC)/Library\n"";" >>$(MMS$TARGET)',"\n";
  1020. if (length $self->{LDLOADLIBS}) {
  1021. my($lib); my($line) = '';
  1022. foreach $lib (split ' ', $self->{LDLOADLIBS}) {
  1023. $lib =~ s%\$%\\\$%g; # Escape '$' in VMS filespecs
  1024. if (length($line) + length($lib) > 160) {
  1025. push @m, "\t\$(PERL) -e \"print qq{$line}\" >>\$(MMS\$TARGET)\n";
  1026. $line = $lib . '\n';
  1027. }
  1028. else { $line .= $lib . '\n'; }
  1029. }
  1030. push @m, "\t\$(PERL) -e \"print qq{$line}\" >>\$(MMS\$TARGET)\n" if $line;
  1031. }
  1032. join('',@m);
  1033. }
  1034. =item dynamic_lib (override)
  1035. Use VMS Link command.
  1036. =cut
  1037. sub dynamic_lib {
  1038. my($self, %attribs) = @_;
  1039. return '' unless $self->needs_linking(); #might be because of a subdir
  1040. return '' unless $self->has_link_code();
  1041. my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
  1042. my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
  1043. my $shr = $Config{'dbgprefix'} . 'PerlShr';
  1044. my(@m);
  1045. push @m,"
  1046. OTHERLDFLAGS = $otherldflags
  1047. INST_DYNAMIC_DEP = $inst_dynamic_dep
  1048. ";
  1049. push @m, '
  1050. $(INST_DYNAMIC) : $(INST_STATIC) $(PERL_INC)perlshr_attr.opt $(INST_ARCHAUTODIR).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
  1051. $(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)
  1052. If F$TrnLNm("',$shr,'").eqs."" Then Define/NoLog/User ',"$shr Sys\$Share:$shr.$Config{'dlext'}",'
  1053. Link $(LDFLAGS) /Shareable=$(MMS$TARGET)$(OTHERLDFLAGS) $(BASEEXT).opt/Option,$(PERL_INC)perlshr_attr.opt/Option
  1054. ';
  1055. push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  1056. join('',@m);
  1057. }
  1058. =item dynamic_bs (override)
  1059. Use VMS-style quoting on Mkbootstrap command line.
  1060. =cut
  1061. sub dynamic_bs {
  1062. my($self, %attribs) = @_;
  1063. return '
  1064. BOOTSTRAP =
  1065. ' unless $self->has_link_code();
  1066. '
  1067. BOOTSTRAP = '."$self->{BASEEXT}.bs".'
  1068. # As MakeMaker mkbootstrap might not write a file (if none is required)
  1069. # we use touch to prevent make continually trying to remake it.
  1070. # The DynaLoader only reads a non-empty file.
  1071. $(BOOTSTRAP) : $(MAKEFILE) '."$self->{BOOTDEP}".' $(INST_ARCHAUTODIR).exists
  1072. $(NOECHO) $(SAY) "Running mkbootstrap for $(NAME) ($(BSLOADLIBS))"
  1073. $(NOECHO) $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -
  1074. -e "use ExtUtils::Mkbootstrap; Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
  1075. $(NOECHO) $(TOUCH) $(MMS$TARGET)
  1076. $(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR).exists
  1077. $(NOECHO) $(RM_RF) $(INST_BOOT)
  1078. - $(CP) $(BOOTSTRAP) $(INST_BOOT)
  1079. ';
  1080. }
  1081. =item static_lib (override)
  1082. Use VMS commands to manipulate object library.
  1083. =cut
  1084. sub static_lib {
  1085. my($self) = @_;
  1086. return '' unless $self->needs_linking();
  1087. return '
  1088. $(INST_STATIC) :
  1089. $(NOECHO) $(NOOP)
  1090. ' unless ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB});
  1091. my(@m,$lib);
  1092. push @m,'
  1093. # Rely on suffix rule for update action
  1094. $(OBJECT) : $(INST_ARCHAUTODIR).exists
  1095. $(INST_STATIC) : $(OBJECT) $(MYEXTLIB)
  1096. ';
  1097. # If this extension has it's own library (eg SDBM_File)
  1098. # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
  1099. push(@m, "\t",'$(CP) $(MYEXTLIB) $(MMS$TARGET)',"\n") if $self->{MYEXTLIB};
  1100. push(@m,"\t",'If F$Search("$(MMS$TARGET)").eqs."" Then Library/Object/Create $(MMS$TARGET)',"\n");
  1101. # if there was a library to copy, then we can't use MMS$SOURCE_LIST,
  1102. # 'cause it's a library and you can't stick them in other libraries.
  1103. # In that case, we use $OBJECT instead and hope for the best
  1104. if ($self->{MYEXTLIB}) {
  1105. push(@m,"\t",'Library/Object/Replace $(MMS$TARGET) $(OBJECT)',"\n");
  1106. } else {
  1107. push(@m,"\t",'Library/Object/Replace $(MMS$TARGET) $(MMS$SOURCE_LIST)',"\n");
  1108. }
  1109. push @m, "\t\$(NOECHO) \$(PERL) -e 1 >\$(INST_ARCHAUTODIR)extralibs.ld\n";
  1110. foreach $lib (split ' ', $self->{EXTRALIBS}) {
  1111. push(@m,"\t",'$(NOECHO) $(PERL) -e "print qq{',$lib,'\n}" >>$(INST_ARCHAUTODIR)extralibs.ld',"\n");
  1112. }
  1113. push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  1114. join('',@m);
  1115. }
  1116. =item manifypods (override)
  1117. Use VMS-style quoting on command line, and VMS logical name
  1118. to specify fallback location at build time if we can't find pod2man.
  1119. =cut
  1120. sub manifypods {
  1121. my($self, %attribs) = @_;
  1122. return "\nmanifypods :\n\t\$(NOECHO) \$(NOOP)\n" unless %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
  1123. my($dist);
  1124. my($pod2man_exe);
  1125. if (defined $self->{PERL_SRC}) {
  1126. $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
  1127. } else {
  1128. $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man');
  1129. }
  1130. if (not ($pod2man_exe = $self->perl_script($pod2man_exe))) {
  1131. # No pod2man but some MAN3PODS to be installed
  1132. print <<END;
  1133. Warning: I could not locate your pod2man program. As a last choice,
  1134. I will look for the file to which the logical name POD2MAN
  1135. points when MMK is invoked.
  1136. END
  1137. $pod2man_exe = "pod2man";
  1138. }
  1139. my(@m);
  1140. push @m,
  1141. qq[POD2MAN_EXE = $pod2man_exe\n],
  1142. q[POD2MAN = $(PERL) -we "%m=@ARGV;for (keys %m){" -
  1143. -e "system(""MCR $^X $(POD2MAN_EXE) $_ >$m{$_}"");}"
  1144. ];
  1145. push @m, "\nmanifypods : \$(MAN1PODS) \$(MAN3PODS)\n";
  1146. if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
  1147. my($pod);
  1148. foreach $pod (sort keys %{$self->{MAN1PODS}}) {
  1149. push @m, qq[\t\@- If F\$Search("\$(POD2MAN_EXE)").nes."" Then \$(POD2MAN) ];
  1150. push @m, "$pod $self->{MAN1PODS}{$pod}\n";
  1151. }
  1152. foreach $pod (sort keys %{$self->{MAN3PODS}}) {
  1153. push @m, qq[\t\@- If F\$Search("\$(POD2MAN_EXE)").nes."" Then \$(POD2MAN) ];
  1154. push @m, "$pod $self->{MAN3PODS}{$pod}\n";
  1155. }
  1156. }
  1157. join('', @m);
  1158. }
  1159. =item processPL (override)
  1160. Use VMS-style quoting on command line.
  1161. =cut
  1162. sub processPL {
  1163. my($self) = @_;
  1164. return "" unless $self->{PL_FILES};
  1165. my(@m, $plfile);
  1166. foreach $plfile (sort keys %{$self->{PL_FILES}}) {
  1167. my $list = ref($self->{PL_FILES}->{$plfile})
  1168. ? $self->{PL_FILES}->{$plfile}
  1169. : [$self->{PL_FILES}->{$plfile}];
  1170. foreach $target (@$list) {
  1171. my $vmsplfile = vmsify($plfile);
  1172. my $vmsfile = vmsify($target);
  1173. push @m, "
  1174. all :: $vmsfile
  1175. \$(NOECHO) \$(NOOP)
  1176. $vmsfile :: $vmsplfile
  1177. ",' $(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" '," $vmsplfile $vmsfile
  1178. ";
  1179. }
  1180. }
  1181. join "", @m;
  1182. }
  1183. =item installbin (override)
  1184. Stay under DCL's 255 character command line limit once again by
  1185. splitting potentially long list of files across multiple lines
  1186. in C<realclean> target.
  1187. =cut
  1188. sub installbin {
  1189. my($self) = @_;
  1190. return '' unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
  1191. return '' unless @{$self->{EXE_FILES}};
  1192. my(@m, $from, $to, %fromto, @to, $line);
  1193. my(@exefiles) = map { vmsify($_) } @{$self->{EXE_FILES}};
  1194. for $from (@exefiles) {
  1195. my($path) = '$(INST_SCRIPT)' . basename($from);
  1196. local($_) = $path; # backward compatibility
  1197. $to = $self->libscan($path);
  1198. print "libscan($from) => '$to'\n" if ($Verbose >=2);
  1199. $fromto{$from} = vmsify($to);
  1200. }
  1201. @to = values %fromto;
  1202. push @m, "
  1203. EXE_FILES = @exefiles
  1204. all :: @to
  1205. \$(NOECHO) \$(NOOP)
  1206. realclean ::
  1207. ";
  1208. $line = ''; #avoid unitialized var warning
  1209. foreach $to (@to) {
  1210. if (length($line) + length($to) > 80) {
  1211. push @m, "\t\$(RM_F) $line\n";
  1212. $line = $to;
  1213. }
  1214. else { $line .= " $to"; }
  1215. }
  1216. push @m, "\t\$(RM_F) $line\n\n" if $line;
  1217. while (($from,$to) = each %fromto) {
  1218. last unless defined $from;
  1219. my $todir;
  1220. if ($to =~ m#[/>:\]]#) { $todir = dirname($to); }
  1221. else { ($todir = $to) =~ s/[^\)]+$//; }
  1222. $todir = $self->fixpath($todir,1);
  1223. push @m, "
  1224. $to : $from \$(MAKEFILE) ${todir}.exists
  1225. \$(CP) $from $to
  1226. ", $self->dir_target($todir);
  1227. }
  1228. join "", @m;
  1229. }
  1230. =item subdir_x (override)
  1231. Use VMS commands to change default directory.
  1232. =cut
  1233. sub subdir_x {
  1234. my($self, $subdir) = @_;
  1235. my(@m,$key);
  1236. $subdir = $self->fixpath($subdir,1);
  1237. push @m, '
  1238. subdirs ::
  1239. olddef = F$Environment("Default")
  1240. Set Default ',$subdir,'
  1241. - $(MMS)$(MMSQUALIFIERS) all $(USEMACROS)$(PASTHRU)$(MACROEND)
  1242. Set Default \'olddef\'
  1243. ';
  1244. join('',@m);
  1245. }
  1246. =item clean (override)
  1247. Split potentially long list of files across multiple commands (in
  1248. order to stay under the magic command line limit). Also use MM[SK]
  1249. commands for handling subdirectories.
  1250. =cut
  1251. sub clean {
  1252. my($self, %attribs) = @_;
  1253. my(@m,$dir);
  1254. push @m, '
  1255. # Delete temporary files but do not touch installed files. We don\'t delete
  1256. # the Descrip.MMS here so that a later make realclean still has it to use.
  1257. clean ::
  1258. ';
  1259. foreach $dir (@{$self->{DIR}}) { # clean subdirectories first
  1260. my($vmsdir) = $self->fixpath($dir,1);
  1261. push( @m, ' If F$Search("'.$vmsdir.'$(MAKEFILE)").nes."" Then \\',"\n\t",
  1262. '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS)$(MMSQUALIFIERS) clean`;"',"\n");
  1263. }
  1264. push @m, ' $(RM_F) *.Map *.Dmp *.Lis *.cpp *.$(DLEXT) *$(OBJ_EXT) *$(LIB_EXT) *.Opt $(BOOTSTRAP) $(BASEEXT).bso .MM_Tmp
  1265. ';
  1266. my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
  1267. # Unlink realclean, $attribs{FILES} is a string here; it may contain
  1268. # a list or a macro that expands to a list.
  1269. if ($attribs{FILES}) {
  1270. my($word,$key,@filist);
  1271. if (ref $attribs{FILES} eq 'ARRAY') { @filist = @{$attribs{FILES}}; }
  1272. else { @filist = split /\s+/, $attribs{FILES}; }
  1273. foreach $word (@filist) {
  1274. if (($key) = $word =~ m#^\$\((.*)\)$# and ref $self->{$key} eq 'ARRAY') {
  1275. push(@otherfiles, @{$self->{$key}});
  1276. }
  1277. else { push(@otherfiles, $word); }
  1278. }
  1279. }
  1280. push(@otherfiles, qw[ blib $(MAKE_APERL_FILE) extralibs.ld perlmain.c pm_to_blib.ts ]);
  1281. push(@otherfiles,$self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
  1282. my($file,$line);
  1283. $line = ''; #avoid unitialized var warning
  1284. # Occasionally files are repeated several times from different sources
  1285. { my(%of) = map { ($_,1) } @otherfiles; @otherfiles = keys %of; }
  1286. foreach $file (@otherfiles) {
  1287. $file = $self->fixpath($file);
  1288. if (length($line) + length($file) > 80) {
  1289. push @m, "\t\$(RM_RF) $line\n";
  1290. $line = "$file";
  1291. }
  1292. else { $line .= " $file"; }
  1293. }
  1294. push @m, "\t\$(RM_RF) $line\n" if $line;
  1295. push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
  1296. join('', @m);
  1297. }
  1298. =item realclean (override)
  1299. Guess what we're working around? Also, use MM[SK] for subdirectories.
  1300. =cut
  1301. sub realclean {
  1302. my($self, %attribs) = @_;
  1303. my(@m);
  1304. push(@m,'
  1305. # Delete temporary files (via clean) and also delete installed files
  1306. realclean :: clean
  1307. ');
  1308. foreach(@{$self->{DIR}}){
  1309. my($vmsdir) = $self->fixpath($_,1);
  1310. push(@m, ' If F$Search("'."$vmsdir".'$(MAKEFILE)").nes."" Then \\',"\n\t",
  1311. '$(PERL) -e "chdir ',"'$vmsdir'",'; print `$(MMS)$(MMSQUALIFIERS) realclean`;"',"\n");
  1312. }
  1313. push @m,' $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR)
  1314. ';
  1315. # We can't expand several of the MMS macros here, since they don't have
  1316. # corresponding %$self keys (i.e. they're defined in Descrip.MMS as a
  1317. # combination of macros). In order to stay below DCL's 255 char limit,
  1318. # we put only 2 on a line.
  1319. my($file,$line,$fcnt);
  1320. my(@files) = qw{ $(MAKEFILE) $(MAKEFILE)_old };
  1321. if ($self->has_link_code) {
  1322. push(@files,qw{ $(INST_DYNAMIC) $(INST_STATIC) $(INST_BOOT) $(OBJECT) });
  1323. }
  1324. push(@files, values %{$self->{PM}});
  1325. $line = ''; #avoid unitialized var warning
  1326. # Occasionally files are repeated several times from different sources
  1327. { my(%f) = map { ($_,1) } @files; @files = keys %f; }
  1328. foreach $file (@files) {
  1329. $file = $self->fixpath($file);
  1330. if (length($line) + length($file) > 80 || ++$fcnt >= 2) {
  1331. push @m, "\t\$(RM_F) $line\n";
  1332. $line = "$file";
  1333. $fcnt = 0;
  1334. }
  1335. else { $line .= " $file"; }
  1336. }
  1337. push @m, "\t\$(RM_F) $line\n" if $line;
  1338. if ($attribs{FILES}) {
  1339. my($word,$key,@filist,@allfiles);
  1340. if (ref $attribs{FILES} eq 'ARRAY') { @filist = @{$attribs{FILES}}; }
  1341. else { @filist = split /\s+/, $attribs{FILES}; }
  1342. foreach $word (@filist) {
  1343. if (($key) = $word =~ m#^\$\((.*)\)$# and ref $self->{$key} eq 'ARRAY') {
  1344. push(@allfiles, @{$self->{$key}});
  1345. }
  1346. else { push(@allfiles, $word); }
  1347. }
  1348. $line = '';
  1349. # Occasionally files are repeated several times from different sources
  1350. { my(%af) = map { ($_,1) } @allfiles; @allfiles = keys %af; }
  1351. foreach $file (@allfiles) {
  1352. $file = $self->fixpath($file);
  1353. if (length($line) + length($file) > 80) {
  1354. push @m, "\t\$(RM_RF) $line\n";
  1355. $line = "$file";
  1356. }
  1357. else { $line .= " $file"; }
  1358. }
  1359. push @m, "\t\$(RM_RF) $line\n" if $line;
  1360. }
  1361. push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
  1362. join('', @m);
  1363. }
  1364. =item dist_basics (override)
  1365. Use VMS-style quoting on command line.
  1366. =cut
  1367. sub dist_basics {
  1368. my($self) = @_;
  1369. '
  1370. distclean :: realclean distcheck
  1371. $(NOECHO) $(NOOP)
  1372. distcheck :
  1373. $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&fullcheck\'; fullcheck()"
  1374. skipcheck :
  1375. $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&skipcheck\'; skipcheck()"
  1376. manifest :
  1377. $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest \'&mkmanifest\'; mkmanifest()"
  1378. ';
  1379. }
  1380. =item dist_core (override)
  1381. Syntax for invoking F<VMS_Share> differs from that for Unix F<shar>,
  1382. so C<shdist> target actions are VMS-specific.
  1383. =cut
  1384. sub dist_core {
  1385. my($self) = @_;
  1386. q[
  1387. dist : $(DIST_DEFAULT)
  1388. $(NOECHO) $(PERL) -le "print 'Warning: $m older than $vf' if -e ($vf = '$(VERSION_FROM)') && -M $vf < -M ($m = '$(MAKEFILE)')"
  1389. zipdist : $(DISTVNAME).zip
  1390. $(NOECHO) $(NOOP)
  1391. tardist : $(DISTVNAME).tar$(SUFFIX)
  1392. $(NOECHO) $(NOOP)
  1393. $(DISTVNAME).zip : distdir
  1394. $(PREOP)
  1395. $(ZIP) "$(ZIPFLAGS)" $(MMS$TARGET) [.$(DISTVNAME)...]*.*;
  1396. $(RM_RF) $(DISTVNAME)
  1397. $(POSTOP)
  1398. $(DISTVNAME).tar$(SUFFIX) : distdir
  1399. $(PREOP)
  1400. $(TO_UNIX)
  1401. $(TAR) "$(TARFLAGS)" $(DISTVNAME).tar [.$(DISTVNAME)...]
  1402. $(RM_RF) $(DISTVNAME)
  1403. $(COMPRESS) $(DISTVNAME).tar
  1404. $(POSTOP)
  1405. shdist : distdir
  1406. $(PREOP)
  1407. $(SHAR) [.$(DISTVNAME...]*.*; $(DISTVNAME).share
  1408. $(RM_RF) $(DISTVNAME)
  1409. $(POSTOP)
  1410. ];
  1411. }
  1412. =item dist_dir (override)
  1413. Use VMS-style quoting on command line.
  1414. =cut
  1415. sub dist_dir {
  1416. my($self) = @_;
  1417. q{
  1418. distdir :
  1419. $(RM_RF) $(DISTVNAME)
  1420. $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e "use ExtUtils::Manifest '/mani/';" \\
  1421. -e "manicopy(maniread(),'$(DISTVNAME)','$(DIST_CP)');"
  1422. };
  1423. }
  1424. =item dist_test (override)
  1425. Use VMS commands to change default directory, and use VMS-style
  1426. quoting on command line.
  1427. =cut
  1428. sub dist_test {
  1429. my($self) = @_;
  1430. q{
  1431. disttest : distdir
  1432. startdir = F$Environment("Default")
  1433. Set Default [.$(DISTVNAME)]
  1434. $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL
  1435. $(MMS)$(MMSQUALIFIERS)
  1436. $(MMS)$(MMSQUALIFIERS) test
  1437. Set Default 'startdir'
  1438. };
  1439. }
  1440. # --- Test and Installation Sections ---
  1441. =item install (override)
  1442. Work around DCL's 255 character limit several times,and use
  1443. VMS-style command line quoting in a few cases.
  1444. =cut
  1445. sub install {
  1446. my($self, %attribs) = @_;
  1447. my(@m,@docfiles);
  1448. if ($self->{EXE_FILES}) {
  1449. my($line,$file) = ('','');
  1450. foreach $file (@{$self->{EXE_FILES}}) {
  1451. $line .= "$file ";
  1452. if (length($line) > 128) {
  1453. push(@docfiles,qq[\t\$(PERL) -e "print '$line'" >>.MM_tmp\n]);
  1454. $line = '';
  1455. }
  1456. }
  1457. push(@docfiles,qq[\t\$(PERL) -e "print '$line'" >>.MM_tmp\n]) if $line;
  1458. }
  1459. push @m, q[
  1460. install :: all pure_install doc_install
  1461. $(NOECHO) $(NOOP)
  1462. install_perl :: all pure_perl_install doc_perl_install
  1463. $(NOECHO) $(NOOP)
  1464. install_site :: all pure_site_install doc_site_install
  1465. $(NOECHO) $(NOOP)
  1466. install_ :: install_site
  1467. $(NOECHO) $(SAY) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
  1468. pure_install :: pure_$(INSTALLDIRS)_install
  1469. $(NOECHO) $(NOOP)
  1470. doc_install :: doc_$(INSTALLDIRS)_install
  1471. $(NOECHO) $(SAY) "Appending installation info to $(INSTALLARCHLIB)perllocal.pod"
  1472. pure__install : pure_site_install
  1473. $(NOECHO) $(SAY) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
  1474. doc__install : doc_site_install
  1475. $(NOECHO) $(SAY) "INSTALLDIRS not defined, defaulting to INSTALLDIRS=site"
  1476. # This hack brought to you by DCL's 255-character command line limit
  1477. pure_perl_install ::
  1478. $(NOECHO) $(PERL) -e "print 'read ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[ '" >.MM_tmp
  1479. $(NOECHO) $(PERL) -e "print 'write ].$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q[ '" >>.MM_tmp
  1480. $(NOECHO) $(PERL) -e "print '$(INST_LIB) $(INSTALLPRIVLIB) '" >>.MM_tmp
  1481. $(NOECHO) $(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLARCHLIB) '" >>.MM_tmp
  1482. $(NOECHO) $(PERL) -e "print '$(INST_BIN) $(INSTALLBIN) '" >>.MM_tmp
  1483. $(NOECHO) $(PERL) -e "print '$(INST_SCRIPT) $(INSTALLSCRIPT) '" >>.MM_tmp
  1484. $(NOECHO) $(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLMAN1DIR) '" >>.MM_tmp
  1485. $(NOECHO) $(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLMAN3DIR) '" >>.MM_tmp
  1486. $(MOD_INSTALL) <.MM_tmp
  1487. $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;
  1488. $(NOECHO) $(WARN_IF_OLD_PACKLIST) ].$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q[
  1489. # Likewise
  1490. pure_site_install ::
  1491. $(NOECHO) $(PERL) -e "print 'read ].$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q[ '" >.MM_tmp
  1492. $(NOECHO) $(PERL) -e "print 'write ].$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q[ '" >>.MM_tmp
  1493. $(NOECHO) $(PERL) -e "print '$(INST_LIB) $(INSTALLSITELIB) '" >>.MM_tmp
  1494. $(NOECHO) $(PERL) -e "print '$(INST_ARCHLIB) $(INSTALLSITEARCH) '" >>.MM_tmp
  1495. $(NOECHO) $(PERL) -e "print '$(INST_BIN) $(INSTALLBIN) '" >>.MM_tmp
  1496. $(NOECHO) $(PERL) -e "print '$(INST_SCRIPT) $(INSTALLSCRIPT) '" >>.MM_tmp
  1497. $(NOECHO) $(PERL) -e "print '$(INST_MAN1DIR) $(INSTALLMAN1DIR) '" >>.MM_tmp
  1498. $(NOECHO) $(PERL) -e "print '$(INST_MAN3DIR) $(INSTALLMAN3DIR) '" >>.MM_tmp
  1499. $(MOD_INSTALL) <.MM_tmp
  1500. $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;
  1501. $(NOECHO) $(WARN_IF_OLD_PACKLIST) ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[
  1502. # Ditto
  1503. doc_perl_install ::
  1504. $(NOECHO) $(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLPRIVLIB)|'" >.MM_tmp
  1505. $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES)|'" >>.MM_tmp
  1506. ],@docfiles,
  1507. q% $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp
  1508. $(NOECHO) $(PERL) -e "print q[print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp
  1509. $(NOECHO) $(PERL) -e "print q[while(($key=shift) && ($val=shift)) ]" >>.MM2_tmp
  1510. $(NOECHO) $(PERL) -e "print q[{print qq[=item *\\n\\nC<$key: $val>\\n\\n];}print qq[=back\\n\\n];]" >>.MM2_tmp
  1511. $(NOECHO) $(PERL) .MM2_tmp <.MM_tmp >>%.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
  1512. $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;,.MM2_tmp;
  1513. # And again
  1514. doc_site_install ::
  1515. $(NOECHO) $(PERL) -e "print 'Module $(NAME)|installed into|$(INSTALLSITELIB)|'" >.MM_tmp
  1516. $(NOECHO) $(PERL) -e "print 'LINKTYPE|$(LINKTYPE)|VERSION|$(VERSION)|EXE_FILES|$(EXE_FILES)|'" >>.MM_tmp
  1517. ],@docfiles,
  1518. q% $(NOECHO) $(PERL) -e "print q[@ARGV=split(/\\|/,<STDIN>);]" >.MM2_tmp
  1519. $(NOECHO) $(PERL) -e "print q[print '=head2 ',scalar(localtime),': C<',shift,qq[>\\n\\n=over 4\\n\\n];]" >>.MM2_tmp
  1520. $(NOECHO) $(PERL) -e "print q[while(($key=shift) && ($val=shift)) ]" >>.MM2_tmp
  1521. $(NOECHO) $(PERL) -e "print q[{print qq[=item *\\n\\nC<$key: $val>\\n\\n];}print qq[=back\\n\\n];]" >>.MM2_tmp
  1522. $(NOECHO) $(PERL) .MM2_tmp <.MM_tmp >>%.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
  1523. $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;,.MM2_tmp;
  1524. ];
  1525. push @m, q[
  1526. uninstall :: uninstall_from_$(INSTALLDIRS)dirs
  1527. $(NOECHO) $(NOOP)
  1528. uninstall_from_perldirs ::
  1529. $(NOECHO) $(UNINSTALL) ].$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q[
  1530. $(NOECHO) $(SAY) "Uninstall is now deprecated and makes no actual changes."
  1531. $(NOECHO) $(SAY) "Please check the list above carefully for errors, and manually remove"
  1532. $(NOECHO) $(SAY) "the appropriate files. Sorry for the inconvenience."
  1533. uninstall_from_sitedirs ::
  1534. $(NOECHO) $(UNINSTALL) ],$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist'),"\n",q[
  1535. $(NOECHO) $(SAY) "Uninstall is now deprecated and makes no actual changes."
  1536. $(NOECHO) $(SAY) "Please check the list above carefully for errors, and manually remove"
  1537. $(NOECHO) $(SAY) "the appropriate files. Sorry for the inconvenience."
  1538. ];
  1539. join('',@m);
  1540. }
  1541. =item perldepend (override)
  1542. Use VMS-style syntax for files; it's cheaper to just do it directly here
  1543. than to have the MM_Unix method call C<catfile> repeatedly. Also, if
  1544. we have to rebuild Config.pm, use MM[SK] to do it.
  1545. =cut
  1546. sub perldepend {
  1547. my($self) = @_;
  1548. my(@m);
  1549. push @m, '
  1550. $(OBJECT) : $(PERL_INC)EXTERN.h, $(PERL_INC)INTERN.h, $(PERL_INC)XSUB.h, $(PERL_INC)av.h
  1551. $(OBJECT) : $(PERL_INC)cop.h, $(PERL_INC)cv.h, $(PERL_INC)embed.h, $(PERL_INC)form.h
  1552. $(OBJECT) : $(PERL_INC)gv.h, $(PERL_INC)handy.h, $(PERL_INC)hv.h, $(PERL_INC)keywords.h
  1553. $(OBJECT) : $(PERL_INC)mg.h, $(PERL_INC)op.h, $(PERL_INC)opcode.h, $(PERL_INC)patchlevel.h
  1554. $(OBJECT) : $(PERL_INC)perl.h, $(PERL_INC)perly.h, $(PERL_INC)pp.h, $(PERL_INC)proto.h
  1555. $(OBJECT) : $(PERL_INC)regcomp.h, $(PERL_INC)regexp.h, $(PERL_INC)scope.h, $(PERL_INC)sv.h
  1556. $(OBJECT) : $(PERL_INC)vmsish.h, $(PERL_INC)util.h, $(PERL_INC)config.h
  1557. $(OBJECT) : $(PERL_INC)iperlsys.h
  1558. ' if $self->{OBJECT};
  1559. if ($self->{PERL_SRC}) {
  1560. my(@macros);
  1561. my($mmsquals) = '$(USEMAKEFILE)[.vms]$(MAKEFILE)';
  1562. push(@macros,'__AXP__=1') if $Config{'arch'} eq 'VMS_AXP';
  1563. push(@macros,'DECC=1') if $Config{'vms_cc_type'} eq 'decc';
  1564. push(@macros,'GNUC=1') if $Config{'vms_cc_type'} eq 'gcc';
  1565. push(@macros,'SOCKET=1') if $Config{'d_has_sockets'};
  1566. push(@macros,qq["CC=$Config{'cc'}"]) if $Config{'cc'} =~ m!/!;
  1567. $mmsquals .= '$(USEMACROS)' . join(',',@macros) . '$(MACROEND)' if @macros;
  1568. push(@m,q[
  1569. # Check for unpropagated config.sh changes. Should never happen.
  1570. # We do NOT just update config.h because that is not sufficient.
  1571. # An out of date config.h is not fatal but complains loudly!
  1572. $(PERL_INC)config.h : $(PERL_SRC)config.sh
  1573. $(NOOP)
  1574. $(PERL_ARCHLIB)Config.pm : $(PERL_SRC)config.sh
  1575. $(NOECHO) Write Sys$Error "$(PERL_ARCHLIB)Config.pm may be out of date with config.h or genconfig.pl"
  1576. olddef = F$Environment("Default")
  1577. Set Default $(PERL_SRC)
  1578. $(MMS)],$mmsquals,);
  1579. if ($self->{PERL_ARCHLIB} =~ m|\[-| && $self->{PERL_SRC} =~ m|(\[-+)|) {
  1580. my($prefix,$target) = ($1,$self->fixpath('$(PERL_ARCHLIB)Config.pm',0));
  1581. $target =~ s/\Q$prefix/[/;
  1582. push(@m," $target");
  1583. }
  1584. else { push(@m,' $(MMS$TARGET)'); }
  1585. push(@m,q[
  1586. Set Default 'olddef'
  1587. ]);
  1588. }
  1589. push(@m, join(" ", map($self->fixpath($_,0),values %{$self->{XS}}))." : \$(XSUBPPDEPS)\n")
  1590. if %{$self->{XS}};
  1591. join('',@m);
  1592. }
  1593. =item makefile (override)
  1594. Use VMS commands and quoting.
  1595. =cut
  1596. sub makefile {
  1597. my($self) = @_;
  1598. my(@m,@cmd);
  1599. # We do not know what target was originally specified so we
  1600. # must force a manual rerun to be sure. But as it should only
  1601. # happen very rarely it is not a significant problem.
  1602. push @m, q[
  1603. $(OBJECT) : $(FIRST_MAKEFILE)
  1604. ] if $self->{OBJECT};
  1605. push @m,q[
  1606. # We take a very conservative approach here, but it\'s worth it.
  1607. # We move $(MAKEFILE) to $(MAKEFILE)_old here to avoid gnu make looping.
  1608. $(MAKEFILE) : Makefile.PL $(CONFIGDEP)
  1609. $(NOECHO) $(SAY) "$(MAKEFILE) out-of-date with respect to $(MMS$SOURCE_LIST)"
  1610. $(NOECHO) $(SAY) "Cleaning current config before rebuilding $(MAKEFILE) ..."
  1611. - $(MV) $(MAKEFILE) $(MAKEFILE)_old
  1612. - $(MMS)$(MMSQUALIFIERS) $(USEMAKEFILE)$(MAKEFILE)_old clean
  1613. $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL ],join(' ',map(qq["$_"],@ARGV)),q[
  1614. $(NOECHO) $(SAY) "$(MAKEFILE) has been rebuilt."
  1615. $(NOECHO) $(SAY) "Please run $(MMS) to build the extension."
  1616. ];
  1617. join('',@m);
  1618. }
  1619. =item test (override)
  1620. Use VMS commands for handling subdirectories.
  1621. =cut
  1622. sub test {
  1623. my($self, %attribs) = @_;
  1624. my($tests) = $attribs{TESTS} || ( -d 't' ? 't/*.t' : '');
  1625. my(@m);
  1626. push @m,"
  1627. TEST_VERBOSE = 0
  1628. TEST_TYPE = test_\$(LINKTYPE)
  1629. TEST_FILE = test.pl
  1630. TESTDB_SW = -d
  1631. test :: \$(TEST_TYPE)
  1632. \$(NOECHO) \$(NOOP)
  1633. testdb :: testdb_\$(LINKTYPE)
  1634. \$(NOECHO) \$(NOOP)
  1635. ";
  1636. foreach(@{$self->{DIR}}){
  1637. my($vmsdir) = $self->fixpath($_,1);
  1638. push(@m, ' If F$Search("',$vmsdir,'$(MAKEFILE)").nes."" Then $(PERL) -e "chdir ',"'$vmsdir'",
  1639. '; print `$(MMS)$(MMSQUALIFIERS) $(PASTHRU2) test`'."\n");
  1640. }
  1641. push(@m, "\t\$(NOECHO) \$(SAY) \"No tests defined for \$(NAME) extension.\"\n")
  1642. unless $tests or -f "test.pl" or @{$self->{DIR}};
  1643. push(@m, "\n");
  1644. push(@m, "test_dynamic :: pure_all\n");
  1645. push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
  1646. push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
  1647. push(@m, "\t\$(NOECHO) \$(NOOP)\n") if (!$tests && ! -f "test.pl");
  1648. push(@m, "\n");
  1649. push(@m, "testdb_dynamic :: pure_all\n");
  1650. push(@m, $self->test_via_script('$(FULLPERL) "$(TESTDB_SW)"', '$(TEST_FILE)'));
  1651. push(@m, "\n");
  1652. # Occasionally we may face this degenerate target:
  1653. push @m, "test_ : test_dynamic\n\n";
  1654. if ($self->needs_linking()) {
  1655. push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
  1656. push(@m, $self->test_via_harness('$(MAP_TARGET)', $tests)) if $tests;
  1657. push(@m, $self->test_via_script('$(MAP_TARGET)', 'test.pl')) if -f 'test.pl';
  1658. push(@m, "\n");
  1659. push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
  1660. push(@m, $self->test_via_script('$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
  1661. push(@m, "\n");
  1662. }
  1663. else {
  1664. push @m, "test_static :: test_dynamic\n\t\$(NOECHO) \$(NOOP)\n\n";
  1665. push @m, "testdb_static :: testdb_dynamic\n\t\$(NOECHO) \$(NOOP)\n";
  1666. }
  1667. join('',@m);
  1668. }
  1669. =item test_via_harness (override)
  1670. Use VMS-style quoting on command line.
  1671. =cut
  1672. sub test_via_harness {
  1673. my($self,$perl,$tests) = @_;
  1674. " $perl".' "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_LIB)" "-I$(PERL_ARCHLIB)" \\'."\n\t".
  1675. '-e "use Test::Harness qw(&runtests $verbose); $verbose=$(TEST_VERBOSE); runtests @ARGV;" \\'."\n\t$tests\n";
  1676. }
  1677. =item test_via_script (override)
  1678. Use VMS-style quoting on command line.
  1679. =cut
  1680. sub test_via_script {
  1681. my($self,$perl,$script) = @_;
  1682. " $perl".' "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" '.$script.'
  1683. ';
  1684. }
  1685. =item makeaperl (override)
  1686. Undertake to build a new set of Perl images using VMS commands. Since
  1687. VMS does dynamic loading, it's not necessary to statically link each
  1688. extension into the Perl image, so this isn't the normal build path.
  1689. Consequently, it hasn't really been tested, and may well be incomplete.
  1690. =cut
  1691. sub makeaperl {
  1692. my($self, %attribs) = @_;
  1693. my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
  1694. @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
  1695. my(@m);
  1696. push @m, "
  1697. # --- MakeMaker makeaperl section ---
  1698. MAP_TARGET = $target
  1699. ";
  1700. return join '', @m if $self->{PARENT};
  1701. my($dir) = join ":", @{$self->{DIR}};
  1702. unless ($self->{MAKEAPERL}) {
  1703. push @m, q{
  1704. $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
  1705. $(NOECHO) $(SAY) "Writing ""$(MMS$TARGET)"" for this $(MAP_TARGET)"
  1706. $(NOECHO) $(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
  1707. Makefile.PL DIR=}, $dir, q{ \
  1708. MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
  1709. MAKEAPERL=1 NORECURS=1 };
  1710. push @m, map(q[ \\\n\t\t"$_"], @ARGV),q{
  1711. $(MAP_TARGET) :: $(MAKE_APERL_FILE)
  1712. $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(MAKE_APERL_FILE) static $(MMS$TARGET)
  1713. };
  1714. push @m, "\n";
  1715. return join '', @m;
  1716. }
  1717. my($linkcmd,@optlibs,@staticpkgs,$extralist,$targdir,$libperldir,%libseen);
  1718. local($_);
  1719. # The front matter of the linkcommand...
  1720. $linkcmd = join ' ', $Config{'ld'},
  1721. grep($_, @Config{qw(large split ldflags ccdlflags)});
  1722. $linkcmd =~ s/\s+/ /g;
  1723. # Which *.olb files could we make use of...
  1724. local(%olbs);
  1725. $olbs{$self->{INST_ARCHAUTODIR}} = "$self->{BASEEXT}\$(LIB_EXT)";
  1726. require File::Find;
  1727. File::Find::find(sub {
  1728. return unless m/\Q$self->{LIB_EXT}\E$/;
  1729. return if m/^libperl/;
  1730. if( exists $self->{INCLUDE_EXT} ){
  1731. my $found = 0;
  1732. my $incl;
  1733. my $xx;
  1734. ($xx = $File::Find::name) =~ s,.*?/auto/,,;
  1735. $xx =~ s,/?$_,,;
  1736. $xx =~ s,/,::,g;
  1737. # Throw away anything not explicitly marked for inclusion.
  1738. # DynaLoader is implied.
  1739. foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
  1740. if( $xx eq $incl ){
  1741. $found++;
  1742. last;
  1743. }
  1744. }
  1745. return unless $found;
  1746. }
  1747. elsif( exists $self->{EXCLUDE_EXT} ){
  1748. my $excl;
  1749. my $xx;
  1750. ($xx = $File::Find::name) =~ s,.*?/auto/,,;
  1751. $xx =~ s,/?$_,,;
  1752. $xx =~ s,/,::,g;
  1753. # Throw away anything explicitly marked for exclusion
  1754. foreach $excl (@{$self->{EXCLUDE_EXT}}){
  1755. return if( $xx eq $excl );
  1756. }
  1757. }
  1758. $olbs{$ENV{DEFAULT}} = $_;
  1759. }, grep( -d $_, @{$searchdirs || []}));
  1760. # We trust that what has been handed in as argument will be buildable
  1761. $static = [] unless $static;
  1762. @olbs{@{$static}} = (1) x @{$static};
  1763. $extra = [] unless $extra && ref $extra eq 'ARRAY';
  1764. # Sort the object libraries in inverse order of
  1765. # filespec length to try to insure that dependent extensions
  1766. # will appear before their parents, so the linker will
  1767. # search the parent library to resolve references.
  1768. # (e.g. Intuit::DWIM will precede Intuit, so unresolved
  1769. # references from [.intuit.dwim]dwim.obj can be found
  1770. # in [.intuit]intuit.olb).
  1771. for (sort { length($a) <=> length($b) } keys %olbs) {
  1772. next unless $olbs{$_} =~ /\Q$self->{LIB_EXT}\E$/;
  1773. my($dir) = $self->fixpath($_,1);
  1774. my($extralibs) = $dir . "extralibs.ld";
  1775. my($extopt) = $dir . $olbs{$_};
  1776. $extopt =~ s/$self->{LIB_EXT}$/.opt/;
  1777. push @optlibs, "$dir$olbs{$_}";
  1778. # Get external libraries this extension will need
  1779. if (-f $extralibs ) {
  1780. my %seenthis;
  1781. open LIST,$extralibs or warn $!,next;
  1782. while (<LIST>) {
  1783. chomp;
  1784. # Include a library in the link only once, unless it's mentioned
  1785. # multiple times within a single extension's options file, in which
  1786. # case we assume the builder needed to search it again later in the
  1787. # link.
  1788. my $skip = exists($libseen{$_}) && !exists($seenthis{$_});
  1789. $libseen{$_}++; $seenthis{$_}++;
  1790. next if $skip;
  1791. push @$extra,$_;
  1792. }
  1793. close LIST;
  1794. }
  1795. # Get full name of extension for ExtUtils::Miniperl
  1796. if (-f $extopt) {
  1797. open OPT,$extopt or die $!;
  1798. while (<OPT>) {
  1799. next unless /(?:UNIVERSAL|VECTOR)=boot_([\w_]+)/;
  1800. my $pkg = $1;
  1801. $pkg =~ s#__*#::#g;
  1802. push @staticpkgs,$pkg;
  1803. }
  1804. }
  1805. }
  1806. # Place all of the external libraries after all of the Perl extension
  1807. # libraries in the final link, in order to maximize the opportunity
  1808. # for XS code from multiple extensions to resolve symbols against the
  1809. # same external library while only including that library once.
  1810. push @optlibs, @$extra;
  1811. $target = "Perl$Config{'exe_ext'}" unless $target;
  1812. ($shrtarget,$targdir) = fileparse($target);
  1813. $shrtarget =~ s/^([^.]*)/$1Shr/;
  1814. $shrtarget = $targdir . $shrtarget;
  1815. $target = "Perlshr.$Config{'dlext'}" unless $target;
  1816. $tmp = "[]" unless $tmp;
  1817. $tmp = $self->fixpath($tmp,1);
  1818. if (@optlibs) { $extralist = join(' ',@optlibs); }
  1819. else { $extralist = ''; }
  1820. # Let ExtUtils::Liblist find the necessary libs for us (but skip PerlShr)
  1821. # that's what we're building here).
  1822. push @optlibs, grep { !/PerlShr/i } split ' ', +($self->ext())[2];
  1823. if ($libperl) {
  1824. unless (-f $libperl || -f ($libperl = $self->catfile($Config{'installarchlib'},'CORE',$libperl))) {
  1825. print STDOUT "Warning: $libperl not found\n";
  1826. undef $libperl;
  1827. }
  1828. }
  1829. unless ($libperl) {
  1830. if (defined $self->{PERL_SRC}) {
  1831. $libperl = $self->catfile($self->{PERL_SRC},"libperl$self->{LIB_EXT}");
  1832. } elsif (-f ($libperl = $self->catfile($Config{'installarchlib'},'CORE',"libperl$self->{LIB_EXT}")) ) {
  1833. } else {
  1834. print STDOUT "Warning: $libperl not found
  1835. If you're going to build a static perl binary, make sure perl is installed
  1836. otherwise ignore this warning\n";
  1837. }
  1838. }
  1839. $libperldir = $self->fixpath((fileparse($libperl))[1],1);
  1840. push @m, '
  1841. # Fill in the target you want to produce if it\'s not perl
  1842. MAP_TARGET = ',$self->fixpath($target,0),'
  1843. MAP_SHRTARGET = ',$self->fixpath($shrtarget,0),"
  1844. MAP_LINKCMD = $linkcmd
  1845. MAP_PERLINC = ", $perlinc ? map('"$_" ',@{$perlinc}) : '',"
  1846. MAP_EXTRA = $extralist
  1847. MAP_LIBPERL = ",$self->fixpath($libperl,0),'
  1848. ';
  1849. push @m,"\n${tmp}Makeaperl.Opt : \$(MAP_EXTRA)\n";
  1850. foreach (@optlibs) {
  1851. push @m,' $(NOECHO) $(PERL) -e "print q{',$_,'}" >>$(MMS$TARGET)',"\n";
  1852. }
  1853. push @m,"\n${tmp}PerlShr.Opt :\n\t";
  1854. push @m,'$(NOECHO) $(PERL) -e "print q{$(MAP_SHRTARGET)}" >$(MMS$TARGET)',"\n";
  1855. push @m,'
  1856. $(MAP_SHRTARGET) : $(MAP_LIBPERL) Makeaperl.Opt ',"${libperldir}Perlshr_Attr.Opt",'
  1857. $(MAP_LINKCMD)/Shareable=$(MMS$TARGET) $(MAP_LIBPERL), Makeaperl.Opt/Option ',"${libperldir}Perlshr_Attr.Opt/Option",'
  1858. $(MAP_TARGET) : $(MAP_SHRTARGET) ',"${tmp}perlmain\$(OBJ_EXT) ${tmp}PerlShr.Opt",'
  1859. $(MAP_LINKCMD) ',"${tmp}perlmain\$(OBJ_EXT)",', PerlShr.Opt/Option
  1860. $(NOECHO) $(SAY) "To install the new ""$(MAP_TARGET)"" binary, say"
  1861. $(NOECHO) $(SAY) " $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(MAKEFILE) inst_perl $(USEMACROS)MAP_TARGET=$(MAP_TARGET)$(ENDMACRO)"
  1862. $(NOECHO) $(SAY) "To remove the intermediate files, say
  1863. $(NOECHO) $(SAY) " $(MMS)$(MMSQUALIFIERS)$(USEMAKEFILE)$(MAKEFILE) map_clean"
  1864. ';
  1865. push @m,"\n${tmp}perlmain.c : \$(MAKEFILE)\n\t\$(NOECHO) \$(PERL) -e 1 >${tmp}Writemain.tmp\n";
  1866. push @m, "# More from the 255-char line length limit\n";
  1867. foreach (@staticpkgs) {
  1868. push @m,' $(NOECHO) $(PERL) -e "print q{',$_,qq[}" >>${tmp}Writemain.tmp\n];
  1869. }
  1870. push @m,'
  1871. $(NOECHO) $(PERL) $(MAP_PERLINC) -ane "use ExtUtils::Miniperl; writemain(@F)" ',$tmp,'Writemain.tmp >$(MMS$TARGET)
  1872. $(NOECHO) $(RM_F) ',"${tmp}Writemain.tmp\n";
  1873. push @m, q[
  1874. # Still more from the 255-char line length limit
  1875. doc_inst_perl :
  1876. $(NOECHO) $(PERL) -e "print 'Perl binary $(MAP_TARGET)|'" >.MM_tmp
  1877. $(NOECHO) $(PERL) -e "print 'MAP_STATIC|$(MAP_STATIC)|'" >>.MM_tmp
  1878. $(NOECHO) $(PERL) -pl040 -e " " ].$self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'),q[ >>.MM_tmp
  1879. $(NOECHO) $(PERL) -e "print 'MAP_LIBPERL|$(MAP_LIBPERL)|'" >>.MM_tmp
  1880. $(DOC_INSTALL) <.MM_tmp >>].$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q[
  1881. $(NOECHO) Delete/NoLog/NoConfirm .MM_tmp;
  1882. ];
  1883. push @m, "
  1884. inst_perl : pure_inst_perl doc_inst_perl
  1885. \$(NOECHO) \$(NOOP)
  1886. pure_inst_perl : \$(MAP_TARGET)
  1887. $self->{CP} \$(MAP_SHRTARGET) ",$self->fixpath($Config{'installbin'},1),"
  1888. $self->{CP} \$(MAP_TARGET) ",$self->fixpath($Config{'installbin'},1),"
  1889. clean :: map_clean
  1890. \$(NOECHO) \$(NOOP)
  1891. map_clean :
  1892. \$(RM_F) ${tmp}perlmain\$(OBJ_EXT) ${tmp}perlmain.c \$(MAKEFILE)
  1893. \$(RM_F) ${tmp}Makeaperl.Opt ${tmp}PerlShr.Opt \$(MAP_TARGET)
  1894. ";
  1895. join '', @m;
  1896. }
  1897. # --- Output postprocessing section ---
  1898. =item nicetext (override)
  1899. Insure that colons marking targets are preceded by space, in order
  1900. to distinguish the target delimiter from a colon appearing as
  1901. part of a filespec.
  1902. =cut
  1903. sub nicetext {
  1904. my($self,$text) = @_;
  1905. $text =~ s/([^\s:])(:+\s)/$1 $2/gs;
  1906. $text;
  1907. }
  1908. 1;
  1909. =back
  1910. =cut
  1911. __END__