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.

3856 lines
111 KiB

  1. package ExtUtils::MM_Unix;
  2. use Exporter ();
  3. use Config;
  4. use File::Basename qw(basename dirname fileparse);
  5. use DirHandle;
  6. use strict;
  7. use vars qw($VERSION $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Is_PERL_OBJECT
  8. $Verbose %pm %static $Xsubpp_Version);
  9. $VERSION = substr q$Revision: 1.12603 $, 10;
  10. # $Id: MM_Unix.pm,v 1.126 1998/06/28 21:32:49 k Exp k $
  11. Exporter::import('ExtUtils::MakeMaker', qw($Verbose &neatvalue));
  12. $Is_OS2 = $^O eq 'os2';
  13. $Is_Mac = $^O eq 'MacOS';
  14. $Is_Win32 = $^O eq 'MSWin32';
  15. $Is_Dos = $^O eq 'dos';
  16. $Is_PERL_OBJECT = $Config{'ccflags'} =~ /-DPERL_OBJECT/;
  17. if ($Is_VMS = $^O eq 'VMS') {
  18. require VMS::Filespec;
  19. import VMS::Filespec qw( &vmsify );
  20. }
  21. =head1 NAME
  22. ExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker
  23. =head1 SYNOPSIS
  24. C<require ExtUtils::MM_Unix;>
  25. =head1 DESCRIPTION
  26. The methods provided by this package are designed to be used in
  27. conjunction with ExtUtils::MakeMaker. When MakeMaker writes a
  28. Makefile, it creates one or more objects that inherit their methods
  29. from a package C<MM>. MM itself doesn't provide any methods, but it
  30. ISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operating
  31. specific packages take the responsibility for all the methods provided
  32. by MM_Unix. We are trying to reduce the number of the necessary
  33. overrides by defining rather primitive operations within
  34. ExtUtils::MM_Unix.
  35. If you are going to write a platform specific MM package, please try
  36. to limit the necessary overrides to primitive methods, and if it is not
  37. possible to do so, let's work out how to achieve that gain.
  38. If you are overriding any of these methods in your Makefile.PL (in the
  39. MY class), please report that to the makemaker mailing list. We are
  40. trying to minimize the necessary method overrides and switch to data
  41. driven Makefile.PLs wherever possible. In the long run less methods
  42. will be overridable via the MY class.
  43. =head1 METHODS
  44. The following description of methods is still under
  45. development. Please refer to the code for not suitably documented
  46. sections and complain loudly to the makemaker mailing list.
  47. Not all of the methods below are overridable in a
  48. Makefile.PL. Overridable methods are marked as (o). All methods are
  49. overridable by a platform specific MM_*.pm file (See
  50. L<ExtUtils::MM_VMS>) and L<ExtUtils::MM_OS2>).
  51. =head2 Preloaded methods
  52. =over 2
  53. =item canonpath
  54. No physical check on the filesystem, but a logical cleanup of a
  55. path. On UNIX eliminated successive slashes and successive "/.".
  56. =cut
  57. sub canonpath {
  58. my($self,$path) = @_;
  59. my $node = '';
  60. if ( $^O eq 'qnx' && $path =~ s|^(//\d+)/|/|s ) {
  61. $node = $1;
  62. }
  63. $path =~ s|(?<=[^/])/+|/|g ; # xx////xx -> xx/xx
  64. $path =~ s|(/\.)+/|/|g ; # xx/././xx -> xx/xx
  65. $path =~ s|^(\./)+||s unless $path eq "./"; # ./xx -> xx
  66. $path =~ s|(?<=[^/])/\z|| ; # xx/ -> xx
  67. "$node$path";
  68. }
  69. =item catdir
  70. Concatenate two or more directory names to form a complete path ending
  71. with a directory. But remove the trailing slash from the resulting
  72. string, because it doesn't look good, isn't necessary and confuses
  73. OS2. Of course, if this is the root directory, don't cut off the
  74. trailing slash :-)
  75. =cut
  76. # ';
  77. sub catdir {
  78. my $self = shift @_;
  79. my @args = @_;
  80. for (@args) {
  81. # append a slash to each argument unless it has one there
  82. $_ .= "/" if $_ eq '' or substr($_,-1) ne "/";
  83. }
  84. $self->canonpath(join('', @args));
  85. }
  86. =item catfile
  87. Concatenate one or more directory names and a filename to form a
  88. complete path ending with a filename
  89. =cut
  90. sub catfile {
  91. my $self = shift @_;
  92. my $file = pop @_;
  93. return $self->canonpath($file) unless @_;
  94. my $dir = $self->catdir(@_);
  95. for ($dir) {
  96. $_ .= "/" unless substr($_,length($_)-1,1) eq "/";
  97. }
  98. return $self->canonpath($dir.$file);
  99. }
  100. =item curdir
  101. Returns a string representing of the current directory. "." on UNIX.
  102. =cut
  103. sub curdir {
  104. return "." ;
  105. }
  106. =item rootdir
  107. Returns a string representing of the root directory. "/" on UNIX.
  108. =cut
  109. sub rootdir {
  110. return "/";
  111. }
  112. =item updir
  113. Returns a string representing of the parent directory. ".." on UNIX.
  114. =cut
  115. sub updir {
  116. return "..";
  117. }
  118. sub ExtUtils::MM_Unix::c_o ;
  119. sub ExtUtils::MM_Unix::clean ;
  120. sub ExtUtils::MM_Unix::const_cccmd ;
  121. sub ExtUtils::MM_Unix::const_config ;
  122. sub ExtUtils::MM_Unix::const_loadlibs ;
  123. sub ExtUtils::MM_Unix::constants ;
  124. sub ExtUtils::MM_Unix::depend ;
  125. sub ExtUtils::MM_Unix::dir_target ;
  126. sub ExtUtils::MM_Unix::dist ;
  127. sub ExtUtils::MM_Unix::dist_basics ;
  128. sub ExtUtils::MM_Unix::dist_ci ;
  129. sub ExtUtils::MM_Unix::dist_core ;
  130. sub ExtUtils::MM_Unix::dist_dir ;
  131. sub ExtUtils::MM_Unix::dist_test ;
  132. sub ExtUtils::MM_Unix::dlsyms ;
  133. sub ExtUtils::MM_Unix::dynamic ;
  134. sub ExtUtils::MM_Unix::dynamic_bs ;
  135. sub ExtUtils::MM_Unix::dynamic_lib ;
  136. sub ExtUtils::MM_Unix::exescan ;
  137. sub ExtUtils::MM_Unix::export_list ;
  138. sub ExtUtils::MM_Unix::extliblist ;
  139. sub ExtUtils::MM_Unix::file_name_is_absolute ;
  140. sub ExtUtils::MM_Unix::find_perl ;
  141. sub ExtUtils::MM_Unix::fixin ;
  142. sub ExtUtils::MM_Unix::force ;
  143. sub ExtUtils::MM_Unix::guess_name ;
  144. sub ExtUtils::MM_Unix::has_link_code ;
  145. sub ExtUtils::MM_Unix::htmlifypods ;
  146. sub ExtUtils::MM_Unix::init_dirscan ;
  147. sub ExtUtils::MM_Unix::init_main ;
  148. sub ExtUtils::MM_Unix::init_others ;
  149. sub ExtUtils::MM_Unix::install ;
  150. sub ExtUtils::MM_Unix::installbin ;
  151. sub ExtUtils::MM_Unix::libscan ;
  152. sub ExtUtils::MM_Unix::linkext ;
  153. sub ExtUtils::MM_Unix::lsdir ;
  154. sub ExtUtils::MM_Unix::macro ;
  155. sub ExtUtils::MM_Unix::makeaperl ;
  156. sub ExtUtils::MM_Unix::makefile ;
  157. sub ExtUtils::MM_Unix::manifypods ;
  158. sub ExtUtils::MM_Unix::maybe_command ;
  159. sub ExtUtils::MM_Unix::maybe_command_in_dirs ;
  160. sub ExtUtils::MM_Unix::needs_linking ;
  161. sub ExtUtils::MM_Unix::nicetext ;
  162. sub ExtUtils::MM_Unix::parse_version ;
  163. sub ExtUtils::MM_Unix::pasthru ;
  164. sub ExtUtils::MM_Unix::path ;
  165. sub ExtUtils::MM_Unix::perl_archive;
  166. sub ExtUtils::MM_Unix::perl_archive_after;
  167. sub ExtUtils::MM_Unix::perl_script ;
  168. sub ExtUtils::MM_Unix::perldepend ;
  169. sub ExtUtils::MM_Unix::pm_to_blib ;
  170. sub ExtUtils::MM_Unix::post_constants ;
  171. sub ExtUtils::MM_Unix::post_initialize ;
  172. sub ExtUtils::MM_Unix::postamble ;
  173. sub ExtUtils::MM_Unix::ppd ;
  174. sub ExtUtils::MM_Unix::prefixify ;
  175. sub ExtUtils::MM_Unix::processPL ;
  176. sub ExtUtils::MM_Unix::realclean ;
  177. sub ExtUtils::MM_Unix::replace_manpage_separator ;
  178. sub ExtUtils::MM_Unix::static ;
  179. sub ExtUtils::MM_Unix::static_lib ;
  180. sub ExtUtils::MM_Unix::staticmake ;
  181. sub ExtUtils::MM_Unix::subdir_x ;
  182. sub ExtUtils::MM_Unix::subdirs ;
  183. sub ExtUtils::MM_Unix::test ;
  184. sub ExtUtils::MM_Unix::test_via_harness ;
  185. sub ExtUtils::MM_Unix::test_via_script ;
  186. sub ExtUtils::MM_Unix::tool_autosplit ;
  187. sub ExtUtils::MM_Unix::tool_xsubpp ;
  188. sub ExtUtils::MM_Unix::tools_other ;
  189. sub ExtUtils::MM_Unix::top_targets ;
  190. sub ExtUtils::MM_Unix::writedoc ;
  191. sub ExtUtils::MM_Unix::xs_c ;
  192. sub ExtUtils::MM_Unix::xs_cpp ;
  193. sub ExtUtils::MM_Unix::xs_o ;
  194. sub ExtUtils::MM_Unix::xsubpp_version ;
  195. package ExtUtils::MM_Unix;
  196. use SelfLoader;
  197. 1;
  198. __DATA__
  199. =back
  200. =head2 SelfLoaded methods
  201. =over 2
  202. =item c_o (o)
  203. Defines the suffix rules to compile different flavors of C files to
  204. object files.
  205. =cut
  206. sub c_o {
  207. # --- Translation Sections ---
  208. my($self) = shift;
  209. return '' unless $self->needs_linking();
  210. my(@m);
  211. push @m, '
  212. .c$(OBJ_EXT):
  213. $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
  214. ';
  215. push @m, '
  216. .C$(OBJ_EXT):
  217. $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C
  218. ' if $^O ne 'os2' and $^O ne 'MSWin32' and $^O ne 'dos'; #Case-specific
  219. push @m, '
  220. .cpp$(OBJ_EXT):
  221. $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cpp
  222. .cxx$(OBJ_EXT):
  223. $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cxx
  224. .cc$(OBJ_EXT):
  225. $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cc
  226. ';
  227. join "", @m;
  228. }
  229. =item cflags (o)
  230. Does very much the same as the cflags script in the perl
  231. distribution. It doesn't return the whole compiler command line, but
  232. initializes all of its parts. The const_cccmd method then actually
  233. returns the definition of the CCCMD macro which uses these parts.
  234. =cut
  235. #'
  236. sub cflags {
  237. my($self,$libperl)=@_;
  238. return $self->{CFLAGS} if $self->{CFLAGS};
  239. return '' unless $self->needs_linking();
  240. my($prog, $uc, $perltype, %cflags);
  241. $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ;
  242. $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/;
  243. @cflags{qw(cc ccflags optimize shellflags)}
  244. = @Config{qw(cc ccflags optimize shellflags)};
  245. my($optdebug) = "";
  246. $cflags{shellflags} ||= '';
  247. my(%map) = (
  248. D => '-DDEBUGGING',
  249. E => '-DEMBED',
  250. DE => '-DDEBUGGING -DEMBED',
  251. M => '-DEMBED -DMULTIPLICITY',
  252. DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY',
  253. );
  254. if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){
  255. $uc = uc($1);
  256. } else {
  257. $uc = ""; # avoid warning
  258. }
  259. $perltype = $map{$uc} ? $map{$uc} : "";
  260. if ($uc =~ /^D/) {
  261. $optdebug = "-g";
  262. }
  263. my($name);
  264. ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ;
  265. if ($prog = $Config::Config{$name}) {
  266. # Expand hints for this extension via the shell
  267. print STDOUT "Processing $name hint:\n" if $Verbose;
  268. my(@o)=`cc=\"$cflags{cc}\"
  269. ccflags=\"$cflags{ccflags}\"
  270. optimize=\"$cflags{optimize}\"
  271. perltype=\"$cflags{perltype}\"
  272. optdebug=\"$cflags{optdebug}\"
  273. eval '$prog'
  274. echo cc=\$cc
  275. echo ccflags=\$ccflags
  276. echo optimize=\$optimize
  277. echo perltype=\$perltype
  278. echo optdebug=\$optdebug
  279. `;
  280. my($line);
  281. foreach $line (@o){
  282. chomp $line;
  283. if ($line =~ /(.*?)=\s*(.*)\s*$/){
  284. $cflags{$1} = $2;
  285. print STDOUT " $1 = $2\n" if $Verbose;
  286. } else {
  287. print STDOUT "Unrecognised result from hint: '$line'\n";
  288. }
  289. }
  290. }
  291. if ($optdebug) {
  292. $cflags{optimize} = $optdebug;
  293. }
  294. for (qw(ccflags optimize perltype)) {
  295. $cflags{$_} =~ s/^\s+//;
  296. $cflags{$_} =~ s/\s+/ /g;
  297. $cflags{$_} =~ s/\s+$//;
  298. $self->{uc $_} ||= $cflags{$_}
  299. }
  300. if ($Is_PERL_OBJECT) {
  301. $self->{CCFLAGS} =~ s/-DPERL_OBJECT(\b|$)/-DPERL_CAPI/g;
  302. if ($Is_Win32) {
  303. if ($Config{'cc'} =~ /^cl/i) {
  304. # Turn off C++ mode of the MSC compiler
  305. $self->{CCFLAGS} =~ s/-TP(\s|$)//g;
  306. $self->{OPTIMIZE} =~ s/-TP(\s|$)//g;
  307. }
  308. elsif ($Config{'cc'} =~ /^bcc32/i) {
  309. # Turn off C++ mode of the Borland compiler
  310. $self->{CCFLAGS} =~ s/-P(\s|$)//g;
  311. $self->{OPTIMIZE} =~ s/-P(\s|$)//g;
  312. }
  313. elsif ($Config{'cc'} =~ /^gcc/i) {
  314. # Turn off C++ mode of the GCC compiler
  315. $self->{CCFLAGS} =~ s/-xc\+\+(\s|$)//g;
  316. $self->{OPTIMIZE} =~ s/-xc\+\+(\s|$)//g;
  317. }
  318. }
  319. }
  320. if ($self->{POLLUTE}) {
  321. $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
  322. }
  323. my $pollute = '';
  324. if ($Config{usemymalloc} and not $Config{bincompat5005}
  325. and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
  326. and $self->{PERL_MALLOC_OK}) {
  327. $pollute = '$(PERL_MALLOC_DEF)';
  328. }
  329. return $self->{CFLAGS} = qq{
  330. CCFLAGS = $self->{CCFLAGS}
  331. OPTIMIZE = $self->{OPTIMIZE}
  332. PERLTYPE = $self->{PERLTYPE}
  333. MPOLLUTE = $pollute
  334. };
  335. }
  336. =item clean (o)
  337. Defines the clean target.
  338. =cut
  339. sub clean {
  340. # --- Cleanup and Distribution Sections ---
  341. my($self, %attribs) = @_;
  342. my(@m,$dir);
  343. push(@m, '
  344. # Delete temporary files but do not touch installed files. We don\'t delete
  345. # the Makefile here so a later make realclean still has a makefile to use.
  346. clean ::
  347. ');
  348. # clean subdirectories first
  349. for $dir (@{$self->{DIR}}) {
  350. if ($Is_Win32 && Win32::IsWin95()) {
  351. push @m, <<EOT;
  352. cd $dir
  353. \$(TEST_F) $self->{MAKEFILE}
  354. \$(MAKE) clean
  355. cd ..
  356. EOT
  357. }
  358. else {
  359. push @m, <<EOT;
  360. -cd $dir && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) clean
  361. EOT
  362. }
  363. }
  364. my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
  365. push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
  366. push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) $(INST_ARCHAUTODIR)/extralibs.all
  367. perlmain.c mon.out core core.*perl.*.?
  368. *perl.core so_locations pm_to_blib
  369. *$(OBJ_EXT) *$(LIB_EXT) perl.exe
  370. $(BOOTSTRAP) $(BASEEXT).bso $(BASEEXT).def
  371. $(BASEEXT).exp
  372. ]);
  373. push @m, "\t-$self->{RM_RF} @otherfiles\n";
  374. # See realclean and ext/utils/make_ext for usage of Makefile.old
  375. push(@m,
  376. "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old \$(DEV_NULL)\n");
  377. push(@m,
  378. "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
  379. join("", @m);
  380. }
  381. =item const_cccmd (o)
  382. Returns the full compiler call for C programs and stores the
  383. definition in CONST_CCCMD.
  384. =cut
  385. sub const_cccmd {
  386. my($self,$libperl)=@_;
  387. return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
  388. return '' unless $self->needs_linking();
  389. return $self->{CONST_CCCMD} =
  390. q{CCCMD = $(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) \\
  391. $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
  392. $(XS_DEFINE_VERSION)};
  393. }
  394. =item const_config (o)
  395. Defines a couple of constants in the Makefile that are imported from
  396. %Config.
  397. =cut
  398. sub const_config {
  399. # --- Constants Sections ---
  400. my($self) = shift;
  401. my(@m,$m);
  402. push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n");
  403. push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n");
  404. my(%once_only);
  405. foreach $m (@{$self->{CONFIG}}){
  406. # SITE*EXP macros are defined in &constants; avoid duplicates here
  407. next if $once_only{$m} or $m eq 'sitelibexp' or $m eq 'sitearchexp';
  408. push @m, "\U$m\E = ".$self->{uc $m}."\n";
  409. $once_only{$m} = 1;
  410. }
  411. join('', @m);
  412. }
  413. =item const_loadlibs (o)
  414. Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. See
  415. L<ExtUtils::Liblist> for details.
  416. =cut
  417. sub const_loadlibs {
  418. my($self) = shift;
  419. return "" unless $self->needs_linking;
  420. my @m;
  421. push @m, qq{
  422. # $self->{NAME} might depend on some other libraries:
  423. # See ExtUtils::Liblist for details
  424. #
  425. };
  426. my($tmp);
  427. for $tmp (qw/
  428. EXTRALIBS LDLOADLIBS BSLOADLIBS LD_RUN_PATH
  429. /) {
  430. next unless defined $self->{$tmp};
  431. push @m, "$tmp = $self->{$tmp}\n";
  432. }
  433. return join "", @m;
  434. }
  435. =item constants (o)
  436. Initializes lots of constants and .SUFFIXES and .PHONY
  437. =cut
  438. sub constants {
  439. my($self) = @_;
  440. my(@m,$tmp);
  441. for $tmp (qw/
  442. AR_STATIC_ARGS NAME DISTNAME NAME_SYM VERSION
  443. VERSION_SYM XS_VERSION INST_BIN INST_EXE INST_LIB
  444. INST_ARCHLIB INST_SCRIPT PREFIX INSTALLDIRS
  445. INSTALLPRIVLIB INSTALLARCHLIB INSTALLSITELIB
  446. INSTALLSITEARCH INSTALLBIN INSTALLSCRIPT PERL_LIB
  447. PERL_ARCHLIB SITELIBEXP SITEARCHEXP LIBPERL_A MYEXTLIB
  448. FIRST_MAKEFILE MAKE_APERL_FILE PERLMAINCC PERL_SRC
  449. PERL_INC PERL FULLPERL FULL_AR
  450. / ) {
  451. next unless defined $self->{$tmp};
  452. push @m, "$tmp = $self->{$tmp}\n";
  453. }
  454. push @m, qq{
  455. VERSION_MACRO = VERSION
  456. DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
  457. XS_VERSION_MACRO = XS_VERSION
  458. XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
  459. PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
  460. };
  461. push @m, qq{
  462. MAKEMAKER = $INC{'ExtUtils/MakeMaker.pm'}
  463. MM_VERSION = $ExtUtils::MakeMaker::VERSION
  464. };
  465. push @m, q{
  466. # FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
  467. # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
  468. # ROOTEXT = Directory part of FULLEXT with leading slash (eg /DBD) !!! Deprecated from MM 5.32 !!!
  469. # PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
  470. # DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
  471. };
  472. for $tmp (qw/
  473. FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
  474. LDFROM LINKTYPE PM_FILTER
  475. / ) {
  476. next unless defined $self->{$tmp};
  477. push @m, "$tmp = $self->{$tmp}\n";
  478. }
  479. push @m, "
  480. # Handy lists of source code files:
  481. XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
  482. C_FILES = ".join(" \\\n\t", @{$self->{C}})."
  483. O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
  484. H_FILES = ".join(" \\\n\t", @{$self->{H}})."
  485. HTMLLIBPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLLIBPODS}})."
  486. HTMLSCRIPTPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLSCRIPTPODS}})."
  487. MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
  488. MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
  489. ";
  490. for $tmp (qw/
  491. INST_HTMLPRIVLIBDIR INSTALLHTMLPRIVLIBDIR
  492. INST_HTMLSITELIBDIR INSTALLHTMLSITELIBDIR
  493. INST_HTMLSCRIPTDIR INSTALLHTMLSCRIPTDIR
  494. INST_HTMLLIBDIR HTMLEXT
  495. INST_MAN1DIR INSTALLMAN1DIR MAN1EXT
  496. INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
  497. /) {
  498. next unless defined $self->{$tmp};
  499. push @m, "$tmp = $self->{$tmp}\n";
  500. }
  501. for $tmp (qw(
  502. PERM_RW PERM_RWX
  503. )
  504. ) {
  505. my $method = lc($tmp);
  506. # warn "self[$self] method[$method]";
  507. push @m, "$tmp = ", $self->$method(), "\n";
  508. }
  509. push @m, q{
  510. .NO_CONFIG_REC: Makefile
  511. } if $ENV{CLEARCASE_ROOT};
  512. # why not q{} ? -- emacs
  513. push @m, qq{
  514. # work around a famous dec-osf make(1) feature(?):
  515. makemakerdflt: all
  516. .SUFFIXES: .xs .c .C .cpp .cxx .cc \$(OBJ_EXT)
  517. # Nick wanted to get rid of .PRECIOUS. I don't remember why. I seem to recall, that
  518. # some make implementations will delete the Makefile when we rebuild it. Because
  519. # we call false(1) when we rebuild it. So make(1) is not completely wrong when it
  520. # does so. Our milage may vary.
  521. # .PRECIOUS: Makefile # seems to be not necessary anymore
  522. .PHONY: all config static dynamic test linkext manifest
  523. # Where is the Config information that we are using/depend on
  524. CONFIGDEP = \$(PERL_ARCHLIB)/Config.pm \$(PERL_INC)/config.h
  525. };
  526. my @parentdir = split(/::/, $self->{PARENT_NAME});
  527. push @m, q{
  528. # Where to put things:
  529. INST_LIBDIR = }. $self->catdir('$(INST_LIB)',@parentdir) .q{
  530. INST_ARCHLIBDIR = }. $self->catdir('$(INST_ARCHLIB)',@parentdir) .q{
  531. INST_AUTODIR = }. $self->catdir('$(INST_LIB)','auto','$(FULLEXT)') .q{
  532. INST_ARCHAUTODIR = }. $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)') .q{
  533. };
  534. if ($self->has_link_code()) {
  535. push @m, '
  536. INST_STATIC = $(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)
  537. INST_DYNAMIC = $(INST_ARCHAUTODIR)/$(DLBASE).$(DLEXT)
  538. INST_BOOT = $(INST_ARCHAUTODIR)/$(BASEEXT).bs
  539. ';
  540. } else {
  541. push @m, '
  542. INST_STATIC =
  543. INST_DYNAMIC =
  544. INST_BOOT =
  545. ';
  546. }
  547. $tmp = $self->export_list;
  548. push @m, "
  549. EXPORT_LIST = $tmp
  550. ";
  551. $tmp = $self->perl_archive;
  552. push @m, "
  553. PERL_ARCHIVE = $tmp
  554. ";
  555. $tmp = $self->perl_archive_after;
  556. push @m, "
  557. PERL_ARCHIVE_AFTER = $tmp
  558. ";
  559. # push @m, q{
  560. #INST_PM = }.join(" \\\n\t", sort values %{$self->{PM}}).q{
  561. #
  562. #PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
  563. #};
  564. push @m, q{
  565. TO_INST_PM = }.join(" \\\n\t", sort keys %{$self->{PM}}).q{
  566. PM_TO_BLIB = }.join(" \\\n\t", %{$self->{PM}}).q{
  567. };
  568. join('',@m);
  569. }
  570. =item depend (o)
  571. Same as macro for the depend attribute.
  572. =cut
  573. sub depend {
  574. my($self,%attribs) = @_;
  575. my(@m,$key,$val);
  576. while (($key,$val) = each %attribs){
  577. last unless defined $key;
  578. push @m, "$key: $val\n";
  579. }
  580. join "", @m;
  581. }
  582. =item dir_target (o)
  583. Takes an array of directories that need to exist and returns a
  584. Makefile entry for a .exists file in these directories. Returns
  585. nothing, if the entry has already been processed. We're helpless
  586. though, if the same directory comes as $(FOO) _and_ as "bar". Both of
  587. them get an entry, that's why we use "::".
  588. =cut
  589. sub dir_target {
  590. # --- Make-Directories section (internal method) ---
  591. # dir_target(@array) returns a Makefile entry for the file .exists in each
  592. # named directory. Returns nothing, if the entry has already been processed.
  593. # We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
  594. # Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
  595. # prerequisite, because there has to be one, something that doesn't change
  596. # too often :)
  597. my($self,@dirs) = @_;
  598. my(@m,$dir,$targdir);
  599. foreach $dir (@dirs) {
  600. my($src) = $self->catfile($self->{PERL_INC},'perl.h');
  601. my($targ) = $self->catfile($dir,'.exists');
  602. # catfile may have adapted syntax of $dir to target OS, so...
  603. if ($Is_VMS) { # Just remove file name; dirspec is often in macro
  604. ($targdir = $targ) =~ s:/?\.exists\z::;
  605. }
  606. else { # while elsewhere we expect to see the dir separator in $targ
  607. $targdir = dirname($targ);
  608. }
  609. next if $self->{DIR_TARGET}{$self}{$targdir}++;
  610. push @m, qq{
  611. $targ :: $src
  612. $self->{NOECHO}\$(MKPATH) $targdir
  613. $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) $src $targ
  614. };
  615. push(@m, qq{
  616. -$self->{NOECHO}\$(CHMOD) \$(PERM_RWX) $targdir
  617. }) unless $Is_VMS;
  618. }
  619. join "", @m;
  620. }
  621. =item dist (o)
  622. Defines a lot of macros for distribution support.
  623. =cut
  624. sub dist {
  625. my($self, %attribs) = @_;
  626. my(@m);
  627. # VERSION should be sanitised before use as a file name
  628. my($version) = $attribs{VERSION} || '$(VERSION)';
  629. my($name) = $attribs{NAME} || '$(DISTNAME)';
  630. my($tar) = $attribs{TAR} || 'tar'; # eg /usr/bin/gnutar
  631. my($tarflags) = $attribs{TARFLAGS} || 'cvf';
  632. my($zip) = $attribs{ZIP} || 'zip'; # eg pkzip Yuck!
  633. my($zipflags) = $attribs{ZIPFLAGS} || '-r';
  634. my($compress) = $attribs{COMPRESS} || 'gzip --best';
  635. my($suffix) = $attribs{SUFFIX} || '.gz'; # eg .gz
  636. my($shar) = $attribs{SHAR} || 'shar'; # eg "shar --gzip"
  637. my($preop) = $attribs{PREOP} || "$self->{NOECHO}\$(NOOP)"; # eg update MANIFEST
  638. my($postop) = $attribs{POSTOP} || "$self->{NOECHO}\$(NOOP)"; # eg remove the distdir
  639. my($to_unix) = $attribs{TO_UNIX} || ($Is_OS2
  640. ? "$self->{NOECHO}"
  641. . '$(TEST_F) tmp.zip && $(RM) tmp.zip;'
  642. . ' $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM) tmp.zip'
  643. : "$self->{NOECHO}\$(NOOP)");
  644. my($ci) = $attribs{CI} || 'ci -u';
  645. my($rcs_label)= $attribs{RCS_LABEL}|| 'rcs -Nv$(VERSION_SYM): -q';
  646. my($dist_cp) = $attribs{DIST_CP} || 'best';
  647. my($dist_default) = $attribs{DIST_DEFAULT} || 'tardist';
  648. push @m, "
  649. DISTVNAME = ${name}-$version
  650. TAR = $tar
  651. TARFLAGS = $tarflags
  652. ZIP = $zip
  653. ZIPFLAGS = $zipflags
  654. COMPRESS = $compress
  655. SUFFIX = $suffix
  656. SHAR = $shar
  657. PREOP = $preop
  658. POSTOP = $postop
  659. TO_UNIX = $to_unix
  660. CI = $ci
  661. RCS_LABEL = $rcs_label
  662. DIST_CP = $dist_cp
  663. DIST_DEFAULT = $dist_default
  664. ";
  665. join "", @m;
  666. }
  667. =item dist_basics (o)
  668. Defines the targets distclean, distcheck, skipcheck, manifest, veryclean.
  669. =cut
  670. sub dist_basics {
  671. my($self) = shift;
  672. my @m;
  673. push @m, q{
  674. distclean :: realclean distcheck
  675. };
  676. push @m, q{
  677. distcheck :
  678. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=fullcheck \\
  679. -e fullcheck
  680. };
  681. push @m, q{
  682. skipcheck :
  683. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=skipcheck \\
  684. -e skipcheck
  685. };
  686. push @m, q{
  687. manifest :
  688. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=mkmanifest \\
  689. -e mkmanifest
  690. };
  691. push @m, q{
  692. veryclean : realclean
  693. $(RM_F) *~ *.orig */*~ */*.orig
  694. };
  695. join "", @m;
  696. }
  697. =item dist_ci (o)
  698. Defines a check in target for RCS.
  699. =cut
  700. sub dist_ci {
  701. my($self) = shift;
  702. my @m;
  703. push @m, q{
  704. ci :
  705. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
  706. -e "@all = keys %{ maniread() };" \\
  707. -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
  708. -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
  709. };
  710. join "", @m;
  711. }
  712. =item dist_core (o)
  713. Defines the targets dist, tardist, zipdist, uutardist, shdist
  714. =cut
  715. sub dist_core {
  716. my($self) = shift;
  717. my @m;
  718. push @m, q{
  719. dist : $(DIST_DEFAULT)
  720. }.$self->{NOECHO}.q{$(PERL) -le 'print "Warning: Makefile possibly out of date with $$vf" if ' \
  721. -e '-e ($$vf="$(VERSION_FROM)") and -M $$vf < -M "}.$self->{MAKEFILE}.q{";'
  722. tardist : $(DISTVNAME).tar$(SUFFIX)
  723. zipdist : $(DISTVNAME).zip
  724. $(DISTVNAME).tar$(SUFFIX) : distdir
  725. $(PREOP)
  726. $(TO_UNIX)
  727. $(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
  728. $(RM_RF) $(DISTVNAME)
  729. $(COMPRESS) $(DISTVNAME).tar
  730. $(POSTOP)
  731. $(DISTVNAME).zip : distdir
  732. $(PREOP)
  733. $(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
  734. $(RM_RF) $(DISTVNAME)
  735. $(POSTOP)
  736. uutardist : $(DISTVNAME).tar$(SUFFIX)
  737. uuencode $(DISTVNAME).tar$(SUFFIX) \\
  738. $(DISTVNAME).tar$(SUFFIX) > \\
  739. $(DISTVNAME).tar$(SUFFIX)_uu
  740. shdist : distdir
  741. $(PREOP)
  742. $(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
  743. $(RM_RF) $(DISTVNAME)
  744. $(POSTOP)
  745. };
  746. join "", @m;
  747. }
  748. =item dist_dir (o)
  749. Defines the scratch directory target that will hold the distribution
  750. before tar-ing (or shar-ing).
  751. =cut
  752. sub dist_dir {
  753. my($self) = shift;
  754. my @m;
  755. push @m, q{
  756. distdir :
  757. $(RM_RF) $(DISTVNAME)
  758. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=manicopy,maniread \\
  759. -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
  760. };
  761. join "", @m;
  762. }
  763. =item dist_test (o)
  764. Defines a target that produces the distribution in the
  765. scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
  766. subdirectory.
  767. =cut
  768. sub dist_test {
  769. my($self) = shift;
  770. my @m;
  771. push @m, q{
  772. disttest : distdir
  773. cd $(DISTVNAME) && $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) Makefile.PL
  774. cd $(DISTVNAME) && $(MAKE)
  775. cd $(DISTVNAME) && $(MAKE) test
  776. };
  777. join "", @m;
  778. }
  779. =item dlsyms (o)
  780. Used by AIX and VMS to define DL_FUNCS and DL_VARS and write the *.exp
  781. files.
  782. =cut
  783. sub dlsyms {
  784. my($self,%attribs) = @_;
  785. return '' unless ($^O eq 'aix' && $self->needs_linking() );
  786. my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
  787. my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
  788. my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
  789. my(@m);
  790. push(@m,"
  791. dynamic :: $self->{BASEEXT}.exp
  792. ") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
  793. push(@m,"
  794. static :: $self->{BASEEXT}.exp
  795. ") unless $self->{SKIPHASH}{'static'}; # we avoid a warning if we tick them
  796. push(@m,"
  797. $self->{BASEEXT}.exp: Makefile.PL
  798. ",' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
  799. Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
  800. neatvalue($funcs), ', "FUNCLIST" => ', neatvalue($funclist),
  801. ', "DL_VARS" => ', neatvalue($vars), ');\'
  802. ');
  803. join('',@m);
  804. }
  805. =item dynamic (o)
  806. Defines the dynamic target.
  807. =cut
  808. sub dynamic {
  809. # --- Dynamic Loading Sections ---
  810. my($self) = shift;
  811. '
  812. ## $(INST_PM) has been moved to the all: target.
  813. ## It remains here for awhile to allow for old usage: "make dynamic"
  814. #dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT) $(INST_PM)
  815. dynamic :: '.$self->{MAKEFILE}.' $(INST_DYNAMIC) $(INST_BOOT)
  816. '.$self->{NOECHO}.'$(NOOP)
  817. ';
  818. }
  819. =item dynamic_bs (o)
  820. Defines targets for bootstrap files.
  821. =cut
  822. sub dynamic_bs {
  823. my($self, %attribs) = @_;
  824. return '
  825. BOOTSTRAP =
  826. ' unless $self->has_link_code();
  827. return '
  828. BOOTSTRAP = '."$self->{BASEEXT}.bs".'
  829. # As Mkbootstrap might not write a file (if none is required)
  830. # we use touch to prevent make continually trying to remake it.
  831. # The DynaLoader only reads a non-empty file.
  832. $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists
  833. '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
  834. '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
  835. -MExtUtils::Mkbootstrap \
  836. -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
  837. '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
  838. $(CHMOD) $(PERM_RW) $@
  839. $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
  840. '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
  841. -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
  842. $(CHMOD) $(PERM_RW) $@
  843. ';
  844. }
  845. =item dynamic_lib (o)
  846. Defines how to produce the *.so (or equivalent) files.
  847. =cut
  848. sub dynamic_lib {
  849. my($self, %attribs) = @_;
  850. return '' unless $self->needs_linking(); #might be because of a subdir
  851. return '' unless $self->has_link_code;
  852. my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
  853. my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
  854. my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
  855. my($ldfrom) = '$(LDFROM)';
  856. $armaybe = 'ar' if ($^O eq 'dec_osf' and $armaybe eq ':');
  857. my(@m);
  858. push(@m,'
  859. # This section creates the dynamically loadable $(INST_DYNAMIC)
  860. # from $(OBJECT) and possibly $(MYEXTLIB).
  861. ARMAYBE = '.$armaybe.'
  862. OTHERLDFLAGS = '.$otherldflags.'
  863. INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
  864. $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
  865. ');
  866. if ($armaybe ne ':'){
  867. $ldfrom = 'tmp$(LIB_EXT)';
  868. push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
  869. push(@m,' $(RANLIB) '."$ldfrom\n");
  870. }
  871. $ldfrom = "-all $ldfrom -none" if ($^O eq 'dec_osf');
  872. # The IRIX linker doesn't use LD_RUN_PATH
  873. my $ldrun = qq{-rpath "$self->{LD_RUN_PATH}"}
  874. if ($^O eq 'irix' && $self->{LD_RUN_PATH});
  875. # For example in AIX the shared objects/libraries from previous builds
  876. # linger quite a while in the shared dynalinker cache even when nobody
  877. # is using them. This is painful if one for instance tries to restart
  878. # a failed build because the link command will fail unnecessarily 'cos
  879. # the shared object/library is 'busy'.
  880. push(@m,' $(RM_F) $@
  881. ');
  882. push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
  883. ' $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST)');
  884. push @m, '
  885. $(CHMOD) $(PERM_RWX) $@
  886. ';
  887. push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  888. join('',@m);
  889. }
  890. =item exescan
  891. Deprecated method. Use libscan instead.
  892. =cut
  893. sub exescan {
  894. my($self,$path) = @_;
  895. $path;
  896. }
  897. =item extliblist
  898. Called by init_others, and calls ext ExtUtils::Liblist. See
  899. L<ExtUtils::Liblist> for details.
  900. =cut
  901. sub extliblist {
  902. my($self,$libs) = @_;
  903. require ExtUtils::Liblist;
  904. $self->ext($libs, $Verbose);
  905. }
  906. =item file_name_is_absolute
  907. Takes as argument a path and returns true, if it is an absolute path.
  908. =cut
  909. sub file_name_is_absolute {
  910. my($self,$file) = @_;
  911. if ($Is_Dos){
  912. $file =~ m{^([a-z]:)?[\\/]}is ;
  913. }
  914. else {
  915. $file =~ m:^/:s ;
  916. }
  917. }
  918. =item find_perl
  919. Finds the executables PERL and FULLPERL
  920. =cut
  921. sub find_perl {
  922. my($self, $ver, $names, $dirs, $trace) = @_;
  923. my($name, $dir);
  924. if ($trace >= 2){
  925. print "Looking for perl $ver by these names:
  926. @$names
  927. in these dirs:
  928. @$dirs
  929. ";
  930. }
  931. foreach $name (@$names){
  932. foreach $dir (@$dirs){
  933. next unless defined $dir; # $self->{PERL_SRC} may be undefined
  934. my ($abs, $val);
  935. if ($self->file_name_is_absolute($name)) { # /foo/bar
  936. $abs = $name;
  937. } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # foo
  938. $abs = $self->catfile($dir, $name);
  939. } else { # foo/bar
  940. $abs = $self->canonpath($self->catfile($self->curdir, $name));
  941. }
  942. print "Checking $abs\n" if ($trace >= 2);
  943. next unless $self->maybe_command($abs);
  944. print "Executing $abs\n" if ($trace >= 2);
  945. $val = `$abs -e 'require $ver; print "VER_OK\n" ' 2>&1`;
  946. if ($val =~ /VER_OK/) {
  947. print "Using PERL=$abs\n" if $trace;
  948. return $abs;
  949. } elsif ($trace >= 2) {
  950. print "Result: `$val'\n";
  951. }
  952. }
  953. }
  954. print STDOUT "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
  955. 0; # false and not empty
  956. }
  957. =back
  958. =head2 Methods to actually produce chunks of text for the Makefile
  959. The methods here are called for each MakeMaker object in the order
  960. specified by @ExtUtils::MakeMaker::MM_Sections.
  961. =over 2
  962. =item fixin
  963. Inserts the sharpbang or equivalent magic number to a script
  964. =cut
  965. sub fixin { # stolen from the pink Camel book, more or less
  966. my($self,@files) = @_;
  967. my($does_shbang) = $Config::Config{'sharpbang'} =~ /^\s*\#\!/;
  968. my($file,$interpreter);
  969. for $file (@files) {
  970. local(*FIXIN);
  971. local(*FIXOUT);
  972. open(FIXIN, $file) or Carp::croak "Can't process '$file': $!";
  973. local $/ = "\n";
  974. chomp(my $line = <FIXIN>);
  975. next unless $line =~ s/^\s*\#!\s*//; # Not a shbang file.
  976. # Now figure out the interpreter name.
  977. my($cmd,$arg) = split ' ', $line, 2;
  978. $cmd =~ s!^.*/!!;
  979. # Now look (in reverse) for interpreter in absolute PATH (unless perl).
  980. if ($cmd eq "perl") {
  981. if ($Config{startperl} =~ m,^\#!.*/perl,) {
  982. $interpreter = $Config{startperl};
  983. $interpreter =~ s,^\#!,,;
  984. } else {
  985. $interpreter = $Config{perlpath};
  986. }
  987. } else {
  988. my(@absdirs) = reverse grep {$self->file_name_is_absolute} $self->path;
  989. $interpreter = '';
  990. my($dir);
  991. foreach $dir (@absdirs) {
  992. if ($self->maybe_command($cmd)) {
  993. warn "Ignoring $interpreter in $file\n" if $Verbose && $interpreter;
  994. $interpreter = $self->catfile($dir,$cmd);
  995. }
  996. }
  997. }
  998. # Figure out how to invoke interpreter on this machine.
  999. my($shb) = "";
  1000. if ($interpreter) {
  1001. print STDOUT "Changing sharpbang in $file to $interpreter" if $Verbose;
  1002. # this is probably value-free on DOSISH platforms
  1003. if ($does_shbang) {
  1004. $shb .= "$Config{'sharpbang'}$interpreter";
  1005. $shb .= ' ' . $arg if defined $arg;
  1006. $shb .= "\n";
  1007. }
  1008. $shb .= qq{
  1009. eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
  1010. if 0; # not running under some shell
  1011. } unless $Is_Win32; # this won't work on win32, so don't
  1012. } else {
  1013. warn "Can't find $cmd in PATH, $file unchanged"
  1014. if $Verbose;
  1015. next;
  1016. }
  1017. unless ( open(FIXOUT,">$file.new") ) {
  1018. warn "Can't create new $file: $!\n";
  1019. next;
  1020. }
  1021. my($dev,$ino,$mode) = stat FIXIN;
  1022. # Print out the new #! line (or equivalent).
  1023. local $\;
  1024. undef $/;
  1025. print FIXOUT $shb, <FIXIN>;
  1026. close FIXIN;
  1027. close FIXOUT;
  1028. # can't rename/chmod open files on some DOSISH platforms
  1029. # If they override perm_rwx, we won't notice it during fixin,
  1030. # because fixin is run through a new instance of MakeMaker.
  1031. # That is why we must run another CHMOD later.
  1032. $mode = oct($self->perm_rwx) unless $dev;
  1033. chmod $mode, $file;
  1034. unless ( rename($file, "$file.bak") ) {
  1035. warn "Can't rename $file to $file.bak: $!";
  1036. next;
  1037. }
  1038. unless ( rename("$file.new", $file) ) {
  1039. warn "Can't rename $file.new to $file: $!";
  1040. unless ( rename("$file.bak", $file) ) {
  1041. warn "Can't rename $file.bak back to $file either: $!";
  1042. warn "Leaving $file renamed as $file.bak\n";
  1043. }
  1044. next;
  1045. }
  1046. unlink "$file.bak";
  1047. } continue {
  1048. close(FIXIN) if fileno(FIXIN);
  1049. chmod oct($self->perm_rwx), $file or
  1050. die "Can't reset permissions for $file: $!\n";
  1051. system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
  1052. }
  1053. }
  1054. =item force (o)
  1055. Just writes FORCE:
  1056. =cut
  1057. sub force {
  1058. my($self) = shift;
  1059. '# Phony target to force checking subdirectories.
  1060. FORCE:
  1061. '.$self->{NOECHO}.'$(NOOP)
  1062. ';
  1063. }
  1064. =item guess_name
  1065. Guess the name of this package by examining the working directory's
  1066. name. MakeMaker calls this only if the developer has not supplied a
  1067. NAME attribute.
  1068. =cut
  1069. # ';
  1070. sub guess_name {
  1071. my($self) = @_;
  1072. use Cwd 'cwd';
  1073. my $name = basename(cwd());
  1074. $name =~ s|[\-_][\d\.\-]+\z||; # this is new with MM 5.00, we
  1075. # strip minus or underline
  1076. # followed by a float or some such
  1077. print "Warning: Guessing NAME [$name] from current directory name.\n";
  1078. $name;
  1079. }
  1080. =item has_link_code
  1081. Returns true if C, XS, MYEXTLIB or similar objects exist within this
  1082. object that need a compiler. Does not descend into subdirectories as
  1083. needs_linking() does.
  1084. =cut
  1085. sub has_link_code {
  1086. my($self) = shift;
  1087. return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};
  1088. if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){
  1089. $self->{HAS_LINK_CODE} = 1;
  1090. return 1;
  1091. }
  1092. return $self->{HAS_LINK_CODE} = 0;
  1093. }
  1094. =item htmlifypods (o)
  1095. Defines targets and routines to translate the pods into HTML manpages
  1096. and put them into the INST_HTMLLIBDIR and INST_HTMLSCRIPTDIR
  1097. directories.
  1098. =cut
  1099. sub htmlifypods {
  1100. my($self, %attribs) = @_;
  1101. return "\nhtmlifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
  1102. %{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}};
  1103. my($dist);
  1104. my($pod2html_exe);
  1105. if (defined $self->{PERL_SRC}) {
  1106. $pod2html_exe = $self->catfile($self->{PERL_SRC},'pod','pod2html');
  1107. } else {
  1108. $pod2html_exe = $self->catfile($Config{scriptdirexp},'pod2html');
  1109. }
  1110. unless ($pod2html_exe = $self->perl_script($pod2html_exe)) {
  1111. # No pod2html but some HTMLxxxPODS to be installed
  1112. print <<END;
  1113. Warning: I could not locate your pod2html program. Please make sure,
  1114. your pod2html program is in your PATH before you execute 'make'
  1115. END
  1116. $pod2html_exe = "-S pod2html";
  1117. }
  1118. my(@m);
  1119. push @m,
  1120. qq[POD2HTML_EXE = $pod2html_exe\n],
  1121. qq[POD2HTML = \$(PERL) -we 'use File::Basename; use File::Path qw(mkpath); %m=\@ARGV;for (keys %m){' \\\n],
  1122. q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "],
  1123. $self->{MAKEFILE}, q[";' \\
  1124. -e 'print "Htmlifying $$m{$$_}\n";' \\
  1125. -e '$$dir = dirname($$m{$$_}); mkpath($$dir) unless -d $$dir;' \\
  1126. -e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2HTML_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
  1127. -e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}'
  1128. ];
  1129. push @m, "\nhtmlifypods : pure_all ";
  1130. push @m, join " \\\n\t", keys %{$self->{HTMLLIBPODS}}, keys %{$self->{HTMLSCRIPTPODS}};
  1131. push(@m,"\n");
  1132. if (%{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}}) {
  1133. push @m, "\t$self->{NOECHO}\$(POD2HTML) \\\n\t";
  1134. push @m, join " \\\n\t", %{$self->{HTMLLIBPODS}}, %{$self->{HTMLSCRIPTPODS}};
  1135. }
  1136. join('', @m);
  1137. }
  1138. =item init_dirscan
  1139. Initializes DIR, XS, PM, C, O_FILES, H, PL_FILES, HTML*PODS, MAN*PODS, EXE_FILES.
  1140. =cut
  1141. sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc)
  1142. my($self) = @_;
  1143. my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
  1144. local(%pm); #the sub in find() has to see this hash
  1145. @ignore{qw(Makefile.PL test.pl)} = (1,1);
  1146. $ignore{'makefile.pl'} = 1 if $Is_VMS;
  1147. foreach $name ($self->lsdir($self->curdir)){
  1148. next if $name =~ /\#/;
  1149. next if $name eq $self->curdir or $name eq $self->updir or $ignore{$name};
  1150. next unless $self->libscan($name);
  1151. if (-d $name){
  1152. next if -l $name; # We do not support symlinks at all
  1153. $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));
  1154. } elsif ($name =~ /\.xs\z/){
  1155. my($c); ($c = $name) =~ s/\.xs\z/.c/;
  1156. $xs{$name} = $c;
  1157. $c{$c} = 1;
  1158. } elsif ($name =~ /\.c(pp|xx|c)?\z/i){ # .c .C .cpp .cxx .cc
  1159. $c{$name} = 1
  1160. unless $name =~ m/perlmain\.c/; # See MAP_TARGET
  1161. } elsif ($name =~ /\.h\z/i){
  1162. $h{$name} = 1;
  1163. } elsif ($name =~ /\.PL\z/) {
  1164. ($pl_files{$name} = $name) =~ s/\.PL\z// ;
  1165. } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
  1166. # case-insensitive filesystem, one dot per name, so foo.h.PL
  1167. # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
  1168. local($/); open(PL,$name); my $txt = <PL>; close PL;
  1169. if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
  1170. ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
  1171. }
  1172. else { $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name); }
  1173. } elsif ($name =~ /\.(p[ml]|pod)\z/){
  1174. $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name);
  1175. }
  1176. }
  1177. # Some larger extensions often wish to install a number of *.pm/pl
  1178. # files into the library in various locations.
  1179. # The attribute PMLIBDIRS holds an array reference which lists
  1180. # subdirectories which we should search for library files to
  1181. # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ]. We
  1182. # recursively search through the named directories (skipping any
  1183. # which don't exist or contain Makefile.PL files).
  1184. # For each *.pm or *.pl file found $self->libscan() is called with
  1185. # the default installation path in $_[1]. The return value of
  1186. # libscan defines the actual installation location. The default
  1187. # libscan function simply returns the path. The file is skipped
  1188. # if libscan returns false.
  1189. # The default installation location passed to libscan in $_[1] is:
  1190. #
  1191. # ./*.pm => $(INST_LIBDIR)/*.pm
  1192. # ./xyz/... => $(INST_LIBDIR)/xyz/...
  1193. # ./lib/... => $(INST_LIB)/...
  1194. #
  1195. # In this way the 'lib' directory is seen as the root of the actual
  1196. # perl library whereas the others are relative to INST_LIBDIR
  1197. # (which includes PARENT_NAME). This is a subtle distinction but one
  1198. # that's important for nested modules.
  1199. $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]
  1200. unless $self->{PMLIBDIRS};
  1201. #only existing directories that aren't in $dir are allowed
  1202. # Avoid $_ wherever possible:
  1203. # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
  1204. my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
  1205. my ($pmlibdir);
  1206. @{$self->{PMLIBDIRS}} = ();
  1207. foreach $pmlibdir (@pmlibdirs) {
  1208. -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
  1209. }
  1210. if (@{$self->{PMLIBDIRS}}){
  1211. print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
  1212. if ($Verbose >= 2);
  1213. require File::Find;
  1214. File::Find::find(sub {
  1215. if (-d $_){
  1216. if ($_ eq "CVS" || $_ eq "RCS"){
  1217. $File::Find::prune = 1;
  1218. }
  1219. return;
  1220. }
  1221. return if /\#/;
  1222. my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
  1223. my($striplibpath,$striplibname);
  1224. $prefix = '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i);
  1225. ($striplibname,$striplibpath) = fileparse($striplibpath);
  1226. my($inst) = $self->catfile($prefix,$striplibpath,$striplibname);
  1227. local($_) = $inst; # for backwards compatibility
  1228. $inst = $self->libscan($inst);
  1229. print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
  1230. return unless $inst;
  1231. $pm{$path} = $inst;
  1232. }, @{$self->{PMLIBDIRS}});
  1233. }
  1234. $self->{DIR} = [sort keys %dir] unless $self->{DIR};
  1235. $self->{XS} = \%xs unless $self->{XS};
  1236. $self->{PM} = \%pm unless $self->{PM};
  1237. $self->{C} = [sort keys %c] unless $self->{C};
  1238. my(@o_files) = @{$self->{C}};
  1239. $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files] ;
  1240. $self->{H} = [sort keys %h] unless $self->{H};
  1241. $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};
  1242. # Set up names of manual pages to generate from pods
  1243. my %pods;
  1244. foreach my $man (qw(MAN1 MAN3 HTMLLIB HTMLSCRIPT)) {
  1245. unless ($self->{"${man}PODS"}) {
  1246. $self->{"${man}PODS"} = {};
  1247. $pods{$man} = 1 unless $self->{"INST_${man}DIR"} =~ /^(none|\s*)$/;
  1248. }
  1249. }
  1250. if ($pods{MAN1} || $pods{HTMLSCRIPT}) {
  1251. if ( exists $self->{EXE_FILES} ) {
  1252. foreach $name (@{$self->{EXE_FILES}}) {
  1253. local *FH;
  1254. my($ispod)=0;
  1255. if (open(FH,"<$name")) {
  1256. while (<FH>) {
  1257. if (/^=head1\s+\w+/) {
  1258. $ispod=1;
  1259. last;
  1260. }
  1261. }
  1262. close FH;
  1263. } else {
  1264. # If it doesn't exist yet, we assume, it has pods in it
  1265. $ispod = 1;
  1266. }
  1267. next unless $ispod;
  1268. if ($pods{HTMLSCRIPT}) {
  1269. $self->{HTMLSCRIPTPODS}->{$name} =
  1270. $self->catfile("\$(INST_HTMLSCRIPTDIR)", basename($name).".\$(HTMLEXT)");
  1271. }
  1272. if ($pods{MAN1}) {
  1273. $self->{MAN1PODS}->{$name} =
  1274. $self->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)");
  1275. }
  1276. }
  1277. }
  1278. }
  1279. if ($pods{MAN3} || $pods{HTMLLIB}) {
  1280. my %manifypods = (); # we collect the keys first, i.e. the files
  1281. # we have to convert to pod
  1282. foreach $name (keys %{$self->{PM}}) {
  1283. if ($name =~ /\.pod\z/ ) {
  1284. $manifypods{$name} = $self->{PM}{$name};
  1285. } elsif ($name =~ /\.p[ml]\z/ ) {
  1286. local *FH;
  1287. my($ispod)=0;
  1288. if (open(FH,"<$name")) {
  1289. while (<FH>) {
  1290. if (/^=head1\s+\w+/) {
  1291. $ispod=1;
  1292. last;
  1293. }
  1294. }
  1295. close FH;
  1296. } else {
  1297. $ispod = 1;
  1298. }
  1299. if( $ispod ) {
  1300. $manifypods{$name} = $self->{PM}{$name};
  1301. }
  1302. }
  1303. }
  1304. # Remove "Configure.pm" and similar, if it's not the only pod listed
  1305. # To force inclusion, just name it "Configure.pod", or override MAN3PODS
  1306. foreach $name (keys %manifypods) {
  1307. if ($name =~ /(config|setup).*\.pm/is) {
  1308. delete $manifypods{$name};
  1309. next;
  1310. }
  1311. my($manpagename) = $name;
  1312. $manpagename =~ s/\.p(od|m|l)\z//;
  1313. if ($pods{HTMLLIB}) {
  1314. $self->{HTMLLIBPODS}->{$name} =
  1315. $self->catfile("\$(INST_HTMLLIBDIR)", "$manpagename.\$(HTMLEXT)");
  1316. }
  1317. unless ($manpagename =~ s!^\W*lib\W+!!s) { # everything below lib is ok
  1318. $manpagename = $self->catfile(split(/::/,$self->{PARENT_NAME}),$manpagename);
  1319. }
  1320. if ($pods{MAN3}) {
  1321. $manpagename = $self->replace_manpage_separator($manpagename);
  1322. $self->{MAN3PODS}->{$name} =
  1323. $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
  1324. }
  1325. }
  1326. }
  1327. }
  1328. =item init_main
  1329. Initializes NAME, FULLEXT, BASEEXT, PARENT_NAME, DLBASE, PERL_SRC,
  1330. PERL_LIB, PERL_ARCHLIB, PERL_INC, INSTALLDIRS, INST_*, INSTALL*,
  1331. PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, EXE_EXT, MAP_TARGET,
  1332. LIBPERL_A, VERSION_FROM, VERSION, DISTNAME, VERSION_SYM.
  1333. =cut
  1334. sub init_main {
  1335. my($self) = @_;
  1336. # --- Initialize Module Name and Paths
  1337. # NAME = Foo::Bar::Oracle
  1338. # FULLEXT = Foo/Bar/Oracle
  1339. # BASEEXT = Oracle
  1340. # ROOTEXT = Directory part of FULLEXT with leading /. !!! Deprecated from MM 5.32 !!!
  1341. # PARENT_NAME = Foo::Bar
  1342. ### Only UNIX:
  1343. ### ($self->{FULLEXT} =
  1344. ### $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket
  1345. $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});
  1346. # Copied from DynaLoader:
  1347. my(@modparts) = split(/::/,$self->{NAME});
  1348. my($modfname) = $modparts[-1];
  1349. # Some systems have restrictions on files names for DLL's etc.
  1350. # mod2fname returns appropriate file base name (typically truncated)
  1351. # It may also edit @modparts if required.
  1352. if (defined &DynaLoader::mod2fname) {
  1353. $modfname = &DynaLoader::mod2fname(\@modparts);
  1354. }
  1355. ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;
  1356. if (defined &DynaLoader::mod2fname) {
  1357. # As of 5.001m, dl_os2 appends '_'
  1358. $self->{DLBASE} = $modfname;
  1359. } else {
  1360. $self->{DLBASE} = '$(BASEEXT)';
  1361. }
  1362. ### ROOTEXT deprecated from MM 5.32
  1363. ### ($self->{ROOTEXT} =
  1364. ### $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ; #eg. /BSD/Foo
  1365. ### $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT};
  1366. # --- Initialize PERL_LIB, INST_LIB, PERL_SRC
  1367. # *Real* information: where did we get these two from? ...
  1368. my $inc_config_dir = dirname($INC{'Config.pm'});
  1369. my $inc_carp_dir = dirname($INC{'Carp.pm'});
  1370. unless ($self->{PERL_SRC}){
  1371. my($dir);
  1372. foreach $dir ($self->updir(),$self->catdir($self->updir(),$self->updir()),$self->catdir($self->updir(),$self->updir(),$self->updir()),$self->catdir($self->updir(),$self->updir(),$self->updir(),$self->updir())){
  1373. if (
  1374. -f $self->catfile($dir,"config.sh")
  1375. &&
  1376. -f $self->catfile($dir,"perl.h")
  1377. &&
  1378. -f $self->catfile($dir,"lib","Exporter.pm")
  1379. ) {
  1380. $self->{PERL_SRC}=$dir ;
  1381. last;
  1382. }
  1383. }
  1384. }
  1385. if ($self->{PERL_SRC}){
  1386. $self->{PERL_LIB} ||= $self->catdir("$self->{PERL_SRC}","lib");
  1387. $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
  1388. $self->{PERL_INC} = ($Is_Win32) ? $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
  1389. # catch a situation that has occurred a few times in the past:
  1390. unless (
  1391. -s $self->catfile($self->{PERL_SRC},'cflags')
  1392. or
  1393. $Is_VMS
  1394. &&
  1395. -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
  1396. or
  1397. $Is_Mac
  1398. or
  1399. $Is_Win32
  1400. ){
  1401. warn qq{
  1402. You cannot build extensions below the perl source tree after executing
  1403. a 'make clean' in the perl source tree.
  1404. To rebuild extensions distributed with the perl source you should
  1405. simply Configure (to include those extensions) and then build perl as
  1406. normal. After installing perl the source tree can be deleted. It is
  1407. not needed for building extensions by running 'perl Makefile.PL'
  1408. usually without extra arguments.
  1409. It is recommended that you unpack and build additional extensions away
  1410. from the perl source tree.
  1411. };
  1412. }
  1413. } else {
  1414. # we should also consider $ENV{PERL5LIB} here
  1415. my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
  1416. $self->{PERL_LIB} ||= $Config::Config{privlibexp};
  1417. $self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp};
  1418. $self->{PERL_INC} = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
  1419. my $perl_h;
  1420. if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
  1421. and not $old){
  1422. # Maybe somebody tries to build an extension with an
  1423. # uninstalled Perl outside of Perl build tree
  1424. my $found;
  1425. for my $dir (@INC) {
  1426. $found = $dir, last if -e $self->catdir($dir, "Config.pm");
  1427. }
  1428. if ($found) {
  1429. my $inc = dirname $found;
  1430. if (-e $self->catdir($inc, "perl.h")) {
  1431. $self->{PERL_LIB} = $found;
  1432. $self->{PERL_ARCHLIB} = $found;
  1433. $self->{PERL_INC} = $inc;
  1434. $self->{UNINSTALLED_PERL} = 1;
  1435. print STDOUT <<EOP;
  1436. ... Detected uninstalled Perl. Trying to continue.
  1437. EOP
  1438. }
  1439. }
  1440. }
  1441. unless (-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))){
  1442. die qq{
  1443. Error: Unable to locate installed Perl libraries or Perl source code.
  1444. It is recommended that you install perl in a standard location before
  1445. building extensions. Some precompiled versions of perl do not contain
  1446. these header files, so you cannot build extensions. In such a case,
  1447. please build and install your perl from a fresh perl distribution. It
  1448. usually solves this kind of problem.
  1449. \(You get this message, because MakeMaker could not find "$perl_h"\)
  1450. };
  1451. }
  1452. # print STDOUT "Using header files found in $self->{PERL_INC}\n"
  1453. # if $Verbose && $self->needs_linking();
  1454. }
  1455. # We get SITELIBEXP and SITEARCHEXP directly via
  1456. # Get_from_Config. When we are running standard modules, these
  1457. # won't matter, we will set INSTALLDIRS to "perl". Otherwise we
  1458. # set it to "site". I prefer that INSTALLDIRS be set from outside
  1459. # MakeMaker.
  1460. $self->{INSTALLDIRS} ||= "site";
  1461. # INST_LIB typically pre-set if building an extension after
  1462. # perl has been built and installed. Setting INST_LIB allows
  1463. # you to build directly into, say $Config::Config{privlibexp}.
  1464. unless ($self->{INST_LIB}){
  1465. ##### XXXXX We have to change this nonsense
  1466. if (defined $self->{PERL_SRC} and $self->{INSTALLDIRS} eq "perl") {
  1467. $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
  1468. } else {
  1469. $self->{INST_LIB} = $self->catdir($self->curdir,"blib","lib");
  1470. }
  1471. }
  1472. $self->{INST_ARCHLIB} ||= $self->catdir($self->curdir,"blib","arch");
  1473. $self->{INST_BIN} ||= $self->catdir($self->curdir,'blib','bin');
  1474. # We need to set up INST_LIBDIR before init_libscan() for VMS
  1475. my @parentdir = split(/::/, $self->{PARENT_NAME});
  1476. $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)',@parentdir);
  1477. $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)',@parentdir);
  1478. $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)','auto','$(FULLEXT)');
  1479. $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)','auto','$(FULLEXT)');
  1480. # INST_EXE is deprecated, should go away March '97
  1481. $self->{INST_EXE} ||= $self->catdir($self->curdir,'blib','script');
  1482. $self->{INST_SCRIPT} ||= $self->catdir($self->curdir,'blib','script');
  1483. # The user who requests an installation directory explicitly
  1484. # should not have to tell us a architecture installation directory
  1485. # as well. We look if a directory exists that is named after the
  1486. # architecture. If not we take it as a sign that it should be the
  1487. # same as the requested installation directory. Otherwise we take
  1488. # the found one.
  1489. # We do the same thing twice: for privlib/archlib and for sitelib/sitearch
  1490. my($libpair);
  1491. for $libpair ({l=>"privlib", a=>"archlib"}, {l=>"sitelib", a=>"sitearch"}) {
  1492. my $lib = "install$libpair->{l}";
  1493. my $Lib = uc $lib;
  1494. my $Arch = uc "install$libpair->{a}";
  1495. if( $self->{$Lib} && ! $self->{$Arch} ){
  1496. my($ilib) = $Config{$lib};
  1497. $ilib = VMS::Filespec::unixify($ilib) if $Is_VMS;
  1498. $self->prefixify($Arch,$ilib,$self->{$Lib});
  1499. unless (-d $self->{$Arch}) {
  1500. print STDOUT "Directory $self->{$Arch} not found, thusly\n" if $Verbose;
  1501. $self->{$Arch} = $self->{$Lib};
  1502. }
  1503. print STDOUT "Defaulting $Arch to $self->{$Arch}\n" if $Verbose;
  1504. }
  1505. }
  1506. # we have to look at the relation between $Config{prefix} and the
  1507. # requested values. We're going to set the $Config{prefix} part of
  1508. # all the installation path variables to literally $(PREFIX), so
  1509. # the user can still say make PREFIX=foo
  1510. my($configure_prefix) = $Config{'prefix'};
  1511. $configure_prefix = VMS::Filespec::unixify($configure_prefix) if $Is_VMS;
  1512. $self->{PREFIX} ||= $configure_prefix;
  1513. my($install_variable,$search_prefix,$replace_prefix);
  1514. # If the prefix contains perl, Configure shapes the tree as follows:
  1515. # perlprefix/lib/ INSTALLPRIVLIB
  1516. # perlprefix/lib/pod/
  1517. # perlprefix/lib/site_perl/ INSTALLSITELIB
  1518. # perlprefix/bin/ INSTALLBIN
  1519. # perlprefix/man/ INSTALLMAN1DIR
  1520. # else
  1521. # prefix/lib/perl5/ INSTALLPRIVLIB
  1522. # prefix/lib/perl5/pod/
  1523. # prefix/lib/perl5/site_perl/ INSTALLSITELIB
  1524. # prefix/bin/ INSTALLBIN
  1525. # prefix/lib/perl5/man/ INSTALLMAN1DIR
  1526. #
  1527. # The above results in various kinds of breakage on various
  1528. # platforms, so we cope with it as follows: if prefix/lib/perl5
  1529. # or prefix/lib/perl5/man exist, we'll replace those instead
  1530. # of /prefix/{lib,man}
  1531. $replace_prefix = qq[\$\(PREFIX\)];
  1532. for $install_variable (qw/
  1533. INSTALLBIN
  1534. INSTALLSCRIPT
  1535. /) {
  1536. $self->prefixify($install_variable,$configure_prefix,$replace_prefix);
  1537. }
  1538. my $funkylibdir = $self->catdir($configure_prefix,"lib","perl5");
  1539. $funkylibdir = '' unless -d $funkylibdir;
  1540. $search_prefix = $funkylibdir || $self->catdir($configure_prefix,"lib");
  1541. if ($self->{LIB}) {
  1542. $self->{INSTALLPRIVLIB} = $self->{INSTALLSITELIB} = $self->{LIB};
  1543. $self->{INSTALLARCHLIB} = $self->{INSTALLSITEARCH} =
  1544. $self->catdir($self->{LIB},$Config{'archname'});
  1545. }
  1546. else {
  1547. if (-d $self->catdir($self->{PREFIX},"lib","perl5")) {
  1548. $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib", "perl5");
  1549. }
  1550. else {
  1551. $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib");
  1552. }
  1553. for $install_variable (qw/
  1554. INSTALLPRIVLIB
  1555. INSTALLARCHLIB
  1556. INSTALLSITELIB
  1557. INSTALLSITEARCH
  1558. /)
  1559. {
  1560. $self->prefixify($install_variable,$search_prefix,$replace_prefix);
  1561. }
  1562. }
  1563. my $funkymandir = $self->catdir($configure_prefix,"lib","perl5","man");
  1564. $funkymandir = '' unless -d $funkymandir;
  1565. $search_prefix = $funkymandir || $self->catdir($configure_prefix,"man");
  1566. if (-d $self->catdir($self->{PREFIX},"lib","perl5", "man")) {
  1567. $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib", "perl5", "man");
  1568. }
  1569. else {
  1570. $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"man");
  1571. }
  1572. for $install_variable (qw/
  1573. INSTALLMAN1DIR
  1574. INSTALLMAN3DIR
  1575. /)
  1576. {
  1577. $self->prefixify($install_variable,$search_prefix,$replace_prefix);
  1578. }
  1579. # Now we head at the manpages. Maybe they DO NOT want manpages
  1580. # installed
  1581. $self->{INSTALLMAN1DIR} = $Config::Config{installman1dir}
  1582. unless defined $self->{INSTALLMAN1DIR};
  1583. unless (defined $self->{INST_MAN1DIR}){
  1584. if ($self->{INSTALLMAN1DIR} =~ /^(none|\s*)$/){
  1585. $self->{INST_MAN1DIR} = $self->{INSTALLMAN1DIR};
  1586. } else {
  1587. $self->{INST_MAN1DIR} = $self->catdir($self->curdir,'blib','man1');
  1588. }
  1589. }
  1590. $self->{MAN1EXT} ||= $Config::Config{man1ext};
  1591. $self->{INSTALLMAN3DIR} = $Config::Config{installman3dir}
  1592. unless defined $self->{INSTALLMAN3DIR};
  1593. unless (defined $self->{INST_MAN3DIR}){
  1594. if ($self->{INSTALLMAN3DIR} =~ /^(none|\s*)$/){
  1595. $self->{INST_MAN3DIR} = $self->{INSTALLMAN3DIR};
  1596. } else {
  1597. $self->{INST_MAN3DIR} = $self->catdir($self->curdir,'blib','man3');
  1598. }
  1599. }
  1600. $self->{MAN3EXT} ||= $Config::Config{man3ext};
  1601. $self->{INSTALLHTMLPRIVLIBDIR} = $Config::Config{installhtmlprivlibdir}
  1602. unless defined $self->{INSTALLHTMLPRIVLIBDIR};
  1603. $self->{INSTALLHTMLSITELIBDIR} = $Config::Config{installhtmlsitelibdir}
  1604. unless defined $self->{INSTALLHTMLSITELIBDIR};
  1605. unless (defined $self->{INST_HTMLLIBDIR}){
  1606. if ($self->{INSTALLHTMLSITELIBDIR} =~ /^(none|\s*)$/){
  1607. $self->{INST_HTMLLIBDIR} = $self->{INSTALLHTMLSITELIBDIR};
  1608. } else {
  1609. $self->{INST_HTMLLIBDIR} = $self->catdir($self->curdir,'blib','html','lib');
  1610. }
  1611. }
  1612. $self->{INSTALLHTMLSCRIPTDIR} = $Config::Config{installhtmlscriptdir}
  1613. unless defined $self->{INSTALLHTMLSCRIPTDIR};
  1614. unless (defined $self->{INST_HTMLSCRIPTDIR}){
  1615. if ($self->{INSTALLHTMLSCRIPTDIR} =~ /^(none|\s*)$/){
  1616. $self->{INST_HTMLSCRIPTDIR} = $self->{INSTALLHTMLSCRIPTDIR};
  1617. } else {
  1618. $self->{INST_HTMLSCRIPTDIR} = $self->catdir($self->curdir,'blib','html','bin');
  1619. }
  1620. }
  1621. $self->{HTMLEXT} ||= $Config::Config{htmlext} || 'html';
  1622. # Get some stuff out of %Config if we haven't yet done so
  1623. print STDOUT "CONFIG must be an array ref\n"
  1624. if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
  1625. $self->{CONFIG} = [] unless (ref $self->{CONFIG});
  1626. push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
  1627. push(@{$self->{CONFIG}}, 'shellflags') if $Config::Config{shellflags};
  1628. my(%once_only,$m);
  1629. foreach $m (@{$self->{CONFIG}}){
  1630. next if $once_only{$m};
  1631. print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
  1632. unless exists $Config::Config{$m};
  1633. $self->{uc $m} ||= $Config::Config{$m};
  1634. $once_only{$m} = 1;
  1635. }
  1636. # This is too dangerous:
  1637. # if ($^O eq "next") {
  1638. # $self->{AR} = "libtool";
  1639. # $self->{AR_STATIC_ARGS} = "-o";
  1640. # }
  1641. # But I leave it as a placeholder
  1642. $self->{AR_STATIC_ARGS} ||= "cr";
  1643. # These should never be needed
  1644. $self->{LD} ||= 'ld';
  1645. $self->{OBJ_EXT} ||= '.o';
  1646. $self->{LIB_EXT} ||= '.a';
  1647. $self->{MAP_TARGET} ||= "perl";
  1648. $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
  1649. # make a simple check if we find Exporter
  1650. warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
  1651. (Exporter.pm not found)"
  1652. unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
  1653. $self->{NAME} eq "ExtUtils::MakeMaker";
  1654. # Determine VERSION and VERSION_FROM
  1655. ($self->{DISTNAME}=$self->{NAME}) =~ s#(::)#-#g unless $self->{DISTNAME};
  1656. if ($self->{VERSION_FROM}){
  1657. $self->{VERSION} = $self->parse_version($self->{VERSION_FROM}) or
  1658. Carp::carp "WARNING: Setting VERSION via file '$self->{VERSION_FROM}' failed\n"
  1659. }
  1660. # strip blanks
  1661. if ($self->{VERSION}) {
  1662. $self->{VERSION} =~ s/^\s+//;
  1663. $self->{VERSION} =~ s/\s+$//;
  1664. }
  1665. $self->{VERSION} ||= "0.10";
  1666. ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
  1667. # Graham Barr and Paul Marquess had some ideas how to ensure
  1668. # version compatibility between the *.pm file and the
  1669. # corresponding *.xs file. The bottomline was, that we need an
  1670. # XS_VERSION macro that defaults to VERSION:
  1671. $self->{XS_VERSION} ||= $self->{VERSION};
  1672. # --- Initialize Perl Binary Locations
  1673. # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL'
  1674. # will be working versions of perl 5. miniperl has priority over perl
  1675. # for PERL to ensure that $(PERL) is usable while building ./ext/*
  1676. my ($component,@defpath);
  1677. foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) {
  1678. push @defpath, $component if defined $component;
  1679. }
  1680. $self->{PERL} ||=
  1681. $self->find_perl(5.0, [ $self->canonpath($^X), 'miniperl',
  1682. 'perl','perl5',"perl$Config{version}" ],
  1683. \@defpath, $Verbose );
  1684. # don't check if perl is executable, maybe they have decided to
  1685. # supply switches with perl
  1686. # Define 'FULLPERL' to be a non-miniperl (used in test: target)
  1687. ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
  1688. unless ($self->{FULLPERL});
  1689. }
  1690. =item init_others
  1691. Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH,
  1692. OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, NOOP, FIRST_MAKEFILE,
  1693. MAKEFILE, NOECHO, RM_F, RM_RF, TEST_F, TOUCH, CP, MV, CHMOD, UMASK_NULL
  1694. =cut
  1695. sub init_others { # --- Initialize Other Attributes
  1696. my($self) = shift;
  1697. # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
  1698. # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
  1699. # undefined. In any case we turn it into an anon array:
  1700. # May check $Config{libs} too, thus not empty.
  1701. $self->{LIBS}=[''] unless $self->{LIBS};
  1702. $self->{LIBS}=[$self->{LIBS}] if ref \$self->{LIBS} eq 'SCALAR';
  1703. $self->{LD_RUN_PATH} = "";
  1704. my($libs);
  1705. foreach $libs ( @{$self->{LIBS}} ){
  1706. $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
  1707. my(@libs) = $self->extliblist($libs);
  1708. if ($libs[0] or $libs[1] or $libs[2]){
  1709. # LD_RUN_PATH now computed by ExtUtils::Liblist
  1710. ($self->{EXTRALIBS}, $self->{BSLOADLIBS}, $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
  1711. last;
  1712. }
  1713. }
  1714. if ( $self->{OBJECT} ) {
  1715. $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
  1716. } else {
  1717. # init_dirscan should have found out, if we have C files
  1718. $self->{OBJECT} = "";
  1719. $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
  1720. }
  1721. $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
  1722. $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
  1723. $self->{PERLMAINCC} ||= '$(CC)';
  1724. $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
  1725. # Sanity check: don't define LINKTYPE = dynamic if we're skipping
  1726. # the 'dynamic' section of MM. We don't have this problem with
  1727. # 'static', since we either must use it (%Config says we can't
  1728. # use dynamic loading) or the caller asked for it explicitly.
  1729. if (!$self->{LINKTYPE}) {
  1730. $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
  1731. ? 'static'
  1732. : ($Config::Config{usedl} ? 'dynamic' : 'static');
  1733. };
  1734. # These get overridden for VMS and maybe some other systems
  1735. $self->{NOOP} ||= '$(SHELL) -c true';
  1736. $self->{FIRST_MAKEFILE} ||= "Makefile";
  1737. $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
  1738. $self->{MAKE_APERL_FILE} ||= "Makefile.aperl";
  1739. $self->{NOECHO} = '@' unless defined $self->{NOECHO};
  1740. $self->{RM_F} ||= "rm -f";
  1741. $self->{RM_RF} ||= "rm -rf";
  1742. $self->{TOUCH} ||= "touch";
  1743. $self->{TEST_F} ||= "test -f";
  1744. $self->{CP} ||= "cp";
  1745. $self->{MV} ||= "mv";
  1746. $self->{CHMOD} ||= "chmod";
  1747. $self->{UMASK_NULL} ||= "umask 0";
  1748. $self->{DEV_NULL} ||= "> /dev/null 2>&1";
  1749. }
  1750. =item install (o)
  1751. Defines the install target.
  1752. =cut
  1753. sub install {
  1754. my($self, %attribs) = @_;
  1755. my(@m);
  1756. push @m, q{
  1757. install :: all pure_install doc_install
  1758. install_perl :: all pure_perl_install doc_perl_install
  1759. install_site :: all pure_site_install doc_site_install
  1760. install_ :: install_site
  1761. @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
  1762. pure_install :: pure_$(INSTALLDIRS)_install
  1763. doc_install :: doc_$(INSTALLDIRS)_install
  1764. }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
  1765. pure__install : pure_site_install
  1766. @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
  1767. doc__install : doc_site_install
  1768. @echo INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
  1769. pure_perl_install ::
  1770. }.$self->{NOECHO}.q{$(MOD_INSTALL) \
  1771. read }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
  1772. write }.$self->catfile('$(INSTALLARCHLIB)','auto','$(FULLEXT)','.packlist').q{ \
  1773. $(INST_LIB) $(INSTALLPRIVLIB) \
  1774. $(INST_ARCHLIB) $(INSTALLARCHLIB) \
  1775. $(INST_BIN) $(INSTALLBIN) \
  1776. $(INST_SCRIPT) $(INSTALLSCRIPT) \
  1777. $(INST_HTMLLIBDIR) $(INSTALLHTMLPRIVLIBDIR) \
  1778. $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \
  1779. $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
  1780. $(INST_MAN3DIR) $(INSTALLMAN3DIR)
  1781. }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
  1782. }.$self->catdir('$(SITEARCHEXP)','auto','$(FULLEXT)').q{
  1783. pure_site_install ::
  1784. }.$self->{NOECHO}.q{$(MOD_INSTALL) \
  1785. read }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{ \
  1786. write }.$self->catfile('$(INSTALLSITEARCH)','auto','$(FULLEXT)','.packlist').q{ \
  1787. $(INST_LIB) $(INSTALLSITELIB) \
  1788. $(INST_ARCHLIB) $(INSTALLSITEARCH) \
  1789. $(INST_BIN) $(INSTALLBIN) \
  1790. $(INST_SCRIPT) $(INSTALLSCRIPT) \
  1791. $(INST_HTMLLIBDIR) $(INSTALLHTMLSITELIBDIR) \
  1792. $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \
  1793. $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
  1794. $(INST_MAN3DIR) $(INSTALLMAN3DIR)
  1795. }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
  1796. }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
  1797. doc_perl_install ::
  1798. -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB)
  1799. -}.$self->{NOECHO}.q{$(DOC_INSTALL) \
  1800. "Module" "$(NAME)" \
  1801. "installed into" "$(INSTALLPRIVLIB)" \
  1802. LINKTYPE "$(LINKTYPE)" \
  1803. VERSION "$(VERSION)" \
  1804. EXE_FILES "$(EXE_FILES)" \
  1805. >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
  1806. doc_site_install ::
  1807. -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB)
  1808. -}.$self->{NOECHO}.q{$(DOC_INSTALL) \
  1809. "Module" "$(NAME)" \
  1810. "installed into" "$(INSTALLSITELIB)" \
  1811. LINKTYPE "$(LINKTYPE)" \
  1812. VERSION "$(VERSION)" \
  1813. EXE_FILES "$(EXE_FILES)" \
  1814. >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
  1815. };
  1816. push @m, q{
  1817. uninstall :: uninstall_from_$(INSTALLDIRS)dirs
  1818. uninstall_from_perldirs ::
  1819. }.$self->{NOECHO}.
  1820. q{$(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
  1821. uninstall_from_sitedirs ::
  1822. }.$self->{NOECHO}.
  1823. q{$(UNINSTALL) }.$self->catfile('$(SITEARCHEXP)','auto','$(FULLEXT)','.packlist').q{
  1824. };
  1825. join("",@m);
  1826. }
  1827. =item installbin (o)
  1828. Defines targets to make and to install EXE_FILES.
  1829. =cut
  1830. sub installbin {
  1831. my($self) = shift;
  1832. return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
  1833. return "" unless @{$self->{EXE_FILES}};
  1834. my(@m, $from, $to, %fromto, @to);
  1835. push @m, $self->dir_target(qw[$(INST_SCRIPT)]);
  1836. for $from (@{$self->{EXE_FILES}}) {
  1837. my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
  1838. local($_) = $path; # for backwards compatibility
  1839. $to = $self->libscan($path);
  1840. print "libscan($from) => '$to'\n" if ($Verbose >=2);
  1841. $fromto{$from}=$to;
  1842. }
  1843. @to = values %fromto;
  1844. push(@m, qq{
  1845. EXE_FILES = @{$self->{EXE_FILES}}
  1846. } . ($Is_Win32
  1847. ? q{FIXIN = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
  1848. -e "system qq[pl2bat.bat ].shift"
  1849. } : q{FIXIN = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::MakeMaker \
  1850. -e "MY->fixin(shift)"
  1851. }).qq{
  1852. pure_all :: @to
  1853. $self->{NOECHO}\$(NOOP)
  1854. realclean ::
  1855. $self->{RM_F} @to
  1856. });
  1857. while (($from,$to) = each %fromto) {
  1858. last unless defined $from;
  1859. my $todir = dirname($to);
  1860. push @m, "
  1861. $to: $from $self->{MAKEFILE} " . $self->catdir($todir,'.exists') . "
  1862. $self->{NOECHO}$self->{RM_F} $to
  1863. $self->{CP} $from $to
  1864. \$(FIXIN) $to
  1865. -$self->{NOECHO}\$(CHMOD) \$(PERM_RWX) $to
  1866. ";
  1867. }
  1868. join "", @m;
  1869. }
  1870. =item libscan (o)
  1871. Takes a path to a file that is found by init_dirscan and returns false
  1872. if we don't want to include this file in the library. Mainly used to
  1873. exclude RCS, CVS, and SCCS directories from installation.
  1874. =cut
  1875. # ';
  1876. sub libscan {
  1877. my($self,$path) = @_;
  1878. return '' if $path =~ m:\b(RCS|CVS|SCCS)\b: ;
  1879. $path;
  1880. }
  1881. =item linkext (o)
  1882. Defines the linkext target which in turn defines the LINKTYPE.
  1883. =cut
  1884. sub linkext {
  1885. my($self, %attribs) = @_;
  1886. # LINKTYPE => static or dynamic or ''
  1887. my($linktype) = defined $attribs{LINKTYPE} ?
  1888. $attribs{LINKTYPE} : '$(LINKTYPE)';
  1889. "
  1890. linkext :: $linktype
  1891. $self->{NOECHO}\$(NOOP)
  1892. ";
  1893. }
  1894. =item lsdir
  1895. Takes as arguments a directory name and a regular expression. Returns
  1896. all entries in the directory that match the regular expression.
  1897. =cut
  1898. sub lsdir {
  1899. my($self) = shift;
  1900. my($dir, $regex) = @_;
  1901. my(@ls);
  1902. my $dh = new DirHandle;
  1903. $dh->open($dir || ".") or return ();
  1904. @ls = $dh->read;
  1905. $dh->close;
  1906. @ls = grep(/$regex/, @ls) if $regex;
  1907. @ls;
  1908. }
  1909. =item macro (o)
  1910. Simple subroutine to insert the macros defined by the macro attribute
  1911. into the Makefile.
  1912. =cut
  1913. sub macro {
  1914. my($self,%attribs) = @_;
  1915. my(@m,$key,$val);
  1916. while (($key,$val) = each %attribs){
  1917. last unless defined $key;
  1918. push @m, "$key = $val\n";
  1919. }
  1920. join "", @m;
  1921. }
  1922. =item makeaperl (o)
  1923. Called by staticmake. Defines how to write the Makefile to produce a
  1924. static new perl.
  1925. By default the Makefile produced includes all the static extensions in
  1926. the perl library. (Purified versions of library files, e.g.,
  1927. DynaLoader_pure_p1_c0_032.a are automatically ignored to avoid link errors.)
  1928. =cut
  1929. sub makeaperl {
  1930. my($self, %attribs) = @_;
  1931. my($makefilename, $searchdirs, $static, $extra, $perlinc, $target, $tmp, $libperl) =
  1932. @attribs{qw(MAKE DIRS STAT EXTRA INCL TARGET TMP LIBPERL)};
  1933. my(@m);
  1934. push @m, "
  1935. # --- MakeMaker makeaperl section ---
  1936. MAP_TARGET = $target
  1937. FULLPERL = $self->{FULLPERL}
  1938. ";
  1939. return join '', @m if $self->{PARENT};
  1940. my($dir) = join ":", @{$self->{DIR}};
  1941. unless ($self->{MAKEAPERL}) {
  1942. push @m, q{
  1943. $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
  1944. $(MAKE) -f $(MAKE_APERL_FILE) $@
  1945. $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
  1946. }.$self->{NOECHO}.q{echo Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
  1947. }.$self->{NOECHO}.q{$(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
  1948. Makefile.PL DIR=}, $dir, q{ \
  1949. MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
  1950. MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=};
  1951. foreach (@ARGV){
  1952. if( /\s/ ){
  1953. s/=(.*)/='$1'/;
  1954. }
  1955. push @m, " \\\n\t\t$_";
  1956. }
  1957. # push @m, map( " \\\n\t\t$_", @ARGV );
  1958. push @m, "\n";
  1959. return join '', @m;
  1960. }
  1961. my($cccmd, $linkcmd, $lperl);
  1962. $cccmd = $self->const_cccmd($libperl);
  1963. $cccmd =~ s/^CCCMD\s*=\s*//;
  1964. $cccmd =~ s/\$\(INC\)/ -I$self->{PERL_INC} /;
  1965. $cccmd .= " $Config::Config{cccdlflags}"
  1966. if ($Config::Config{useshrplib} eq 'true');
  1967. $cccmd =~ s/\(CC\)/\(PERLMAINCC\)/;
  1968. # The front matter of the linkcommand...
  1969. $linkcmd = join ' ', "\$(CC)",
  1970. grep($_, @Config{qw(ldflags ccdlflags)});
  1971. $linkcmd =~ s/\s+/ /g;
  1972. $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
  1973. # Which *.a files could we make use of...
  1974. local(%static);
  1975. require File::Find;
  1976. File::Find::find(sub {
  1977. return unless m/\Q$self->{LIB_EXT}\E$/;
  1978. return if m/^libperl/;
  1979. # Skip purified versions of libraries (e.g., DynaLoader_pure_p1_c0_032.a)
  1980. return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
  1981. if( exists $self->{INCLUDE_EXT} ){
  1982. my $found = 0;
  1983. my $incl;
  1984. my $xx;
  1985. ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
  1986. $xx =~ s,/?$_,,;
  1987. $xx =~ s,/,::,g;
  1988. # Throw away anything not explicitly marked for inclusion.
  1989. # DynaLoader is implied.
  1990. foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
  1991. if( $xx eq $incl ){
  1992. $found++;
  1993. last;
  1994. }
  1995. }
  1996. return unless $found;
  1997. }
  1998. elsif( exists $self->{EXCLUDE_EXT} ){
  1999. my $excl;
  2000. my $xx;
  2001. ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
  2002. $xx =~ s,/?$_,,;
  2003. $xx =~ s,/,::,g;
  2004. # Throw away anything explicitly marked for exclusion
  2005. foreach $excl (@{$self->{EXCLUDE_EXT}}){
  2006. return if( $xx eq $excl );
  2007. }
  2008. }
  2009. # don't include the installed version of this extension. I
  2010. # leave this line here, although it is not necessary anymore:
  2011. # I patched minimod.PL instead, so that Miniperl.pm won't
  2012. # enclude duplicates
  2013. # Once the patch to minimod.PL is in the distribution, I can
  2014. # drop it
  2015. return if $File::Find::name =~ m:auto/$self->{FULLEXT}/$self->{BASEEXT}$self->{LIB_EXT}\z:;
  2016. use Cwd 'cwd';
  2017. $static{cwd() . "/" . $_}++;
  2018. }, grep( -d $_, @{$searchdirs || []}) );
  2019. # We trust that what has been handed in as argument, will be buildable
  2020. $static = [] unless $static;
  2021. @static{@{$static}} = (1) x @{$static};
  2022. $extra = [] unless $extra && ref $extra eq 'ARRAY';
  2023. for (sort keys %static) {
  2024. next unless /\Q$self->{LIB_EXT}\E\z/;
  2025. $_ = dirname($_) . "/extralibs.ld";
  2026. push @$extra, $_;
  2027. }
  2028. grep(s/^/-I/, @{$perlinc || []});
  2029. $target = "perl" unless $target;
  2030. $tmp = "." unless $tmp;
  2031. # MAP_STATIC doesn't look into subdirs yet. Once "all" is made and we
  2032. # regenerate the Makefiles, MAP_STATIC and the dependencies for
  2033. # extralibs.all are computed correctly
  2034. push @m, "
  2035. MAP_LINKCMD = $linkcmd
  2036. MAP_PERLINC = @{$perlinc || []}
  2037. MAP_STATIC = ",
  2038. join(" \\\n\t", reverse sort keys %static), "
  2039. MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
  2040. ";
  2041. if (defined $libperl) {
  2042. ($lperl = $libperl) =~ s/\$\(A\)/$self->{LIB_EXT}/;
  2043. }
  2044. unless ($libperl && -f $lperl) { # Ilya's code...
  2045. my $dir = $self->{PERL_SRC} || "$self->{PERL_ARCHLIB}/CORE";
  2046. $dir = "$self->{PERL_ARCHLIB}/.." if $self->{UNINSTALLED_PERL};
  2047. $libperl ||= "libperl$self->{LIB_EXT}";
  2048. $libperl = "$dir/$libperl";
  2049. $lperl ||= "libperl$self->{LIB_EXT}";
  2050. $lperl = "$dir/$lperl";
  2051. if (! -f $libperl and ! -f $lperl) {
  2052. # We did not find a static libperl. Maybe there is a shared one?
  2053. if ($^O eq 'solaris' or $^O eq 'sunos') {
  2054. $lperl = $libperl = "$dir/$Config::Config{libperl}";
  2055. # SUNOS ld does not take the full path to a shared library
  2056. $libperl = '' if $^O eq 'sunos';
  2057. }
  2058. }
  2059. print STDOUT "Warning: $libperl not found
  2060. If you're going to build a static perl binary, make sure perl is installed
  2061. otherwise ignore this warning\n"
  2062. unless (-f $lperl || defined($self->{PERL_SRC}));
  2063. }
  2064. push @m, "
  2065. MAP_LIBPERL = $libperl
  2066. ";
  2067. push @m, "
  2068. \$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)/.exists ".join(" \\\n\t", @$extra)."
  2069. $self->{NOECHO}$self->{RM_F} \$\@
  2070. $self->{NOECHO}\$(TOUCH) \$\@
  2071. ";
  2072. my $catfile;
  2073. foreach $catfile (@$extra){
  2074. push @m, "\tcat $catfile >> \$\@\n";
  2075. }
  2076. # SUNOS ld does not take the full path to a shared library
  2077. my $llibperl = ($libperl)?'$(MAP_LIBPERL)':'-lperl';
  2078. push @m, "
  2079. \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
  2080. \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) $llibperl `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
  2081. $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
  2082. $self->{NOECHO}echo ' make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
  2083. $self->{NOECHO}echo 'To remove the intermediate files say'
  2084. $self->{NOECHO}echo ' make -f $makefilename map_clean'
  2085. $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
  2086. ";
  2087. push @m, "\tcd $tmp && $cccmd -I\$(PERL_INC) perlmain.c\n";
  2088. push @m, qq{
  2089. $tmp/perlmain.c: $makefilename}, q{
  2090. }.$self->{NOECHO}.q{echo Writing $@
  2091. }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -MExtUtils::Miniperl \\
  2092. -e "writemain(grep s#.*/auto/##s, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
  2093. };
  2094. push @m, "\t",$self->{NOECHO}.q{$(PERL) $(INSTALLSCRIPT)/fixpmain
  2095. } if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
  2096. push @m, q{
  2097. doc_inst_perl:
  2098. }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
  2099. -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB)
  2100. -}.$self->{NOECHO}.q{$(DOC_INSTALL) \
  2101. "Perl binary" "$(MAP_TARGET)" \
  2102. MAP_STATIC "$(MAP_STATIC)" \
  2103. MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
  2104. MAP_LIBPERL "$(MAP_LIBPERL)" \
  2105. >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
  2106. };
  2107. push @m, q{
  2108. inst_perl: pure_inst_perl doc_inst_perl
  2109. pure_inst_perl: $(MAP_TARGET)
  2110. }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(INSTALLBIN)','$(MAP_TARGET)').q{
  2111. clean :: map_clean
  2112. map_clean :
  2113. }.$self->{RM_F}.qq{ $tmp/perlmain\$(OBJ_EXT) $tmp/perlmain.c \$(MAP_TARGET) $makefilename \$(INST_ARCHAUTODIR)/extralibs.all
  2114. };
  2115. join '', @m;
  2116. }
  2117. =item makefile (o)
  2118. Defines how to rewrite the Makefile.
  2119. =cut
  2120. sub makefile {
  2121. my($self) = shift;
  2122. my @m;
  2123. # We do not know what target was originally specified so we
  2124. # must force a manual rerun to be sure. But as it should only
  2125. # happen very rarely it is not a significant problem.
  2126. push @m, '
  2127. $(OBJECT) : $(FIRST_MAKEFILE)
  2128. ' if $self->{OBJECT};
  2129. push @m, q{
  2130. # We take a very conservative approach here, but it\'s worth it.
  2131. # We move Makefile to Makefile.old here to avoid gnu make looping.
  2132. }.$self->{MAKEFILE}.q{ : Makefile.PL $(CONFIGDEP)
  2133. }.$self->{NOECHO}.q{echo "Makefile out-of-date with respect to $?"
  2134. }.$self->{NOECHO}.q{echo "Cleaning current config before rebuilding Makefile..."
  2135. -}.$self->{NOECHO}.q{$(RM_F) }."$self->{MAKEFILE}.old".q{
  2136. -}.$self->{NOECHO}.q{$(MV) }."$self->{MAKEFILE} $self->{MAKEFILE}.old".q{
  2137. -$(MAKE) -f }.$self->{MAKEFILE}.q{.old clean $(DEV_NULL) || $(NOOP)
  2138. $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{
  2139. }.$self->{NOECHO}.q{echo "==> Your Makefile has been rebuilt. <=="
  2140. }.$self->{NOECHO}.q{echo "==> Please rerun the make command. <=="
  2141. false
  2142. # To change behavior to :: would be nice, but would break Tk b9.02
  2143. # so you find such a warning below the dist target.
  2144. #}.$self->{MAKEFILE}.q{ :: $(VERSION_FROM)
  2145. # }.$self->{NOECHO}.q{echo "Warning: Makefile possibly out of date with $(VERSION_FROM)"
  2146. };
  2147. join "", @m;
  2148. }
  2149. =item manifypods (o)
  2150. Defines targets and routines to translate the pods into manpages and
  2151. put them into the INST_* directories.
  2152. =cut
  2153. sub manifypods {
  2154. my($self, %attribs) = @_;
  2155. return "\nmanifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
  2156. %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
  2157. my($dist);
  2158. my($pod2man_exe);
  2159. if (defined $self->{PERL_SRC}) {
  2160. $pod2man_exe = $self->catfile($self->{PERL_SRC},'pod','pod2man');
  2161. } else {
  2162. $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man');
  2163. }
  2164. unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
  2165. # Maybe a build by uninstalled Perl?
  2166. $pod2man_exe = $self->catfile($self->{PERL_INC}, "pod", "pod2man");
  2167. }
  2168. unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
  2169. # No pod2man but some MAN3PODS to be installed
  2170. print <<END;
  2171. Warning: I could not locate your pod2man program. Please make sure,
  2172. your pod2man program is in your PATH before you execute 'make'
  2173. END
  2174. $pod2man_exe = "-S pod2man";
  2175. }
  2176. my(@m);
  2177. push @m,
  2178. qq[POD2MAN_EXE = $pod2man_exe\n],
  2179. qq[POD2MAN = \$(PERL) -we '%m=\@ARGV;for (keys %m){' \\\n],
  2180. q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "],
  2181. $self->{MAKEFILE}, q[";' \\
  2182. -e 'print "Manifying $$m{$$_}\n";' \\
  2183. -e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
  2184. -e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}'
  2185. ];
  2186. push @m, "\nmanifypods : pure_all ";
  2187. push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
  2188. push(@m,"\n");
  2189. if (%{$self->{MAN1PODS}} || %{$self->{MAN3PODS}}) {
  2190. push @m, "\t$self->{NOECHO}\$(POD2MAN) \\\n\t";
  2191. push @m, join " \\\n\t", %{$self->{MAN1PODS}}, %{$self->{MAN3PODS}};
  2192. }
  2193. join('', @m);
  2194. }
  2195. =item maybe_command
  2196. Returns true, if the argument is likely to be a command.
  2197. =cut
  2198. sub maybe_command {
  2199. my($self,$file) = @_;
  2200. return $file if -x $file && ! -d $file;
  2201. return;
  2202. }
  2203. =item maybe_command_in_dirs
  2204. method under development. Not yet used. Ask Ilya :-)
  2205. =cut
  2206. sub maybe_command_in_dirs { # $ver is optional argument if looking for perl
  2207. # Ilya's suggestion. Not yet used, want to understand it first, but at least the code is here
  2208. my($self, $names, $dirs, $trace, $ver) = @_;
  2209. my($name, $dir);
  2210. foreach $dir (@$dirs){
  2211. next unless defined $dir; # $self->{PERL_SRC} may be undefined
  2212. foreach $name (@$names){
  2213. my($abs,$tryabs);
  2214. if ($self->file_name_is_absolute($name)) { # /foo/bar
  2215. $abs = $name;
  2216. } elsif ($self->canonpath($name) eq $self->canonpath(basename($name))) { # bar
  2217. $abs = $self->catfile($dir, $name);
  2218. } else { # foo/bar
  2219. $abs = $self->catfile($self->curdir, $name);
  2220. }
  2221. print "Checking $abs for $name\n" if ($trace >= 2);
  2222. next unless $tryabs = $self->maybe_command($abs);
  2223. print "Substituting $tryabs instead of $abs\n"
  2224. if ($trace >= 2 and $tryabs ne $abs);
  2225. $abs = $tryabs;
  2226. if (defined $ver) {
  2227. print "Executing $abs\n" if ($trace >= 2);
  2228. if (`$abs -e 'require $ver; print "VER_OK\n" ' 2>&1` =~ /VER_OK/) {
  2229. print "Using PERL=$abs\n" if $trace;
  2230. return $abs;
  2231. }
  2232. } else { # Do not look for perl
  2233. return $abs;
  2234. }
  2235. }
  2236. }
  2237. }
  2238. =item needs_linking (o)
  2239. Does this module need linking? Looks into subdirectory objects (see
  2240. also has_link_code())
  2241. =cut
  2242. sub needs_linking {
  2243. my($self) = shift;
  2244. my($child,$caller);
  2245. $caller = (caller(0))[3];
  2246. Carp::confess("Needs_linking called too early") if $caller =~ /^ExtUtils::MakeMaker::/;
  2247. return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
  2248. if ($self->has_link_code or $self->{MAKEAPERL}){
  2249. $self->{NEEDS_LINKING} = 1;
  2250. return 1;
  2251. }
  2252. foreach $child (keys %{$self->{CHILDREN}}) {
  2253. if ($self->{CHILDREN}->{$child}->needs_linking) {
  2254. $self->{NEEDS_LINKING} = 1;
  2255. return 1;
  2256. }
  2257. }
  2258. return $self->{NEEDS_LINKING} = 0;
  2259. }
  2260. =item nicetext
  2261. misnamed method (will have to be changed). The MM_Unix method just
  2262. returns the argument without further processing.
  2263. On VMS used to insure that colons marking targets are preceded by
  2264. space - most Unix Makes don't need this, but it's necessary under VMS
  2265. to distinguish the target delimiter from a colon appearing as part of
  2266. a filespec.
  2267. =cut
  2268. sub nicetext {
  2269. my($self,$text) = @_;
  2270. $text;
  2271. }
  2272. =item parse_version
  2273. parse a file and return what you think is $VERSION in this file set to.
  2274. It will return the string "undef" if it can't figure out what $VERSION
  2275. is.
  2276. =cut
  2277. sub parse_version {
  2278. my($self,$parsefile) = @_;
  2279. my $result;
  2280. local *FH;
  2281. local $/ = "\n";
  2282. open(FH,$parsefile) or die "Could not open '$parsefile': $!";
  2283. my $inpod = 0;
  2284. while (<FH>) {
  2285. $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
  2286. next if $inpod;
  2287. chop;
  2288. # next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/;
  2289. next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
  2290. my $eval = qq{
  2291. package ExtUtils::MakeMaker::_version;
  2292. no strict;
  2293. local $1$2;
  2294. \$$2=undef; do {
  2295. $_
  2296. }; \$$2
  2297. };
  2298. no warnings;
  2299. $result = eval($eval);
  2300. warn "Could not eval '$eval' in $parsefile: $@" if $@;
  2301. $result = "undef" unless defined $result;
  2302. last;
  2303. }
  2304. close FH;
  2305. return $result;
  2306. }
  2307. =item parse_abstract
  2308. parse a file and return what you think is the ABSTRACT
  2309. =cut
  2310. sub parse_abstract {
  2311. my($self,$parsefile) = @_;
  2312. my $result;
  2313. local *FH;
  2314. local $/ = "\n";
  2315. open(FH,$parsefile) or die "Could not open '$parsefile': $!";
  2316. my $inpod = 0;
  2317. my $package = $self->{DISTNAME};
  2318. $package =~ s/-/::/g;
  2319. while (<FH>) {
  2320. $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
  2321. next if !$inpod;
  2322. chop;
  2323. next unless /^($package\s-\s)(.*)/;
  2324. $result = $2;
  2325. last;
  2326. }
  2327. close FH;
  2328. return $result;
  2329. }
  2330. =item pasthru (o)
  2331. Defines the string that is passed to recursive make calls in
  2332. subdirectories.
  2333. =cut
  2334. sub pasthru {
  2335. my($self) = shift;
  2336. my(@m,$key);
  2337. my(@pasthru);
  2338. my($sep) = $Is_VMS ? ',' : '';
  2339. $sep .= "\\\n\t";
  2340. foreach $key (qw(LIB LIBPERL_A LINKTYPE PREFIX OPTIMIZE)){
  2341. push @pasthru, "$key=\"\$($key)\"";
  2342. }
  2343. push @m, "\nPASTHRU = ", join ($sep, @pasthru), "\n";
  2344. join "", @m;
  2345. }
  2346. =item path
  2347. Takes no argument, returns the environment variable PATH as an array.
  2348. =cut
  2349. sub path {
  2350. my($self) = @_;
  2351. my $path_sep = ($Is_OS2 || $Is_Dos) ? ";" : ":";
  2352. my $path = $ENV{PATH};
  2353. $path =~ s:\\:/:g if $Is_OS2;
  2354. my @path = split $path_sep, $path;
  2355. foreach(@path) { $_ = '.' if $_ eq '' }
  2356. @path;
  2357. }
  2358. =item perl_script
  2359. Takes one argument, a file name, and returns the file name, if the
  2360. argument is likely to be a perl script. On MM_Unix this is true for
  2361. any ordinary, readable file.
  2362. =cut
  2363. sub perl_script {
  2364. my($self,$file) = @_;
  2365. return $file if -r $file && -f _;
  2366. return;
  2367. }
  2368. =item perldepend (o)
  2369. Defines the dependency from all *.h files that come with the perl
  2370. distribution.
  2371. =cut
  2372. sub perldepend {
  2373. my($self) = shift;
  2374. my(@m);
  2375. push @m, q{
  2376. # Check for unpropogated config.sh changes. Should never happen.
  2377. # We do NOT just update config.h because that is not sufficient.
  2378. # An out of date config.h is not fatal but complains loudly!
  2379. $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
  2380. -}.$self->{NOECHO}.q{echo "Warning: $(PERL_INC)/config.h out of date with $(PERL_SRC)/config.sh"; false
  2381. $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
  2382. }.$self->{NOECHO}.q{echo "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
  2383. cd $(PERL_SRC) && $(MAKE) lib/Config.pm
  2384. } if $self->{PERL_SRC};
  2385. return join "", @m unless $self->needs_linking;
  2386. push @m, q{
  2387. PERL_HDRS = \
  2388. $(PERL_INC)/EXTERN.h \
  2389. $(PERL_INC)/INTERN.h \
  2390. $(PERL_INC)/XSUB.h \
  2391. $(PERL_INC)/av.h \
  2392. $(PERL_INC)/cc_runtime.h \
  2393. $(PERL_INC)/config.h \
  2394. $(PERL_INC)/cop.h \
  2395. $(PERL_INC)/cv.h \
  2396. $(PERL_INC)/dosish.h \
  2397. $(PERL_INC)/embed.h \
  2398. $(PERL_INC)/embedvar.h \
  2399. $(PERL_INC)/fakethr.h \
  2400. $(PERL_INC)/form.h \
  2401. $(PERL_INC)/gv.h \
  2402. $(PERL_INC)/handy.h \
  2403. $(PERL_INC)/hv.h \
  2404. $(PERL_INC)/intrpvar.h \
  2405. $(PERL_INC)/iperlsys.h \
  2406. $(PERL_INC)/keywords.h \
  2407. $(PERL_INC)/mg.h \
  2408. $(PERL_INC)/nostdio.h \
  2409. $(PERL_INC)/objXSUB.h \
  2410. $(PERL_INC)/op.h \
  2411. $(PERL_INC)/opcode.h \
  2412. $(PERL_INC)/opnames.h \
  2413. $(PERL_INC)/patchlevel.h \
  2414. $(PERL_INC)/perl.h \
  2415. $(PERL_INC)/perlapi.h \
  2416. $(PERL_INC)/perlio.h \
  2417. $(PERL_INC)/perlsdio.h \
  2418. $(PERL_INC)/perlsfio.h \
  2419. $(PERL_INC)/perlvars.h \
  2420. $(PERL_INC)/perly.h \
  2421. $(PERL_INC)/pp.h \
  2422. $(PERL_INC)/pp_proto.h \
  2423. $(PERL_INC)/proto.h \
  2424. $(PERL_INC)/regcomp.h \
  2425. $(PERL_INC)/regexp.h \
  2426. $(PERL_INC)/regnodes.h \
  2427. $(PERL_INC)/scope.h \
  2428. $(PERL_INC)/sv.h \
  2429. $(PERL_INC)/thrdvar.h \
  2430. $(PERL_INC)/thread.h \
  2431. $(PERL_INC)/unixish.h \
  2432. $(PERL_INC)/utf8.h \
  2433. $(PERL_INC)/util.h \
  2434. $(PERL_INC)/warnings.h
  2435. $(OBJECT) : $(PERL_HDRS)
  2436. } if $self->{OBJECT};
  2437. push @m, join(" ", values %{$self->{XS}})." : \$(XSUBPPDEPS)\n" if %{$self->{XS}};
  2438. join "\n", @m;
  2439. }
  2440. =item ppd
  2441. Defines target that creates a PPD (Perl Package Description) file
  2442. for a binary distribution.
  2443. =cut
  2444. sub ppd {
  2445. my($self) = @_;
  2446. my(@m);
  2447. if ($self->{ABSTRACT_FROM}){
  2448. $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
  2449. Carp::carp "WARNING: Setting ABSTRACT via file '$self->{ABSTRACT_FROM}' failed\n";
  2450. }
  2451. my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0) x 4) [0 .. 3];
  2452. push(@m, "# Creates a PPD (Perl Package Description) for a binary distribution.\n");
  2453. push(@m, "ppd:\n");
  2454. push(@m, "\t\@\$(PERL) -e \"print qq{<SOFTPKG NAME=\\\"$self->{DISTNAME}\\\" VERSION=\\\"$pack_ver\\\">\\n}");
  2455. push(@m, ". qq{\\t<TITLE>$self->{DISTNAME}</TITLE>\\n}");
  2456. my $abstract = $self->{ABSTRACT};
  2457. $abstract =~ s/\n/\\n/sg;
  2458. $abstract =~ s/</&lt;/g;
  2459. $abstract =~ s/>/&gt;/g;
  2460. push(@m, ". qq{\\t<ABSTRACT>$abstract</ABSTRACT>\\n}");
  2461. my ($author) = $self->{AUTHOR};
  2462. $author =~ s/</&lt;/g;
  2463. $author =~ s/>/&gt;/g;
  2464. $author =~ s/@/\\@/g;
  2465. push(@m, ". qq{\\t<AUTHOR>$author</AUTHOR>\\n}");
  2466. push(@m, ". qq{\\t<IMPLEMENTATION>\\n}");
  2467. my ($prereq);
  2468. foreach $prereq (sort keys %{$self->{PREREQ_PM}}) {
  2469. my $pre_req = $prereq;
  2470. $pre_req =~ s/::/-/g;
  2471. my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}), (0) x 4) [0 .. 3];
  2472. push(@m, ". qq{\\t\\t<DEPENDENCY NAME=\\\"$pre_req\\\" VERSION=\\\"$dep_ver\\\" />\\n}");
  2473. }
  2474. push(@m, ". qq{\\t\\t<OS NAME=\\\"\$(OSNAME)\\\" />\\n}");
  2475. push(@m, ". qq{\\t\\t<ARCHITECTURE NAME=\\\"$Config{'archname'}\\\" />\\n}");
  2476. my ($bin_location) = $self->{BINARY_LOCATION};
  2477. $bin_location =~ s/\\/\\\\/g;
  2478. if ($self->{PPM_INSTALL_SCRIPT}) {
  2479. if ($self->{PPM_INSTALL_EXEC}) {
  2480. push(@m, " . qq{\\t\\t<INSTALL EXEC=\\\"$self->{PPM_INSTALL_EXEC}\\\">$self->{PPM_INSTALL_SCRIPT}</INSTALL>\\n}");
  2481. }
  2482. else {
  2483. push(@m, " . qq{\\t\\t<INSTALL>$self->{PPM_INSTALL_SCRIPT}</INSTALL>\\n}");
  2484. }
  2485. }
  2486. push(@m, ". qq{\\t\\t<CODEBASE HREF=\\\"$bin_location\\\" />\\n}");
  2487. push(@m, ". qq{\\t</IMPLEMENTATION>\\n}");
  2488. push(@m, ". qq{</SOFTPKG>\\n}\" > $self->{DISTNAME}.ppd");
  2489. join("", @m);
  2490. }
  2491. =item perm_rw (o)
  2492. Returns the attribute C<PERM_RW> or the string C<644>.
  2493. Used as the string that is passed
  2494. to the C<chmod> command to set the permissions for read/writeable files.
  2495. MakeMaker chooses C<644> because it has turned out in the past that
  2496. relying on the umask provokes hard-to-track bug reports.
  2497. When the return value is used by the perl function C<chmod>, it is
  2498. interpreted as an octal value.
  2499. =cut
  2500. sub perm_rw {
  2501. shift->{PERM_RW} || "644";
  2502. }
  2503. =item perm_rwx (o)
  2504. Returns the attribute C<PERM_RWX> or the string C<755>,
  2505. i.e. the string that is passed
  2506. to the C<chmod> command to set the permissions for executable files.
  2507. See also perl_rw.
  2508. =cut
  2509. sub perm_rwx {
  2510. shift->{PERM_RWX} || "755";
  2511. }
  2512. =item pm_to_blib
  2513. Defines target that copies all files in the hash PM to their
  2514. destination and autosplits them. See L<ExtUtils::Install/DESCRIPTION>
  2515. =cut
  2516. sub pm_to_blib {
  2517. my $self = shift;
  2518. my($autodir) = $self->catdir('$(INST_LIB)','auto');
  2519. return q{
  2520. pm_to_blib: $(TO_INST_PM)
  2521. }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
  2522. "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
  2523. -e "pm_to_blib({qw{$(PM_TO_BLIB)}},'}.$autodir.q{','$(PM_FILTER)')"
  2524. }.$self->{NOECHO}.q{$(TOUCH) $@
  2525. };
  2526. }
  2527. =item post_constants (o)
  2528. Returns an empty string per default. Dedicated to overrides from
  2529. within Makefile.PL after all constants have been defined.
  2530. =cut
  2531. sub post_constants{
  2532. my($self) = shift;
  2533. "";
  2534. }
  2535. =item post_initialize (o)
  2536. Returns an empty string per default. Used in Makefile.PLs to add some
  2537. chunk of text to the Makefile after the object is initialized.
  2538. =cut
  2539. sub post_initialize {
  2540. my($self) = shift;
  2541. "";
  2542. }
  2543. =item postamble (o)
  2544. Returns an empty string. Can be used in Makefile.PLs to write some
  2545. text to the Makefile at the end.
  2546. =cut
  2547. sub postamble {
  2548. my($self) = shift;
  2549. "";
  2550. }
  2551. =item prefixify
  2552. Check a path variable in $self from %Config, if it contains a prefix,
  2553. and replace it with another one.
  2554. Takes as arguments an attribute name, a search prefix and a
  2555. replacement prefix. Changes the attribute in the object.
  2556. =cut
  2557. sub prefixify {
  2558. my($self,$var,$sprefix,$rprefix) = @_;
  2559. $self->{uc $var} ||= $Config{lc $var};
  2560. $self->{uc $var} = VMS::Filespec::unixpath($self->{uc $var}) if $Is_VMS;
  2561. $self->{uc $var} =~ s/\Q$sprefix\E/$rprefix/s;
  2562. }
  2563. =item processPL (o)
  2564. Defines targets to run *.PL files.
  2565. =cut
  2566. sub processPL {
  2567. my($self) = shift;
  2568. return "" unless $self->{PL_FILES};
  2569. my(@m, $plfile);
  2570. foreach $plfile (sort keys %{$self->{PL_FILES}}) {
  2571. my $list = ref($self->{PL_FILES}->{$plfile})
  2572. ? $self->{PL_FILES}->{$plfile}
  2573. : [$self->{PL_FILES}->{$plfile}];
  2574. my $target;
  2575. foreach $target (@$list) {
  2576. push @m, "
  2577. all :: $target
  2578. $self->{NOECHO}\$(NOOP)
  2579. $target :: $plfile
  2580. \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile $target
  2581. ";
  2582. }
  2583. }
  2584. join "", @m;
  2585. }
  2586. =item realclean (o)
  2587. Defines the realclean target.
  2588. =cut
  2589. sub realclean {
  2590. my($self, %attribs) = @_;
  2591. my(@m);
  2592. push(@m,'
  2593. # Delete temporary files (via clean) and also delete installed files
  2594. realclean purge :: clean
  2595. ');
  2596. # realclean subdirectories first (already cleaned)
  2597. my $sub = ($Is_Win32 && Win32::IsWin95()) ?
  2598. "\tcd %s\n\t\$(TEST_F) %s\n\t\$(MAKE) %s realclean\n\tcd ..\n" :
  2599. "\t-cd %s && \$(TEST_F) %s && \$(MAKE) %s realclean\n";
  2600. foreach(@{$self->{DIR}}){
  2601. push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old"));
  2602. push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",''));
  2603. }
  2604. push(@m, " $self->{RM_RF} \$(INST_AUTODIR) \$(INST_ARCHAUTODIR)\n");
  2605. if( $self->has_link_code ){
  2606. push(@m, " $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
  2607. push(@m, " $self->{RM_F} \$(INST_STATIC)\n");
  2608. }
  2609. # Issue a several little RM_F commands rather than risk creating a
  2610. # very long command line (useful for extensions such as Encode
  2611. # that have many files).
  2612. if (keys %{$self->{PM}}) {
  2613. my $line = "";
  2614. foreach (values %{$self->{PM}}) {
  2615. if (length($line) + length($_) > 80) {
  2616. push @m, "\t$self->{RM_F} $line\n";
  2617. $line = $_;
  2618. }
  2619. else {
  2620. $line .= " $_";
  2621. }
  2622. }
  2623. push @m, "\t$self->{RM_F} $line\n" if $line;
  2624. }
  2625. my(@otherfiles) = ($self->{MAKEFILE},
  2626. "$self->{MAKEFILE}.old"); # Makefiles last
  2627. push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
  2628. push(@m, " $self->{RM_RF} @otherfiles\n") if @otherfiles;
  2629. push(@m, " $attribs{POSTOP}\n") if $attribs{POSTOP};
  2630. join("", @m);
  2631. }
  2632. =item replace_manpage_separator
  2633. Takes the name of a package, which may be a nested package, in the
  2634. form Foo/Bar and replaces the slash with C<::>. Returns the replacement.
  2635. =cut
  2636. sub replace_manpage_separator {
  2637. my($self,$man) = @_;
  2638. if ($^O eq 'uwin') {
  2639. $man =~ s,/+,.,g;
  2640. } elsif ($Is_Dos) {
  2641. $man =~ s,/+,__,g;
  2642. } else {
  2643. $man =~ s,/+,::,g;
  2644. }
  2645. $man;
  2646. }
  2647. =item static (o)
  2648. Defines the static target.
  2649. =cut
  2650. sub static {
  2651. # --- Static Loading Sections ---
  2652. my($self) = shift;
  2653. '
  2654. ## $(INST_PM) has been moved to the all: target.
  2655. ## It remains here for awhile to allow for old usage: "make static"
  2656. #static :: '.$self->{MAKEFILE}.' $(INST_STATIC) $(INST_PM)
  2657. static :: '.$self->{MAKEFILE}.' $(INST_STATIC)
  2658. '.$self->{NOECHO}.'$(NOOP)
  2659. ';
  2660. }
  2661. =item static_lib (o)
  2662. Defines how to produce the *.a (or equivalent) files.
  2663. =cut
  2664. sub static_lib {
  2665. my($self) = @_;
  2666. # Come to think of it, if there are subdirs with linkcode, we still have no INST_STATIC
  2667. # return '' unless $self->needs_linking(); #might be because of a subdir
  2668. return '' unless $self->has_link_code;
  2669. my(@m);
  2670. push(@m, <<'END');
  2671. $(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)/.exists
  2672. $(RM_RF) $@
  2673. END
  2674. # If this extension has it's own library (eg SDBM_File)
  2675. # then copy that to $(INST_STATIC) and add $(OBJECT) into it.
  2676. push(@m, "\t$self->{CP} \$(MYEXTLIB) \$\@\n") if $self->{MYEXTLIB};
  2677. my $ar;
  2678. if (exists $self->{FULL_AR} && -x $self->{FULL_AR}) {
  2679. # Prefer the absolute pathed ar if available so that PATH
  2680. # doesn't confuse us. Perl itself is built with the full_ar.
  2681. $ar = 'FULL_AR';
  2682. } else {
  2683. $ar = 'AR';
  2684. }
  2685. push @m,
  2686. "\t\$($ar) ".'$(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@'."\n";
  2687. push @m,
  2688. q{ $(CHMOD) $(PERM_RWX) $@
  2689. }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
  2690. };
  2691. # Old mechanism - still available:
  2692. push @m,
  2693. "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
  2694. } if $self->{PERL_SRC} && $self->{EXTRALIBS};
  2695. push @m, "\n";
  2696. push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
  2697. join('', "\n",@m);
  2698. }
  2699. =item staticmake (o)
  2700. Calls makeaperl.
  2701. =cut
  2702. sub staticmake {
  2703. my($self, %attribs) = @_;
  2704. my(@static);
  2705. my(@searchdirs)=($self->{PERL_ARCHLIB}, $self->{SITEARCHEXP}, $self->{INST_ARCHLIB});
  2706. # And as it's not yet built, we add the current extension
  2707. # but only if it has some C code (or XS code, which implies C code)
  2708. if (@{$self->{C}}) {
  2709. @static = $self->catfile($self->{INST_ARCHLIB},
  2710. "auto",
  2711. $self->{FULLEXT},
  2712. "$self->{BASEEXT}$self->{LIB_EXT}"
  2713. );
  2714. }
  2715. # Either we determine now, which libraries we will produce in the
  2716. # subdirectories or we do it at runtime of the make.
  2717. # We could ask all subdir objects, but I cannot imagine, why it
  2718. # would be necessary.
  2719. # Instead we determine all libraries for the new perl at
  2720. # runtime.
  2721. my(@perlinc) = ($self->{INST_ARCHLIB}, $self->{INST_LIB}, $self->{PERL_ARCHLIB}, $self->{PERL_LIB});
  2722. $self->makeaperl(MAKE => $self->{MAKEFILE},
  2723. DIRS => \@searchdirs,
  2724. STAT => \@static,
  2725. INCL => \@perlinc,
  2726. TARGET => $self->{MAP_TARGET},
  2727. TMP => "",
  2728. LIBPERL => $self->{LIBPERL_A}
  2729. );
  2730. }
  2731. =item subdir_x (o)
  2732. Helper subroutine for subdirs
  2733. =cut
  2734. sub subdir_x {
  2735. my($self, $subdir) = @_;
  2736. my(@m);
  2737. if ($Is_Win32 && Win32::IsWin95()) {
  2738. # XXX: dmake-specific, like rest of Win95 port
  2739. return <<EOT;
  2740. subdirs ::
  2741. @[
  2742. cd $subdir
  2743. \$(MAKE) all \$(PASTHRU)
  2744. cd ..
  2745. ]
  2746. EOT
  2747. }
  2748. else {
  2749. return <<EOT;
  2750. subdirs ::
  2751. $self->{NOECHO}cd $subdir && \$(MAKE) all \$(PASTHRU)
  2752. EOT
  2753. }
  2754. }
  2755. =item subdirs (o)
  2756. Defines targets to process subdirectories.
  2757. =cut
  2758. sub subdirs {
  2759. # --- Sub-directory Sections ---
  2760. my($self) = shift;
  2761. my(@m,$dir);
  2762. # This method provides a mechanism to automatically deal with
  2763. # subdirectories containing further Makefile.PL scripts.
  2764. # It calls the subdir_x() method for each subdirectory.
  2765. foreach $dir (@{$self->{DIR}}){
  2766. push(@m, $self->subdir_x($dir));
  2767. #### print "Including $dir subdirectory\n";
  2768. }
  2769. if (@m){
  2770. unshift(@m, "
  2771. # The default clean, realclean and test targets in this Makefile
  2772. # have automatically been given entries for each subdir.
  2773. ");
  2774. } else {
  2775. push(@m, "\n# none")
  2776. }
  2777. join('',@m);
  2778. }
  2779. =item test (o)
  2780. Defines the test targets.
  2781. =cut
  2782. sub test {
  2783. # --- Test and Installation Sections ---
  2784. my($self, %attribs) = @_;
  2785. my $tests = $attribs{TESTS};
  2786. if (!$tests && -d 't') {
  2787. $tests = $Is_Win32 ? join(' ', <t\\*.t>) : 't/*.t';
  2788. }
  2789. # note: 'test.pl' name is also hardcoded in init_dirscan()
  2790. my(@m);
  2791. push(@m,"
  2792. TEST_VERBOSE=0
  2793. TEST_TYPE=test_\$(LINKTYPE)
  2794. TEST_FILE = test.pl
  2795. TEST_FILES = $tests
  2796. TESTDB_SW = -d
  2797. testdb :: testdb_\$(LINKTYPE)
  2798. test :: \$(TEST_TYPE)
  2799. ");
  2800. push(@m, map("\t$self->{NOECHO}cd $_ && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
  2801. @{$self->{DIR}}));
  2802. push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n")
  2803. unless $tests or -f "test.pl" or @{$self->{DIR}};
  2804. push(@m, "\n");
  2805. push(@m, "test_dynamic :: pure_all\n");
  2806. push(@m, $self->test_via_harness('$(FULLPERL)', '$(TEST_FILES)')) if $tests;
  2807. push(@m, $self->test_via_script('$(FULLPERL)', '$(TEST_FILE)')) if -f "test.pl";
  2808. push(@m, "\n");
  2809. push(@m, "testdb_dynamic :: pure_all\n");
  2810. push(@m, $self->test_via_script('$(FULLPERL) $(TESTDB_SW)', '$(TEST_FILE)'));
  2811. push(@m, "\n");
  2812. # Occasionally we may face this degenerate target:
  2813. push @m, "test_ : test_dynamic\n\n";
  2814. if ($self->needs_linking()) {
  2815. push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
  2816. push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
  2817. push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
  2818. push(@m, "\n");
  2819. push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
  2820. push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
  2821. push(@m, "\n");
  2822. } else {
  2823. push @m, "test_static :: test_dynamic\n";
  2824. push @m, "testdb_static :: testdb_dynamic\n";
  2825. }
  2826. join("", @m);
  2827. }
  2828. =item test_via_harness (o)
  2829. Helper method to write the test targets
  2830. =cut
  2831. sub test_via_harness {
  2832. my($self, $perl, $tests) = @_;
  2833. $perl = "PERL_DL_NONLAZY=1 $perl" unless $Is_Win32;
  2834. "\t$perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
  2835. }
  2836. =item test_via_script (o)
  2837. Other helper method for test.
  2838. =cut
  2839. sub test_via_script {
  2840. my($self, $perl, $script) = @_;
  2841. $perl = "PERL_DL_NONLAZY=1 $perl" unless $Is_Win32;
  2842. qq{\t$perl}.q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) }.qq{$script
  2843. };
  2844. }
  2845. =item tool_autosplit (o)
  2846. Defines a simple perl call that runs autosplit. May be deprecated by
  2847. pm_to_blib soon.
  2848. =cut
  2849. sub tool_autosplit {
  2850. # --- Tool Sections ---
  2851. my($self, %attribs) = @_;
  2852. my($asl) = "";
  2853. $asl = "\$AutoSplit::Maxlen=$attribs{MAXLEN};" if $attribs{MAXLEN};
  2854. q{
  2855. # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
  2856. AUTOSPLITFILE = $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e 'use AutoSplit;}.$asl.q{autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1) ;'
  2857. };
  2858. }
  2859. =item tools_other (o)
  2860. Defines SHELL, LD, TOUCH, CP, MV, RM_F, RM_RF, CHMOD, UMASK_NULL in
  2861. the Makefile. Also defines the perl programs MKPATH,
  2862. WARN_IF_OLD_PACKLIST, MOD_INSTALL. DOC_INSTALL, and UNINSTALL.
  2863. =cut
  2864. sub tools_other {
  2865. my($self) = shift;
  2866. my @m;
  2867. my $bin_sh = $Config{sh} || '/bin/sh';
  2868. push @m, qq{
  2869. SHELL = $bin_sh
  2870. };
  2871. for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
  2872. push @m, "$_ = $self->{$_}\n";
  2873. }
  2874. push @m, q{
  2875. # The following is a portable way to say mkdir -p
  2876. # To see which directories are created, change the if 0 to if 1
  2877. MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
  2878. # This helps us to minimize the effect of the .exists files A yet
  2879. # better solution would be to have a stable file in the perl
  2880. # distribution with a timestamp of zero. But this solution doesn't
  2881. # need any changes to the core distribution and works with older perls
  2882. EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
  2883. };
  2884. return join "", @m if $self->{PARENT};
  2885. push @m, q{
  2886. # Here we warn users that an old packlist file was found somewhere,
  2887. # and that they should call some uninstall routine
  2888. WARN_IF_OLD_PACKLIST = $(PERL) -we 'exit unless -f $$ARGV[0];' \\
  2889. -e 'print "WARNING: I have found an old package in\n";' \\
  2890. -e 'print "\t$$ARGV[0].\n";' \\
  2891. -e 'print "Please make sure the two installations are not conflicting\n";'
  2892. UNINST=0
  2893. VERBINST=0
  2894. MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
  2895. -e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');"
  2896. DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \
  2897. -e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", $$arg=shift, "|", $$arg, ">";' \
  2898. -e 'print "=over 4";' \
  2899. -e 'while (defined($$key = shift) and defined($$val = shift)){print "=item *";print "C<$$key: $$val>";}' \
  2900. -e 'print "=back";'
  2901. UNINSTALL = $(PERL) -MExtUtils::Install \
  2902. -e 'uninstall($$ARGV[0],1,1); print "\nUninstall is deprecated. Please check the";' \
  2903. -e 'print " packlist above carefully.\n There may be errors. Remove the";' \
  2904. -e 'print " appropriate files manually.\n Sorry for the inconveniences.\n"'
  2905. };
  2906. return join "", @m;
  2907. }
  2908. =item tool_xsubpp (o)
  2909. Determines typemaps, xsubpp version, prototype behaviour.
  2910. =cut
  2911. sub tool_xsubpp {
  2912. my($self) = shift;
  2913. return "" unless $self->needs_linking;
  2914. my($xsdir) = $self->catdir($self->{PERL_LIB},"ExtUtils");
  2915. my(@tmdeps) = $self->catdir('$(XSUBPPDIR)','typemap');
  2916. if( $self->{TYPEMAPS} ){
  2917. my $typemap;
  2918. foreach $typemap (@{$self->{TYPEMAPS}}){
  2919. if( ! -f $typemap ){
  2920. warn "Typemap $typemap not found.\n";
  2921. }
  2922. else{
  2923. push(@tmdeps, $typemap);
  2924. }
  2925. }
  2926. }
  2927. push(@tmdeps, "typemap") if -f "typemap";
  2928. my(@tmargs) = map("-typemap $_", @tmdeps);
  2929. if( exists $self->{XSOPT} ){
  2930. unshift( @tmargs, $self->{XSOPT} );
  2931. }
  2932. my $xsubpp_version = $self->xsubpp_version($self->catfile($xsdir,"xsubpp"));
  2933. # What are the correct thresholds for version 1 && 2 Paul?
  2934. if ( $xsubpp_version > 1.923 ){
  2935. $self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
  2936. } else {
  2937. if (defined $self->{XSPROTOARG} && $self->{XSPROTOARG} =~ /\-prototypes/) {
  2938. print STDOUT qq{Warning: This extension wants to pass the switch "-prototypes" to xsubpp.
  2939. Your version of xsubpp is $xsubpp_version and cannot handle this.
  2940. Please upgrade to a more recent version of xsubpp.
  2941. };
  2942. } else {
  2943. $self->{XSPROTOARG} = "";
  2944. }
  2945. }
  2946. my $xsubpp = "xsubpp";
  2947. return qq{
  2948. XSUBPPDIR = $xsdir
  2949. XSUBPP = \$(XSUBPPDIR)/$xsubpp
  2950. XSPROTOARG = $self->{XSPROTOARG}
  2951. XSUBPPDEPS = @tmdeps \$(XSUBPP)
  2952. XSUBPPARGS = @tmargs
  2953. };
  2954. };
  2955. sub xsubpp_version
  2956. {
  2957. my($self,$xsubpp) = @_;
  2958. return $Xsubpp_Version if defined $Xsubpp_Version; # global variable
  2959. my ($version) ;
  2960. # try to figure out the version number of the xsubpp on the system
  2961. # first try the -v flag, introduced in 1.921 & 2.000a2
  2962. return "" unless $self->needs_linking;
  2963. my $command = "$self->{PERL} -I$self->{PERL_LIB} $xsubpp -v 2>&1";
  2964. print "Running $command\n" if $Verbose >= 2;
  2965. $version = `$command` ;
  2966. warn "Running '$command' exits with status " . ($?>>8) if $?;
  2967. chop $version ;
  2968. return $Xsubpp_Version = $1 if $version =~ /^xsubpp version (.*)/ ;
  2969. # nope, then try something else
  2970. my $counter = '000';
  2971. my ($file) = 'temp' ;
  2972. $counter++ while -e "$file$counter"; # don't overwrite anything
  2973. $file .= $counter;
  2974. open(F, ">$file") or die "Cannot open file '$file': $!\n" ;
  2975. print F <<EOM ;
  2976. MODULE = fred PACKAGE = fred
  2977. int
  2978. fred(a)
  2979. int a;
  2980. EOM
  2981. close F ;
  2982. $command = "$self->{PERL} $xsubpp $file 2>&1";
  2983. print "Running $command\n" if $Verbose >= 2;
  2984. my $text = `$command` ;
  2985. warn "Running '$command' exits with status " . ($?>>8) if $?;
  2986. unlink $file ;
  2987. # gets 1.2 -> 1.92 and 2.000a1
  2988. return $Xsubpp_Version = $1 if $text =~ /automatically by xsubpp version ([\S]+)\s*/ ;
  2989. # it is either 1.0 or 1.1
  2990. return $Xsubpp_Version = 1.1 if $text =~ /^Warning: ignored semicolon/ ;
  2991. # none of the above, so 1.0
  2992. return $Xsubpp_Version = "1.0" ;
  2993. }
  2994. =item top_targets (o)
  2995. Defines the targets all, subdirs, config, and O_FILES
  2996. =cut
  2997. sub top_targets {
  2998. # --- Target Sections ---
  2999. my($self) = shift;
  3000. my(@m);
  3001. push @m, '
  3002. #all :: config $(INST_PM) subdirs linkext manifypods
  3003. ';
  3004. push @m, '
  3005. all :: pure_all htmlifypods manifypods
  3006. '.$self->{NOECHO}.'$(NOOP)
  3007. '
  3008. unless $self->{SKIPHASH}{'all'};
  3009. push @m, '
  3010. pure_all :: config pm_to_blib subdirs linkext
  3011. '.$self->{NOECHO}.'$(NOOP)
  3012. subdirs :: $(MYEXTLIB)
  3013. '.$self->{NOECHO}.'$(NOOP)
  3014. config :: '.$self->{MAKEFILE}.' $(INST_LIBDIR)/.exists
  3015. '.$self->{NOECHO}.'$(NOOP)
  3016. config :: $(INST_ARCHAUTODIR)/.exists
  3017. '.$self->{NOECHO}.'$(NOOP)
  3018. config :: $(INST_AUTODIR)/.exists
  3019. '.$self->{NOECHO}.'$(NOOP)
  3020. ';
  3021. push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
  3022. if (%{$self->{HTMLLIBPODS}}) {
  3023. push @m, qq[
  3024. config :: \$(INST_HTMLLIBDIR)/.exists
  3025. $self->{NOECHO}\$(NOOP)
  3026. ];
  3027. push @m, $self->dir_target(qw[$(INST_HTMLLIBDIR)]);
  3028. }
  3029. if (%{$self->{HTMLSCRIPTPODS}}) {
  3030. push @m, qq[
  3031. config :: \$(INST_HTMLSCRIPTDIR)/.exists
  3032. $self->{NOECHO}\$(NOOP)
  3033. ];
  3034. push @m, $self->dir_target(qw[$(INST_HTMLSCRIPTDIR)]);
  3035. }
  3036. if (%{$self->{MAN1PODS}}) {
  3037. push @m, qq[
  3038. config :: \$(INST_MAN1DIR)/.exists
  3039. $self->{NOECHO}\$(NOOP)
  3040. ];
  3041. push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
  3042. }
  3043. if (%{$self->{MAN3PODS}}) {
  3044. push @m, qq[
  3045. config :: \$(INST_MAN3DIR)/.exists
  3046. $self->{NOECHO}\$(NOOP)
  3047. ];
  3048. push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
  3049. }
  3050. push @m, '
  3051. $(O_FILES): $(H_FILES)
  3052. ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
  3053. push @m, q{
  3054. help:
  3055. perldoc ExtUtils::MakeMaker
  3056. };
  3057. push @m, q{
  3058. Version_check:
  3059. }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
  3060. -MExtUtils::MakeMaker=Version_check \
  3061. -e "Version_check('$(MM_VERSION)')"
  3062. };
  3063. join('',@m);
  3064. }
  3065. =item writedoc
  3066. Obsolete, deprecated method. Not used since Version 5.21.
  3067. =cut
  3068. sub writedoc {
  3069. # --- perllocal.pod section ---
  3070. my($self,$what,$name,@attribs)=@_;
  3071. my $time = localtime;
  3072. print "=head2 $time: $what C<$name>\n\n=over 4\n\n=item *\n\n";
  3073. print join "\n\n=item *\n\n", map("C<$_>",@attribs);
  3074. print "\n\n=back\n\n";
  3075. }
  3076. =item xs_c (o)
  3077. Defines the suffix rules to compile XS files to C.
  3078. =cut
  3079. sub xs_c {
  3080. my($self) = shift;
  3081. return '' unless $self->needs_linking();
  3082. '
  3083. .xs.c:
  3084. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
  3085. ';
  3086. }
  3087. =item xs_cpp (o)
  3088. Defines the suffix rules to compile XS files to C++.
  3089. =cut
  3090. sub xs_cpp {
  3091. my($self) = shift;
  3092. return '' unless $self->needs_linking();
  3093. '
  3094. .xs.cpp:
  3095. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
  3096. ';
  3097. }
  3098. =item xs_o (o)
  3099. Defines suffix rules to go from XS to object files directly. This is
  3100. only intended for broken make implementations.
  3101. =cut
  3102. sub xs_o { # many makes are too dumb to use xs_c then c_o
  3103. my($self) = shift;
  3104. return '' unless $self->needs_linking();
  3105. '
  3106. .xs$(OBJ_EXT):
  3107. $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
  3108. $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
  3109. ';
  3110. }
  3111. =item perl_archive
  3112. This is internal method that returns path to libperl.a equivalent
  3113. to be linked to dynamic extensions. UNIX does not have one but OS2
  3114. and Win32 do.
  3115. =cut
  3116. sub perl_archive
  3117. {
  3118. return '$(PERL_INC)' . "/$Config{libperl}" if $^O eq "beos";
  3119. return "";
  3120. }
  3121. =item perl_archive_after
  3122. This is an internal method that returns path to a library which
  3123. should be put on the linker command line I<after> the external libraries
  3124. to be linked to dynamic extensions. This may be needed if the linker
  3125. is one-pass, and Perl includes some overrides for C RTL functions,
  3126. such as malloc().
  3127. =cut
  3128. sub perl_archive_after
  3129. {
  3130. return "";
  3131. }
  3132. =item export_list
  3133. This is internal method that returns name of a file that is
  3134. passed to linker to define symbols to be exported.
  3135. UNIX does not have one but OS2 and Win32 do.
  3136. =cut
  3137. sub export_list
  3138. {
  3139. return "";
  3140. }
  3141. 1;
  3142. =back
  3143. =head1 SEE ALSO
  3144. L<ExtUtils::MakeMaker>
  3145. =cut
  3146. __END__