"Fossies" - the Fresh Open Source Software Archive

Member "PDL-2.080/Makefile.PL" (22 May 2022, 14773 Bytes) of package /linux/misc/PDL-2.080.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Makefile.PL" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.079_vs_2.080.

    1 use strict;
    2 use warnings;
    3 
    4 eval { require Devel::CheckLib; Devel::CheckLib->import; };
    5 use 5.010_000;
    6 use ExtUtils::MakeMaker;
    7 use ExtUtils::MakeMaker::Config;
    8 use File::Spec;
    9 
   10 # file globals(!)
   11 my ($pdl_f77conf, $seen_f77conf);
   12 
   13 # The user specifies configuration options using the PDL_CONFIG
   14 # array in perldl.conf - or ~/.perldl.conf or via the PDLCONF command-line
   15 # argument.
   16 #
   17 # We need to use this information during the 'perl Makefile.PL' process,
   18 # and historically this has been done by directly accessing %PDL_CONFIG
   19 # (or %::PDL_CONFIG) variable. However, there are times that this information
   20 # is also needed during the actual build (ie 'make' cycle), at which point
   21 # the variable is not available. However Basic/Core/Config.pm is available,
   22 # but this uses the %PDL::Config variable to access the data.
   23 #
   24 # So, we try to avoid this dichotomy by creating a %PDL::Config during
   25 # the 'perl Makefile.PL' stage and then making sure that PDL_CONFIG
   26 # is destroyed (so it can't be used by accident).
   27 #
   28 # Do we need to worry about Makefile.PL's hacking PDL_CONFIG?
   29 # Probably...
   30 #
   31 %PDL::Config = ();
   32 
   33 sub getpdl_config {
   34   # read in distribution config file
   35   our %PDL_CONFIG;
   36   require './perldl.conf';
   37 
   38   # set up the default MALLOCDBG information (if not specified)
   39   #
   40   if ( exists $PDL_CONFIG{MALLOCDBG} and defined $PDL_CONFIG{MALLOCDBG} ) {
   41       my $val = $PDL_CONFIG{MALLOCDBG};
   42       my $rval = ref($val);
   43       die "ERROR: MALLOCDBG must be set to an associative array, not to a " .
   44     ( $rval ? $rval : "SCALAR" ) unless $rval eq "HASH";
   45   } else {
   46       $PDL_CONFIG{MALLOCDBG} = undef; # exists but undef
   47   }
   48   foreach my $item ( qw( libs include ) ) {
   49       $PDL_CONFIG{MALLOCDBG}->{$item} = ""
   50     unless exists $PDL_CONFIG{MALLOCDBG}->{$item};
   51   }
   52 
   53   # create a PDL::Config variable matching the PDL_CONFIG structure
   54   # and convert yes/no answers to 1/0
   55   #
   56   for my $key ( keys %PDL_CONFIG ) {
   57       my $val = $PDL_CONFIG{$key};
   58       $val =~ s/^y.*/1/i if defined $val;
   59       $val =~ s/^n.*/0/i if defined $val;
   60       $PDL::Config{$key} = $val;
   61   }
   62 
   63   # destroy PDL_CONFIG so that we can catch any accesses
   64   # to them in other Makefile.PL's
   65   #
   66   %PDL_CONFIG = ();
   67 }
   68 
   69 sub check_f77conf {
   70   my ($seenyet) = @_;
   71   return 0 unless $seenyet;
   72 
   73   my $pdl_f77conf = File::Spec->rel2abs($pdl_f77conf)
   74     unless File::Spec->file_name_is_absolute($pdl_f77conf);
   75   $PDL::Config{F77CONF} = $pdl_f77conf;
   76   return 1;
   77 }
   78 
   79 sub make_PDL_Config_pm {
   80   print "Writing Basic/Core/Config.pm\n";
   81   my $configFile = "Basic/Core/Config.pm";
   82   require Data::Dumper;
   83   no warnings 'once';
   84   local $Data::Dumper::Indent = 1;
   85   local $Data::Dumper::Terse = 1;
   86   local $Data::Dumper::Sortkeys = 1;
   87   open my $fh, ">", $configFile
   88     or die "Couldn't open $configFile for writing";
   89   my %config = %PDL::Config;
   90   delete $config{F77CONF}; # no store absolute path
   91   print $fh "
   92 # AUTOMATICALLY GENERATED BY THE PDL TOPLEVEL Makefile.PL.
   93 # DO NOT HAND-EDIT - CHANGES WILL BE LOST UPON YOUR NEXT
   94 #  'perl Makefile.PL'!!!
   95 package PDL::Config;
   96 use strict;
   97 use warnings;
   98 %PDL::Config = %{\n";
   99   print $fh Data::Dumper::Dumper(\%config), "};\n1;\n";
  100 }
  101 
  102 # Scan ARGV for config file argument
  103 @ARGV = map {
  104     if (/^F77CONF=(.*)$/) {
  105         $seen_f77conf=1;
  106         $pdl_f77conf=$1; ();
  107         } else {
  108         $_
  109     }
  110 } @ARGV;
  111 
  112 # needs to be called before any of the make_XX routines
  113 getpdl_config();
  114 $seen_f77conf = check_f77conf($seen_f77conf);
  115 
  116 # this will make PDL::Core::Dev's functions available
  117 # in Makefile.PL files in all subdirectories
  118 require "./Basic/Core/Dev.pm"; PDL::Core::Dev->import();
  119 $INC{'PDL/Core/Dev.pm'} = 1; # so require P:C:Dev will report success after
  120 
  121 my @podpms = map { $_.".pod", '$(INST_LIBDIR)/PDL/' . $_ .".pod"}
  122   qw/Bugs/;
  123 
  124 my @cpan_deps = my @prereq = (
  125   'Data::Dumper'        => 2.121,     # for PDL::IO::Dumper
  126   'File::Map'           => 0.57,      # test new mmap implementation
  127   'File::Which'         => 0,
  128   'Filter::Util::Call'  => 0,         # for PDL::NiceSlice
  129   'Filter::Simple'      => 0.88,      # for new PDL::NiceSlice
  130   'List::Util'          => '1.33',
  131   'Pod::Select'         => 0,         # version TBD for PDL::Doc
  132   'Scalar::Util'        => 0,
  133   'Storable'            => 1.03,      # for PDL::IO::Storable
  134   'Text::Balanced'      => '2.05',    # for PDL::NiceSlice
  135   'Math::Complex'       => 0,
  136 );
  137 my %min_version = (
  138   'OpenGL' => '0.70', # see also Graphics/Makefile.PL
  139   'OpenGL::GLUT' => '0.72', # see also Graphics/Makefile.PL
  140   'ExtUtils::F77' => '1.26', # eg 1.20 can leave off -lgfortran
  141   'Inline'              => 0.83,      # fixed ILSM-finding
  142   'Inline::C'           => 0.62,
  143   'Term::ReadKey'       => '2.34',      #for perldl shell
  144 );
  145 for my $opt_dep (sort keys %min_version) {
  146   (my $file = $opt_dep) =~ s#::#/#g;
  147   next if !eval { require "$file.pm"; 1 }; # not installed, fine
  148   next if eval { $opt_dep->VERSION($min_version{$opt_dep}); 1 };
  149   push @prereq, $opt_dep => $min_version{$opt_dep};
  150 }
  151 
  152 my @exe_files = qw(perldl pdldoc);
  153 push @exe_files, "pdl$Config{exe_ext}" if $^O !~ /MSWin/;
  154 my @cleanup = ("pdl$Config{exe_ext}", qw(
  155   pdldoc.db pdldoc.pod perldl.pod
  156 ));
  157 
  158 ##############################
  159 # Hack to include fPIC on x86_64 systems -
  160 # use similar mods to affect CCFLAGS on other systems as needed...
  161 
  162 my $ccflags =  $Config{ccflags};
  163 if($Config{archname}=~m/x86_64/) {
  164     $ccflags .= " -fPIC";
  165 }
  166 
  167 # create GENERATED subdir with *.pm files during 'make dist' (to make metacpan.org happy)
  168 my $preop = '$(PERLRUNINST) -MPDL::Core::Dev -e pdlpp_mkgen $(DISTVNAME)';
  169 
  170 my @optimize = (OPTIMIZE => $PDL::Config{OPTIMIZE}) if $PDL::Config{OPTIMIZE};
  171 
  172 my %makefile_hash = (
  173   PREREQ_PM => { @prereq },
  174   LICENSE => 'perl',
  175   CONFIGURE_REQUIRES => {
  176     'Devel::CheckLib' => 1.01,
  177     'Carp'            => 1.20,    # EU::MM seems to need this not to crash
  178     'ExtUtils::MakeMaker' => '7.12', # working .g.c
  179     'File::Path'          => 0,
  180     'ExtUtils::ParseXS'   => 3.01, # avoids 2.21, known broken
  181     'ExtUtils::Depends' => '0.402',
  182   },
  183   TEST_REQUIRES => {
  184     'CPAN::Meta' => '2.120900',
  185     'IPC::Cmd' => 0.72,
  186     'Test::Exception' => 0,
  187     'Test::Warn' => 0,  # for t/pptest.t
  188     'Test::Deep' => 0,
  189   },
  190   BUILD_REQUIRES => {
  191     'ExtUtils::MakeMaker' => 0,
  192     'File::Path'          => 0,
  193     'Pod::Select'         => 0,
  194   },
  195   MIN_PERL_VERSION => '5.010',
  196   NAME => 'PDL',
  197   VERSION_FROM => 'Basic/PDL.pm',
  198   EXE_FILES => \@exe_files,
  199   PM => { @podpms }, #so that the script docs are picked up
  200   META_MERGE => {
  201      "meta-spec" => { version => 2 },
  202      resources => {
  203         homepage => 'http://pdl.perl.org/',
  204         bugtracker  => {web=>'https://github.com/PDLPorters/pdl/issues'},
  205         repository  => {
  206            url => 'git://github.com/PDLPorters/pdl.git',
  207            type => 'git',
  208            web => 'https://github.com/PDLPorters/pdl',
  209         },
  210         x_IRC => 'irc://irc.perl.org/#pdl',
  211      },
  212      no_index => { file => ['Doc/scantree.pl'] },
  213      prereqs => {
  214         configure => {
  215            recommends => {
  216               'ExtUtils::F77' => '1.10',
  217               'PGPLOT' => 0,
  218            },
  219         },
  220         runtime => {
  221            suggests => {
  222               'Astro::FITS::Header' => 0,
  223               'Sys::SigAction' => 0, # Ctrl-C handling in shells
  224            },
  225            recommends => \%min_version,
  226            requires => { @cpan_deps },
  227         },
  228      },
  229   },
  230   @optimize,
  231   CCFLAGS => $ccflags,
  232   dist => { COMPRESS => 'gzip', SUFFIX => 'gz', PREOP => $preop },
  233   clean => {
  234     FILES => join ' ', @cleanup, qw(
  235       tbyte.tif tmp0 tmp0.hdr tushort.tif
  236       MANIFEST.bak tmp1* tmpraw* t/tmpraw* t/tmp1*
  237       _Inline/ .inlinepdlpp/ .inline-ct/ .inlinewith/ *.xfig
  238     ),
  239   },
  240   realclean => {'FILES' => 'Basic/Core/Config.pm'},
  241   AUTHOR => 'PerlDL Developers <pdl-general@lists.sourceforge.net>',
  242   ABSTRACT => 'Perl Data Language',
  243   BINARY_LOCATION => 'PDL.tar.gz',
  244 );
  245 
  246 WriteMakefile(%makefile_hash);
  247 
  248 # do *after* WriteMakefile since some options
  249 # are set by the recursively called Makefile.PLs
  250 make_PDL_Config_pm(); # write out config to PDL::Config
  251 
  252 # Extra build target to build the doc database
  253 sub MY::postamble {
  254   my ($self) = @_;
  255   package MY;
  256   my  $text =
  257 '
  258 doctest ::
  259     cd Doc && make test
  260     $(NOECHO) $(ECHO) "doctest: Building PDL documentation database in blib ..."
  261     $(NOECHO) $(PERLRUNINST) Doc$(DFSEP)scantree.pl
  262 %HTML%  $(NOECHO) $(ECHO) "doctest: Building PDL documentation web pages in blib ..."
  263 %HTML%  $(NOECHO) $(PERLRUNINST) Doc$(DFSEP)mkhtmldoc.pl
  264 
  265 doc_site_install :: doc_pdldoc_install
  266 
  267 doc_pdldoc_install :: pure_install # needs installed .../PDL dir to exist
  268     $(NOECHO) $(ECHO) "doc_site_install: Building PDL documentation database ..."
  269     $(NOECHO) $(PERLRUNINST) Doc$(DFSEP)scantree.pl "$(DESTDIR)$(INSTALLSITEARCH)"
  270 %HTML%  $(NOECHO) $(ECHO) "doc_site_install: Building PDL documentation web pages ..."
  271 %HTML%  $(NOECHO) $(PERL) Doc$(DFSEP)mkhtmldoc.pl "$(DESTDIR)$(INSTALLSITEARCH)$(DFSEP)PDL"
  272 
  273 doc_vendor_install ::
  274     $(NOECHO) $(ECHO) "doc_vendor_install: Building PDL documentation database ..."
  275     $(NOECHO) $(PERLRUNINST) Doc$(DFSEP)scantree.pl "$(DESTDIR)$(INSTALLVENDORARCH)"
  276 %HTML%  $(NOECHO) $(ECHO) "doc_vendor_install: Building PDL documentation web pages ..."
  277 %HTML%  $(NOECHO) $(PERL) Doc$(DFSEP)mkhtmldoc.pl "$(DESTDIR)$(INSTALLVENDORARCH)$(DFSEP)PDL"
  278 
  279 doc_perl_install ::
  280     $(NOECHO) $(ECHO) "doc_perl_install: Building PDL documentation database ..."
  281     $(NOECHO) $(PERLRUNINST) Doc$(DFSEP)scantree.pl "$(DESTDIR)$(INSTALLARCHLIB)"
  282 %HTML%  $(NOECHO) $(ECHO) "doc_perl_install: Building PDL documentation web pages ..."
  283 %HTML%  $(NOECHO) $(PERL) Doc$(DFSEP)mkhtmldoc.pl "$(DESTDIR)$(INSTALLARCHLIB)$(DFSEP)PDL"
  284 ';
  285 
  286   if(defined $PDL::Config{HTML_DOCS} && !$PDL::Config{HTML_DOCS}){
  287     $text=~ s/\%HTML\%[^\n]*\n//og; # Remove %HTML% lines
  288   } else {
  289     $text=~ s/\%HTML\%//og; # Remove just %HTML% markers
  290   }
  291 
  292 # Here, `pdl.c` is used directly because some makes (e.g., on Solaris) do not
  293 # support the `$<` variable in explicit rules
  294 $text .= <<EOT if $^O !~ /MSWin/;
  295 pdl$::Config{exe_ext} : pdl.c
  296     \$(CC) \$(CFLAGS) \$(LDFLAGS) \$(CCCDLFLAGS) pdl.c -o \$\@
  297 EOT
  298 
  299 $text .= << 'EOT' if $^O =~ /MSWin/;
  300 
  301 DISTWIN32NAME=$(DISTVNAME)-win32
  302 
  303 ppm : doctest ppd
  304     $(MV) blib$(DFSEP)lib$(DFSEP)PDL$(DFSEP)HtmlDocs$(DFSEP)PDL blib$(DFSEP)html$(DFSEP)lib$(DFSEP)PDL
  305     $(COMPRESS) -dc win32$(DFSEP)pbmwin32.tar.gz | $(TAR) xf -
  306     $(MKPATH) $(DISTWIN32NAME)
  307     $(CP) win32$(DFSEP)Readme $(DISTWIN32NAME)
  308     $(CP) win32$(DFSEP)install.ppm .
  309     $(PERL) -pe "s|<\x{2f}IMPLEMENTATION>|<INSTALL EXEC=\"perl\">install.ppm<\x{2f}INSTALL><\x{2f}IMPLEMENTATION>|" PDL.ppd > PDL.ppd.new
  310     $(RM) PDL.ppd
  311     $(MV) PDL.ppd.new PDL.ppd
  312     $(CP) PDL.ppd $(DISTWIN32NAME)
  313     $(TAR) cf $(DISTWIN32NAME)$(DFSEP)PDL.tar blib install.ppm
  314     cd $(DISTWIN32NAME)
  315     $(COMPRESS) PDL.tar
  316     $(ZIP) $(DISTWIN32NAME).zip *
  317     $(MV) $(DISTWIN32NAME).zip ..
  318     cd ..
  319     $(RM_RF) $(DISTWIN32NAME)
  320 EOT
  321 
  322 $text .= "\n" . ::coretarget($self);
  323 my $coretest = join ' ', map File::Spec->catfile('t', $_.'.t'), qw(
  324   01-pptest autoload bad basic bool clump config constructor core croak lvalue
  325   math matrix matrixops nat_complex ops-bitwise ops pdl_from_string
  326   pdlchar pp_croaking pp_line_numbers primitive pthread reduce
  327   slice subclass thread thread_def ufunc
  328 );
  329 $text .= <<EOF;
  330 
  331 coretest : core
  332     prove -b $coretest
  333 EOF
  334 
  335 return $text
  336 
  337 }
  338 
  339 # the modules to test the ones in full PDL
  340 my @basics; BEGIN { @basics = (
  341   [qw(IO Misc)],
  342   [qw(Libtmp Compression)],
  343   [qw(IO FITS)],
  344   [qw(Libtmp ImageRGB)],
  345   [qw(IO Pnm)],
  346   [qw(IO Storable)],
  347   [qw(Libtmp Image2D)],
  348   [qw(Libtmp ImageND)],
  349   [qw(Libtmp FFT)],
  350 ) }
  351 sub coretarget {
  352     my ($self) = @_;
  353     # remember the fundamental ones end up far to right as much deps on them
  354     # a "right" is either scalar (named target) or tuple of
  355     #     [ \@dir, \@targets, \@prereqs ]
  356     # @dir is dir parts for use by File::Spec
  357     # @targets is make targets within that dir
  358     # @prereqs are named targets - undef=[]
  359     # all a left's rights are made concurrently, no sequence - list ALL prereqs
  360     my @left2rights = (
  361         [
  362             coregen => [
  363                 [ [ qw(Basic) ], [ qw(pm_to_blib) ], ],
  364                 [ [ qw(Basic Core) ], [ qw(pm_to_blib) ], ],
  365                 [ [ qw(Basic Gen) ], [ qw(all) ], ],
  366             ]
  367         ],
  368         [
  369             core => [
  370                 [ [ qw(Basic SourceFilter) ], [ qw(pm_to_blib) ], ],
  371                 map [
  372                     [ 'Basic', $_ ],
  373                     [ qw(pm_to_blib dynamic) ],
  374                     [ 'coregen' ],
  375                 # the modules in PDL::LiteF, used in t/core.t
  376                 ], qw(Core Ops Primitive Ufunc Slices Bad Math MatrixOps),
  377             ]
  378         ],
  379         [
  380             basic => [
  381                 map [
  382                     $_,
  383                     [ qw(pm_to_blib dynamic) ],
  384                     [ 'core' ],
  385                 ], @basics,
  386             ]
  387         ],
  388         [
  389             basictest => [
  390                 map [
  391                     $_,
  392                     [ 'test' ],
  393                     [ 'basic' ],
  394                 ], @basics,
  395             ]
  396         ],
  397     );
  398     join "\n", map flatten_parallel_target($self, $_), @left2rights;
  399 }
  400 
  401 sub format_chunk {
  402     my ($self, $left, $deps, $dir, $targets) = @_;
  403     my @m = join ' ', $left, ':', @{$deps||[]};
  404     my $fsdir = File::Spec->catdir(@$dir);
  405     push @m, "\t" . $self->oneliner(
  406         "die \$! unless chdir q($fsdir); exec q(\$(MAKE) @$targets)"
  407     );
  408     join '', map "$_\n", @m;
  409 }
  410 
  411 # output: list of make chunks with target, deps, recipes
  412 sub flatten_parallel_target {
  413     my ($self, $left2rights) = @_;
  414     my ($left, $rights) = @$left2rights;
  415     my (@deps, @recipes, @otherchunks);
  416     for my $right (@$rights) {
  417         if (ref $right) {
  418             #     [ \@dir, \@targets, \@prereqs ]
  419             # @dir is dir parts for use by File::Spec
  420             # @targets is make targets within that dir
  421             # @prereqs are named targets - undef=[]
  422             my ($dir, $targets, $prereqs) = @$right;
  423             my $target_name = parallel_target_mangle($self, $dir, $targets);
  424             push @deps, $target_name;
  425             push @otherchunks, format_chunk(
  426                 $self, $target_name, $prereqs, $dir, $targets
  427             );
  428         } else {
  429             push @deps, $right;
  430         }
  431     }
  432     (
  433         join(' : ', $left, join ' ', @deps) . "\n",
  434         @otherchunks,
  435     );
  436 }
  437 
  438 sub parallel_target_mangle {
  439     my ($self, $dir, $targets) = @_;
  440     my $target = join '_', @$dir, @$targets;
  441     $target =~ s#[/\\]#_#g; # avoid ambiguity with filenames
  442     $target;
  443 }
  444 
  445 # remove pdl.c from making EUMM think this dir has XS in it
  446 sub MY::init_dirscan {
  447     package MY;
  448     my ($self) = @_;
  449     $self->SUPER::init_dirscan;
  450     $self->{C} = [];
  451     $self->{O_FILES} = [];
  452 }