PageRenderTime 61ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Runtime/Tests/LinqDlrTests/testenv/perl/lib/ExtUtils/MM_Win32.pm

#
Perl | 957 lines | 859 code | 69 blank | 29 comment | 48 complexity | ddfbdc560c228ecd3beb4aae754523b9 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. package ExtUtils::MM_Win32;
  2. =head1 NAME
  3. ExtUtils::MM_Win32 - methods to override UN*X behaviour in ExtUtils::MakeMaker
  4. =head1 SYNOPSIS
  5. use ExtUtils::MM_Win32; # Done internally by ExtUtils::MakeMaker if needed
  6. =head1 DESCRIPTION
  7. See ExtUtils::MM_Unix for a documentation of the methods provided
  8. there. This package overrides the implementation of these methods, not
  9. the semantics.
  10. =over
  11. =cut
  12. use Config;
  13. #use Cwd;
  14. use File::Basename;
  15. require Exporter;
  16. Exporter::import('ExtUtils::MakeMaker',
  17. qw( $Verbose &neatvalue));
  18. $ENV{EMXSHELL} = 'sh'; # to run `commands`
  19. unshift @MM::ISA, 'ExtUtils::MM_Win32';
  20. $BORLAND = 1 if $Config{'cc'} =~ /^bcc/i;
  21. $GCC = 1 if $Config{'cc'} =~ /^gcc/i;
  22. $DMAKE = 1 if $Config{'make'} =~ /^dmake/i;
  23. $NMAKE = 1 if $Config{'make'} =~ /^nmake/i;
  24. $PERLMAKE = 1 if $Config{'make'} =~ /^pmake/i;
  25. $OBJ = 1 if $Config{'ccflags'} =~ /PERL_OBJECT/i;
  26. # a few workarounds for command.com (very basic)
  27. {
  28. package ExtUtils::MM_Win95;
  29. # the $^O test may be overkill, but we want to be sure Win32::IsWin95()
  30. # exists before we try it
  31. unshift @MM::ISA, 'ExtUtils::MM_Win95'
  32. if ($^O =~ /Win32/ && Win32::IsWin95());
  33. sub xs_c {
  34. my($self) = shift;
  35. return '' unless $self->needs_linking();
  36. '
  37. .xs.c:
  38. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
  39. $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c
  40. '
  41. }
  42. sub xs_cpp {
  43. my($self) = shift;
  44. return '' unless $self->needs_linking();
  45. '
  46. .xs.cpp:
  47. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
  48. $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.cpp
  49. ';
  50. }
  51. # many makes are too dumb to use xs_c then c_o
  52. sub xs_o {
  53. my($self) = shift;
  54. return '' unless $self->needs_linking();
  55. '
  56. .xs$(OBJ_EXT):
  57. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) \\
  58. $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.c
  59. $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
  60. ';
  61. }
  62. } # end of command.com workarounds
  63. sub dlsyms {
  64. my($self,%attribs) = @_;
  65. my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
  66. my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
  67. my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
  68. my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {};
  69. my(@m);
  70. (my $boot = $self->{NAME}) =~ s/:/_/g;
  71. if (not $self->{SKIPHASH}{'dynamic'}) {
  72. push(@m,"
  73. $self->{BASEEXT}.def: Makefile.PL
  74. ",
  75. q! $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Mksymlists \\
  76. -e "Mksymlists('NAME' => '!, $self->{NAME},
  77. q!', 'DLBASE' => '!,$self->{DLBASE},
  78. q!', 'DL_FUNCS' => !,neatvalue($funcs),
  79. q!, 'FUNCLIST' => !,neatvalue($funclist),
  80. q!, 'IMPORTS' => !,neatvalue($imports),
  81. q!, 'DL_VARS' => !, neatvalue($vars), q!);"
  82. !);
  83. }
  84. join('',@m);
  85. }
  86. sub replace_manpage_separator {
  87. my($self,$man) = @_;
  88. $man =~ s,/+,.,g;
  89. $man;
  90. }
  91. sub maybe_command {
  92. my($self,$file) = @_;
  93. my @e = exists($ENV{'PATHEXT'})
  94. ? split(/;/, $ENV{PATHEXT})
  95. : qw(.com .exe .bat .cmd);
  96. my $e = '';
  97. for (@e) { $e .= "\Q$_\E|" }
  98. chop $e;
  99. # see if file ends in one of the known extensions
  100. if ($file =~ /($e)$/i) {
  101. return $file if -e $file;
  102. }
  103. else {
  104. for (@e) {
  105. return "$file$_" if -e "$file$_";
  106. }
  107. }
  108. return;
  109. }
  110. sub file_name_is_absolute {
  111. my($self,$file) = @_;
  112. $file =~ m{^([a-z]:)?[\\/]}i ;
  113. }
  114. sub find_perl {
  115. my($self, $ver, $names, $dirs, $trace) = @_;
  116. my($name, $dir);
  117. if ($trace >= 2){
  118. print "Looking for perl $ver by these names:
  119. @$names
  120. in these dirs:
  121. @$dirs
  122. ";
  123. }
  124. foreach $dir (@$dirs){
  125. next unless defined $dir; # $self->{PERL_SRC} may be undefined
  126. foreach $name (@$names){
  127. my ($abs, $val);
  128. if ($self->file_name_is_absolute($name)) { # /foo/bar
  129. $abs = $name;
  130. } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo
  131. $abs = $self->catfile($dir, $name);
  132. } else { # foo/bar
  133. $abs = $self->canonpath($self->catfile($self->curdir, $name));
  134. }
  135. print "Checking $abs\n" if ($trace >= 2);
  136. next unless $self->maybe_command($abs);
  137. print "Executing $abs\n" if ($trace >= 2);
  138. $val = `$abs -e "require $ver;" 2>&1`;
  139. if ($? == 0) {
  140. print "Using PERL=$abs\n" if $trace;
  141. return $abs;
  142. } elsif ($trace >= 2) {
  143. print "Result: `$val'\n";
  144. }
  145. }
  146. }
  147. print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
  148. 0; # false and not empty
  149. }
  150. sub catdir {
  151. my $self = shift;
  152. my @args = @_;
  153. for (@args) {
  154. # append a slash to each argument unless it has one there
  155. $_ .= "\\" if $_ eq '' or substr($_,-1) ne "\\";
  156. }
  157. my $result = $self->canonpath(join('', @args));
  158. $result;
  159. }
  160. =item catfile
  161. Concatenate one or more directory names and a filename to form a
  162. complete path ending with a filename
  163. =cut
  164. sub catfile {
  165. my $self = shift @_;
  166. my $file = pop @_;
  167. return $file unless @_;
  168. my $dir = $self->catdir(@_);
  169. $dir =~ s/(\\\.)$//;
  170. $dir .= "\\" unless substr($dir,length($dir)-1,1) eq "\\";
  171. return $dir.$file;
  172. }
  173. sub init_others
  174. {
  175. my ($self) = @_;
  176. &ExtUtils::MM_Unix::init_others;
  177. $self->{'TOUCH'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e touch';
  178. $self->{'CHMOD'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e chmod';
  179. $self->{'CP'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e cp';
  180. $self->{'RM_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_f';
  181. $self->{'RM_RF'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e rm_rf';
  182. $self->{'MV'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mv';
  183. $self->{'NOOP'} = 'rem';
  184. $self->{'TEST_F'} = '$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e test_f';
  185. $self->{'LD'} = $Config{'ld'} || 'link';
  186. $self->{'AR'} = $Config{'ar'} || 'lib';
  187. $self->{'LDLOADLIBS'} ||= $Config{'libs'};
  188. # -Lfoo must come first for Borland, so we put it in LDDLFLAGS
  189. if ($BORLAND) {
  190. my $libs = $self->{'LDLOADLIBS'};
  191. my $libpath = '';
  192. while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
  193. $libpath .= ' ' if length $libpath;
  194. $libpath .= $1;
  195. }
  196. $self->{'LDLOADLIBS'} = $libs;
  197. $self->{'LDDLFLAGS'} ||= $Config{'lddlflags'};
  198. $self->{'LDDLFLAGS'} .= " $libpath";
  199. }
  200. $self->{'DEV_NULL'} = '> NUL';
  201. # $self->{'NOECHO'} = ''; # till we have it working
  202. }
  203. =item constants (o)
  204. Initializes lots of constants and .SUFFIXES and .PHONY
  205. =cut
  206. sub constants {
  207. my($self) = @_;
  208. my(@m,$tmp);
  209. for $tmp (qw/
  210. AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
  211. VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB
  212. INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
  213. INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
  214. INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
  215. PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
  216. FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
  217. PERL_INC PERL FULLPERL
  218. / ) {
  219. next unless defined $self->{$tmp};
  220. push @m, "$tmp = $self->{$tmp}\n";
  221. }
  222. push @m, qq{
  223. VERSION_MACRO = VERSION
  224. DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
  225. XS_VERSION_MACRO = XS_VERSION
  226. XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
  227. };
  228. push @m, qq{
  229. MAKEMAKER = $INC{'ExtUtils\MakeMaker.pm'}
  230. MM_VERSION = $ExtUtils::MakeMaker::VERSION
  231. };
  232. push @m, q{
  233. # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
  234. # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
  235. # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!!
  236. # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
  237. # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
  238. };
  239. for $tmp (qw/
  240. FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
  241. LDFROM LINKTYPE
  242. / ) {
  243. next unless defined $self->{$tmp};
  244. push @m, "$tmp = $self->{$tmp}\n";
  245. }
  246. push @m, "
  247. # Handy lists of source code files:
  248. XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
  249. C_FILES = ".join(" \\\n\t", @{$self->{C}})."
  250. O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
  251. H_FILES = ".join(" \\\n\t", @{$self->{H}})."
  252. HTMLLIBPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLLIBPODS}})."
  253. HTMLSCRIPTPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLSCRIPTPODS}})."
  254. MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
  255. MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
  256. ";
  257. for $tmp (qw/
  258. INST_HTMLPRIVLIBDIR INSTALLHTMLPRIVLIBDIR
  259. INST_HTMLSITELIBDIR INSTALLHTMLSITELIBDIR
  260. INST_HTMLSCRIPTDIR INSTALLHTMLSCRIPTDIR
  261. INST_HTMLLIBDIR HTMLEXT
  262. INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
  263. INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
  264. /) {
  265. next unless defined $self->{$tmp};
  266. push @m, "$tmp = $self->{$tmp}\n";
  267. }
  268. push @m, qq{
  269. .USESHELL :
  270. } if $DMAKE;
  271. push @m, q{
  272. .NO_CONFIG_REC: Makefile
  273. } if $ENV{CLEARCASE_ROOT};
  274. # why not q{} ? -- emacs
  275. push @m, qq{
  276. # work around a famous dec-osf make(1) feature(?):
  277. makemakerdflt: all
  278. .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
  279. # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
  280. # some make implementations will delete the Makefile when we rebuild it. Because
  281. # we call false(1) when we rebuild it. So make(1) is not completely wrong when it
  282. # does so. Our milage may vary.
  283. # .PRECIOUS: Makefile # seems to be not necessary anymore
  284. .PHONY: all config static dynamic test linkext manifest
  285. # Where is the Config information that we are using/depend on
  286. CONFIGDEP = \$(PERL_ARCHLIB)\\Config.pm \$(PERL_INC)\\config.h
  287. };
  288. my @parentdir = split(/::/, $self->{PARENT_NAME});
  289. push @m, q{
  290. # Where to put things:
  291. INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{
  292. INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{
  293. INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
  294. INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
  295. };
  296. if ($self->has_link_code()) {
  297. push @m, '
  298. INST_STATIC = $(INST_ARCHAUTODIR)\$(BASEEXT)$(LIB_EXT)
  299. INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)
  300. INST_BOOT = $(INST_ARCHAUTODIR)\$(BASEEXT).bs
  301. ';
  302. } else {
  303. push @m, '
  304. INST_STATIC =
  305. INST_DYNAMIC =
  306. INST_BOOT =
  307. ';
  308. }
  309. $tmp = $self->export_list;
  310. push @m, "
  311. EXPORT_LIST = $tmp
  312. ";
  313. $tmp = $self->perl_archive;
  314. push @m, "
  315. PERL_ARCHIVE = $tmp
  316. ";
  317. # push @m, q{
  318. #INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
  319. #
  320. #PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
  321. #};
  322. push @m, q{
  323. TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
  324. PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
  325. };
  326. join('',@m);
  327. }
  328. sub path {
  329. my($self) = @_;
  330. my $path = $ENV{'PATH'} || $ENV{'Path'} || $ENV{'path'};
  331. my @path = split(';',$path);
  332. foreach(@path) { $_ = '.' if $_ eq '' }
  333. @path;
  334. }
  335. =item static_lib (o)
  336. Defines how to produce the *.a (or equivalent) files.
  337. =cut
  338. sub static_lib {
  339. my($self) = @_;
  340. # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
  341. # return '' unless $self->needs_linking(); #might be because of a subdir
  342. return '' unless $self->has_link_code;
  343. my(@m);
  344. push(@m, <<'END');
  345. $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)\.exists
  346. $(RM_RF) $@
  347. END
  348. # If this extension has it's own library (eg SDBM_File)
  349. # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
  350. push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
  351. push @m,
  352. q{ $(AR) }.($BORLAND ? '$@ $(OBJECT:^"+")'
  353. : ($GCC ? '-ru $@ $(OBJECT)'
  354. : '-out:$@ $(OBJECT)')).q{
  355. }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)\extralibs.ld
  356. $(CHMOD) 755 $@
  357. };
  358. # Old mechanism - still available:
  359. push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)\ext.libs}."\n\n"
  360. if $self->{PERL_SRC};
  361. push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  362. join('', "\n",@m);
  363. }
  364. =item dynamic_bs (o)
  365. Defines targets for bootstrap files.
  366. =cut
  367. sub dynamic_bs {
  368. my($self, %attribs) = @_;
  369. return '
  370. BOOTSTRAP =
  371. ' unless $self->has_link_code();
  372. return '
  373. BOOTSTRAP = '."$self->{BASEEXT}.bs".'
  374. # As Mkbootstrap might not write a file (if none is required)
  375. # we use touch to prevent make continually trying to remake it.
  376. # The DynaLoader only reads a non-empty file.
  377. $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)\.exists
  378. '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
  379. '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
  380. -MExtUtils::Mkbootstrap \
  381. -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
  382. '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
  383. $(CHMOD) 644 $@
  384. $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists
  385. '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
  386. -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
  387. $(CHMOD) 644 $@
  388. ';
  389. }
  390. =item dynamic_lib (o)
  391. Defines how to produce the *.so (or equivalent) files.
  392. =cut
  393. sub dynamic_lib {
  394. my($self, %attribs) = @_;
  395. return '' unless $self->needs_linking(); #might be because of a subdir
  396. return '' unless $self->has_link_code;
  397. my($otherldflags) = $attribs{OTHERLDFLAGS} || ($BORLAND ? 'c0d32.obj': '');
  398. my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
  399. my($ldfrom) = '$(LDFROM)';
  400. my(@m);
  401. # one thing for GCC/Mingw32:
  402. # we try to overcome non-relocateable-DLL problems by generating
  403. # a (hopefully unique) image-base from the dll's name
  404. # -- BKS, 10-19-1999
  405. if ($GCC) {
  406. my $dllname = $self->{BASEEXT} . "." . $self->{DLEXT};
  407. $dllname =~ /(....)(.{0,4})/;
  408. my $baseaddr = unpack("n", $1 ^ $2);
  409. $otherldflags .= sprintf("-Wl,--image-base,0x%x0000 ", $baseaddr);
  410. }
  411. push(@m,'
  412. # This section creates the dynamically loadable $(INST_DYNAMIC)
  413. # from $(OBJECT) and possibly $(MYEXTLIB).
  414. OTHERLDFLAGS = '.$otherldflags.'
  415. INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
  416. $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)\.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(INST_DYNAMIC_DEP)
  417. ');
  418. if ($GCC) {
  419. push(@m,
  420. q{ dlltool --def $(EXPORT_LIST) --output-exp dll.exp
  421. $(LD) -o $@ -Wl,--base-file -Wl,dll.base $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp
  422. dlltool --def $(EXPORT_LIST) --base-file dll.base --output-exp dll.exp
  423. $(LD) -o $@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) dll.exp });
  424. } elsif ($BORLAND) {
  425. push(@m,
  426. q{ $(LD) $(LDDLFLAGS) $(OTHERLDFLAGS) }.$ldfrom.q{,$@,,}
  427. .($DMAKE ? q{$(PERL_ARCHIVE:s,/,\,) $(LDLOADLIBS:s,/,\,) }
  428. .q{$(MYEXTLIB:s,/,\,),$(EXPORT_LIST:s,/,\,)}
  429. : q{$(subst /,\,$(PERL_ARCHIVE)) $(subst /,\,$(LDLOADLIBS)) }
  430. .q{$(subst /,\,$(MYEXTLIB)),$(subst /,\,$(EXPORT_LIST))})
  431. .q{,$(RESFILES)});
  432. } else { # VC
  433. push(@m,
  434. q{ $(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
  435. .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
  436. }
  437. push @m, '
  438. $(CHMOD) 755 $@
  439. ';
  440. push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  441. join('',@m);
  442. }
  443. sub perl_archive
  444. {
  445. my ($self) = @_;
  446. return '$(PERL_INC)\\'.$Config{'libperl'};
  447. }
  448. sub export_list
  449. {
  450. my ($self) = @_;
  451. return "$self->{BASEEXT}.def";
  452. }
  453. =item canonpath
  454. No physical check on the filesystem, but a logical cleanup of a
  455. path. On UNIX eliminated successive slashes and successive "/.".
  456. =cut
  457. sub canonpath {
  458. my($self,$path) = @_;
  459. $path =~ s/^([a-z]:)/\u$1/;
  460. $path =~ s|/|\\|g;
  461. $path =~ s|(.)\\+|$1\\|g ; # xx////xx -> xx/xx
  462. $path =~ s|(\\\.)+\\|\\|g ; # xx/././xx -> xx/xx
  463. $path =~ s|^(\.\\)+|| unless $path eq ".\\"; # ./xx -> xx
  464. $path =~ s|\\$||
  465. unless $path =~ m#^([a-z]:)?\\#; # xx/ -> xx
  466. $path .= '.' if $path =~ m#\\$#;
  467. $path;
  468. }
  469. =item perl_script
  470. Takes one argument, a file name, and returns the file name, if the
  471. argument is likely to be a perl script. On MM_Unix this is true for
  472. any ordinary, readable file.
  473. =cut
  474. sub perl_script {
  475. my($self,$file) = @_;
  476. return $file if -r $file && -f _;
  477. return "$file.pl" if -r "$file.pl" && -f _;
  478. return "$file.bat" if -r "$file.bat" && -f _;
  479. return;
  480. }
  481. =item pm_to_blib
  482. Defines target that copies all files in the hash PM to their
  483. destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
  484. =cut
  485. sub pm_to_blib {
  486. my $self = shift;
  487. my($autodir) = $self->catdir('$(INST_LIB)','auto');
  488. return q{
  489. pm_to_blib: $(TO_INST_PM)
  490. }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
  491. "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
  492. -e "pm_to_blib(}.
  493. ($NMAKE ? 'qw[ <<pmfiles.dat ],'
  494. : $DMAKE ? 'qw[ $(mktmp,pmfiles.dat $(PM_TO_BLIB:s,\\,\\\\,)\n) ],'
  495. : '{ qw[$(PM_TO_BLIB)] },'
  496. ).q{'}.$autodir.q{','$(PM_FILTER)')"
  497. }. ($NMAKE ? q{
  498. $(PM_TO_BLIB)
  499. <<
  500. } : '') . $self->{NOECHO}.q{$(TOUCH) $@
  501. };
  502. }
  503. =item test_via_harness (o)
  504. Helper method to write the test targets
  505. =cut
  506. sub test_via_harness {
  507. my($self, $perl, $tests) = @_;
  508. "\t$perl".q! -Mblib -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e "use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;" !."$tests\n";
  509. }
  510. =item tool_autosplit (override)
  511. Use Win32 quoting on command line.
  512. =cut
  513. sub tool_autosplit{
  514. my($self, %attribs) = @_;
  515. my($asl) = "";
  516. $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
  517. q{
  518. # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
  519. AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MAutoSplit }.$asl.q{ -e "autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1);"
  520. };
  521. }
  522. =item tools_other (o)
  523. Win32 overrides.
  524. Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
  525. the Makefile. Also defines the perl programs MKPATH,
  526. WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
  527. =cut
  528. sub tools_other {
  529. my($self) = shift;
  530. my @m;
  531. my $bin_sh = $Config{sh} || 'cmd /c';
  532. push @m, qq{
  533. SHELL = $bin_sh
  534. } unless $DMAKE; # dmake determines its own shell
  535. for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
  536. push @m, "$_ = $self->{$_}\n";
  537. }
  538. push @m, q{
  539. # The following is a portable way to say mkdir -p
  540. # To see which directories are created, change the if 0 to if 1
  541. MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
  542. # This helps us to minimize the effect of the .exists files A yet
  543. # better solution would be to have a stable file in the perl
  544. # distribution with a timestamp of zero. But this solution doesn't
  545. # need any changes to the core distribution and works with older perls
  546. EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
  547. };
  548. return join "", @m if $self->{PARENT};
  549. push @m, q{
  550. # Here we warn users that an old packlist file was found somewhere,
  551. # and that they should call some uninstall routine
  552. WARN_IF_OLD_PACKLIST = $(PERL) -lwe "exit unless -f $$ARGV[0];" \\
  553. -e "print 'WARNING: I have found an old package in';" \\
  554. -e "print ' ', $$ARGV[0], '.';" \\
  555. -e "print 'Please make sure the two installations are not conflicting';"
  556. UNINST=0
  557. VERBINST=1
  558. MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
  559. -e "install({ @ARGV },'$(VERBINST)',0,'$(UNINST)');"
  560. DOC_INSTALL = $(PERL) -e "$$\=\"\n\n\";" \
  561. -e "print '=head2 ', scalar(localtime), ': C<', shift, '>', ' L<', $$arg=shift, '|', $$arg, '>';" \
  562. -e "print '=over 4';" \
  563. -e "while (defined($$key = shift) and defined($$val = shift)) { print '=item *';print 'C<', \"$$key: $$val\", '>'; }" \
  564. -e "print '=back';"
  565. UNINSTALL = $(PERL) -MExtUtils::Install \
  566. -e "uninstall($$ARGV[0],1,1); print \"\nUninstall is deprecated. Please check the";" \
  567. -e "print \" packlist above carefully.\n There may be errors. Remove the\";" \
  568. -e "print \" appropriate files manually.\n Sorry for the inconveniences.\n\""
  569. };
  570. return join "", @m;
  571. }
  572. =item xs_o (o)
  573. Defines suffix rules to go from XS to object files directly. This is
  574. only intended for broken make implementations.
  575. =cut
  576. sub xs_o { # many makes are too dumb to use xs_c then c_o
  577. my($self) = shift;
  578. return ''
  579. }
  580. =item top_targets (o)
  581. Defines the targets all, subdirs, config, and O_FILES
  582. =cut
  583. sub top_targets {
  584. # --- Target Sections ---
  585. my($self) = shift;
  586. my(@m);
  587. push @m, '
  588. #all :: config $(INST_PM) subdirs linkext manifypods
  589. ';
  590. push @m, '
  591. all :: pure_all htmlifypods manifypods
  592. '.$self->{NOECHO}.'$(NOOP)
  593. '
  594. unless $self->{SKIPHASH}{'all'};
  595. push @m, '
  596. pure_all :: config pm_to_blib subdirs linkext
  597. '.$self->{NOECHO}.'$(NOOP)
  598. subdirs :: $(MYEXTLIB)
  599. '.$self->{NOECHO}.'$(NOOP)
  600. config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)\.exists
  601. '.$self->{NOECHO}.'$(NOOP)
  602. config :: $(INST_ARCHAUTODIR)\.exists
  603. '.$self->{NOECHO}.'$(NOOP)
  604. config :: $(INST_AUTODIR)\.exists
  605. '.$self->{NOECHO}.'$(NOOP)
  606. ';
  607. push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
  608. if (%{$self->{HTMLLIBPODS}}) {
  609. push @m, qq[
  610. config :: \$(INST_HTMLLIBDIR)/.exists
  611. $self->{NOECHO}\$(NOOP)
  612. ];
  613. push @m, $self->dir_target(qw[$(INST_HTMLLIBDIR)]);
  614. }
  615. if (%{$self->{HTMLSCRIPTPODS}}) {
  616. push @m, qq[
  617. config :: \$(INST_HTMLSCRIPTDIR)/.exists
  618. $self->{NOECHO}\$(NOOP)
  619. ];
  620. push @m, $self->dir_target(qw[$(INST_HTMLSCRIPTDIR)]);
  621. }
  622. if (%{$self->{MAN1PODS}}) {
  623. push @m, qq[
  624. config :: \$(INST_MAN1DIR)\\.exists
  625. $self->{NOECHO}\$(NOOP)
  626. ];
  627. push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
  628. }
  629. if (%{$self->{MAN3PODS}}) {
  630. push @m, qq[
  631. config :: \$(INST_MAN3DIR)\\.exists
  632. $self->{NOECHO}\$(NOOP)
  633. ];
  634. push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
  635. }
  636. push @m, '
  637. $(O_FILES): $(H_FILES)
  638. ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
  639. push @m, q{
  640. help:
  641. perldoc ExtUtils::MakeMaker
  642. };
  643. push @m, q{
  644. Version_check:
  645. }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
  646. -MExtUtils::MakeMaker=Version_check \
  647. -e "Version_check('$(MM_VERSION)')"
  648. };
  649. join('',@m);
  650. }
  651. =item htmlifypods (o)
  652. Defines targets and routines to translate the pods into HTML manpages
  653. and put them into the INST_HTMLLIBDIR and INST_HTMLSCRIPTDIR
  654. directories.
  655. Same as MM_Unix version (changes command-line quoting).
  656. =cut
  657. sub htmlifypods {
  658. my($self, %attribs) = @_;
  659. return "\nhtmlifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
  660. %{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}};
  661. my($dist);
  662. my($pod2html_exe);
  663. if (defined $self->{PERL_SRC}) {
  664. $pod2html_exe = $self->catfile($self->{PERL_SRC},'pod','pod2html');
  665. } else {
  666. $pod2html_exe = $self->catfile($Config{scriptdirexp},'pod2html');
  667. }
  668. unless ($pod2html_exe = $self->perl_script($pod2html_exe)) {
  669. # No pod2html but some HTMLxxxPODS to be installed
  670. print <<END;
  671. Warning: I could not locate your pod2html program. Please make sure,
  672. your pod2html program is in your PATH before you execute 'make'
  673. END
  674. $pod2html_exe = "-S pod2html";
  675. }
  676. my(@m);
  677. push @m,
  678. qq[POD2HTML_EXE = $pod2html_exe\n],
  679. qq[POD2HTML = \$(PERL) -we "use File::Basename; use File::Path qw(mkpath); %m=\@ARGV;for (keys %m){" \\\n],
  680. q[-e "next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M '],
  681. $self->{MAKEFILE}, q[';" \\
  682. -e "print qq(Htmlifying $$m{$$_}\n);" \\
  683. -e "$$dir = dirname($$m{$$_}); mkpath($$dir) unless -d $$dir;" \\
  684. -e "system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2HTML_EXE) ].qq[$$_>$$m{$$_}])==0 or warn qq(Couldn\\047t install $$m{$$_}\n);" \\
  685. -e "chmod(oct($(PERM_RW))), $$m{$$_} or warn qq(chmod $(PERM_RW) $$m{$$_}: $$!\n);}"
  686. ];
  687. push @m, "\nhtmlifypods : pure_all ";
  688. push @m, join " \\\n\t", keys %{$self->{HTMLLIBPODS}}, keys %{$self->{HTMLSCRIPTPODS}};
  689. push(@m,"\n");
  690. if (%{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}}) {
  691. push @m, "\t$self->{NOECHO}\$(POD2HTML) \\\n\t";
  692. push @m, join " \\\n\t", %{$self->{HTMLLIBPODS}}, %{$self->{HTMLSCRIPTPODS}};
  693. }
  694. join('', @m);
  695. }
  696. =item manifypods (o)
  697. We don't want manpage process.
  698. =cut
  699. sub manifypods {
  700. my($self) = shift;
  701. return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n";
  702. }
  703. =item dist_ci (o)
  704. Same as MM_Unix version (changes command-line quoting).
  705. =cut
  706. sub dist_ci {
  707. my($self) = shift;
  708. my @m;
  709. push @m, q{
  710. ci :
  711. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
  712. -e "@all = keys %{ maniread() };" \\
  713. -e "print(\"Executing $(CI) @all\n\"); system(\"$(CI) @all\");" \\
  714. -e "print(\"Executing $(RCS_LABEL) ...\n\"); system(\"$(RCS_LABEL) @all\");"
  715. };
  716. join "", @m;
  717. }
  718. =item dist_core (o)
  719. Same as MM_Unix version (changes command-line quoting).
  720. =cut
  721. sub dist_core {
  722. my($self) = shift;
  723. my @m;
  724. push @m, q{
  725. dist : $(DIST_DEFAULT)
  726. }.$self->{NOECHO}.q{$(PERL) -le "print \"Warning: Makefile possibly out of date with $$vf\" if " \
  727. -e "-e ($$vf=\"$(VERSION_FROM)\") and -M $$vf < -M \"}.$self->{MAKEFILE}.q{\";"
  728. tardist : $(DISTVNAME).tar$(SUFFIX)
  729. zipdist : $(DISTVNAME).zip
  730. $(DISTVNAME).tar$(SUFFIX) : distdir
  731. $(PREOP)
  732. $(TO_UNIX)
  733. $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
  734. $(RM_RF) $(DISTVNAME)
  735. $(COMPRESS) $(DISTVNAME).tar
  736. $(POSTOP)
  737. $(DISTVNAME).zip : distdir
  738. $(PREOP)
  739. $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
  740. $(RM_RF) $(DISTVNAME)
  741. $(POSTOP)
  742. uutardist : $(DISTVNAME).tar$(SUFFIX)
  743. uuencode $(DISTVNAME).tar$(SUFFIX) \\
  744. $(DISTVNAME).tar$(SUFFIX) > \\
  745. $(DISTVNAME).tar$(SUFFIX)_uu
  746. shdist : distdir
  747. $(PREOP)
  748. $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
  749. $(RM_RF) $(DISTVNAME)
  750. $(POSTOP)
  751. };
  752. join "", @m;
  753. }
  754. =item pasthru (o)
  755. Defines the string that is passed to recursive make calls in
  756. subdirectories.
  757. =cut
  758. sub pasthru {
  759. my($self) = shift;
  760. return "PASTHRU = " . ($NMAKE ? "-nologo" : "");
  761. }
  762. 1;
  763. __END__
  764. =back
  765. =cut