"Fossies" - the Fresh Open Source Software Archive

Member "mod_perl-2.0.11/Apache-Reload/Makefile.PL" (5 Oct 2019, 7858 Bytes) of package /linux/www/apache_httpd_modules/mod_perl-2.0.11.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. See also the last Fossies "Diffs" side-by-side code changes report for "Makefile.PL": 2.0.8_vs_2.0.9.

    1 use strict;
    2 
    3 use lib qw(lib);
    4 use Config;
    5 
    6 my %prereqs = ();
    7 my %mp2 = ( mod_perl2 => 1.99022 );
    8 my %mp1 = ( mod_perl  => 0 );
    9 my $at_min_ver = 1.34;
   10 
   11 my $mp_gen;
   12 # MOD_PERL_2_BUILD is set from building from mod_perl Makefile.PL which should
   13 # also set MP_APXS
   14 if ($ENV{MOD_PERL_2_BUILD}) {
   15     push @ARGV, "-apxs", $ENV{MP_APXS};
   16     my $mp_gen = satisfy_mp_generation(2);
   17 }
   18 else {
   19     $mp_gen = satisfy_mp_generation();
   20 }
   21 
   22 %prereqs = ($mp_gen == 1 ? %mp1 : %mp2);
   23 
   24 my $HAS_APACHE_TEST = check_for_apache_test();
   25 
   26 my $VERSION;
   27 set_version();
   28 
   29 my %common_opts = (
   30                    VERSION         => $VERSION,
   31                    PREREQ_PM       => \%prereqs,
   32                    dist            => {
   33                        COMPRESS => 'gzip -9f', SUFFIX => 'gz',
   34                        PREOP   => 'find $(DISTVNAME) -type d -print|xargs chmod 0755 && ' .
   35                                   'find $(DISTVNAME) -type f -print|xargs chmod 0644',
   36                        TO_UNIX => 'find $(DISTVNAME) -type f -print|xargs dos2unix'
   37                    },
   38                    clean           => { FILES => 't/TEST' },
   39                   );
   40 
   41 ### MAINTAINER_BUILDING_RELEASE is hack
   42 ### for the Release Manager's use only.
   43 ### We will set it so that the resulting
   44 ### distribution will be called Apache-Reload-\d+.tar.gz
   45 ### and NOT Apache2-Reload-\d+.tar.gz
   46 ### This is for historical reasons and consistency
   47 if ($mp_gen == 1 || $ENV{MAINTAINER_BUILDING_RELEASE}) {
   48     require ExtUtils::MakeMaker;
   49     ExtUtils::MakeMaker::WriteMakefile(
   50                                        %common_opts,
   51                                        NAME            => "Apache::Reload",
   52                                        ABSTRACT_FROM   => 'lib/Apache/Reload.pm',
   53                                       );
   54 
   55 }
   56 else {
   57     require ModPerl::MM;
   58     ModPerl::MM::WriteMakefile(
   59                                %common_opts,
   60                                NAME            => "Apache2::Reload",
   61                                ABSTRACT_FROM   => 'lib/Apache2/Reload.pm',
   62                               );
   63 }
   64 
   65 sub check_for_apache_test {
   66     return unless eval {
   67         require Apache::Test;
   68         if ($Apache::Test::VERSION < $at_min_ver) {
   69             die "Apache::Test version is " . $Apache::Test::VERSION . 
   70                 ", minimum version required is $at_min_ver" . 
   71                 ", tests will be skipped\n";
   72         }
   73         require Apache::TestMM;
   74         require Apache::TestRunPerl;
   75         1;
   76     };
   77 
   78     Apache::TestMM::filter_args();
   79 
   80     my %args = @Apache::TestMM::Argv;
   81 
   82     Apache::TestRunPerl->generate_script();
   83 
   84     return 1;
   85 }
   86 
   87 sub set_version {
   88     require Apache::Reload;
   89     $VERSION = $Apache::Reload::VERSION;
   90 
   91     my $fh = Symbol::gensym();
   92     open $fh, 'Changes' or die "Can't open Changes: $!";
   93     while (<$fh>) {
   94         if(/^=item.*-(dev|rc\d+)/) {
   95             $VERSION .= "-$1";
   96             last;
   97         }
   98         last if /^=item/;
   99     }
  100     close $fh;
  101 }
  102 
  103 # If a specific generation was passed as an argument,
  104 #     if satisfied
  105 #         return the same generation
  106 #     else
  107 #         die
  108 # else @ARGV and %ENV will be checked for specific orders
  109 #     if the specification will be found
  110 #         if satisfied
  111 #             return the specified generation
  112 #         else
  113 #             die
  114 #     else if any mp generation is found
  115 #              return it
  116 #           else
  117 #              die
  118 
  119 sub satisfy_mp_generation {
  120     my $wanted = shift || wanted_mp_generation();
  121 
  122     unless ($wanted == 1 || $wanted == 2) {
  123         die "don't know anything about mod_perl generation: $wanted\n" .
  124             "currently supporting only generations 1 and 2";
  125     }
  126 
  127     my $selected = 0;
  128 
  129     if ($wanted == 1) {
  130         require_mod_perl();
  131         if ($mod_perl::VERSION >= 1.99) {
  132             # so we don't pick 2.0 version if 1.0 is wanted
  133             die "You don't seem to have mod_perl 1.0 installed";
  134         }
  135         $selected = 1;
  136     }
  137     elsif ($wanted == 2) {
  138         #warn "Looking for mod_perl 2.0";
  139         require_mod_perl();
  140         if ($mod_perl::VERSION < 2.0) {
  141             die "You don't seem to have mod_perl 2.0 installed";
  142         }
  143         $selected = 2;
  144     }
  145     else {
  146         require_mod_perl();
  147         $selected = $mod_perl::VERSION >= 1.99 ? 2 : 1;
  148         warn "Using $mod_perl::VERSION\n";
  149     }
  150 
  151     return $selected;
  152 }
  153 
  154 sub require_mod_perl {
  155     eval { require mod_perl };
  156     eval { require mod_perl2 }  if ($@);
  157     die "Can't find mod_perl installed\nThe error was: $@" if $@;
  158 }
  159 
  160 # the function looks at %ENV and Makefile.PL option to figure out
  161 # whether a specific mod_perl generation was requested.
  162 # It uses the following logic:
  163 # via options:
  164 # perl Makefile.PL MOD_PERL=2
  165 # or via %ENV:
  166 # env MOD_PERL=1 perl Makefile.PL
  167 #
  168 # return value is:
  169 # 1 or 2 if the specification was found (mp 1 and mp 2 respectively)
  170 # 0 otherwise
  171 sub wanted_mp_generation {
  172 
  173     # check if we have a command line specification
  174     # flag: 0: unknown, 1: mp1, 2: mp2
  175     my $flag = 0;
  176     foreach my $key (@ARGV) {
  177         if ($key =~ /^MOD_PERL=(\d)$/) {
  178             $flag = $1;
  179         }
  180     }
  181 
  182     # check %ENV
  183     my $env = exists $ENV{MOD_PERL} ? $ENV{MOD_PERL} : 0;
  184 
  185     # check for contradicting requirements
  186     if ($env && $flag && $flag != $env) {
  187         die <<EOF;
  188 Can\'t decide which mod_perl version should be used, since you have
  189 supplied contradicting requirements:
  190     enviroment variable MOD_PERL=$env
  191     Makefile.PL option  MOD_PERL=$flag
  192 EOF
  193     }
  194 
  195     my $wanted = 0;
  196     $wanted = 2 if $env == 2 || $flag == 2;
  197     $wanted = 1 if $env == 1 || $flag == 1;
  198 
  199     unless ($wanted) {
  200         # if still unknown try to require mod_perl.pm
  201         eval { require mod_perl };
  202         if ($@) {
  203             # if we don't have mp1, check for mp2
  204             # see if we are in the mp2 build structure
  205             eval { require File::Spec };
  206             unless ($@) {
  207                 my $mplib = File::Spec->catdir('..', 'lib');
  208                 unshift @INC, $mplib if -e File::Spec->catfile($mplib,'mod_perl2.pm');
  209                 my $atlib = File::Spec->catdir('../', 'Apache-Test', 'lib');
  210                 unshift @INC, $atlib if -d $atlib;
  211             } 
  212 
  213             eval { require mod_perl2 } if ($@);
  214             unless ($@) {
  215                 $wanted = 2;
  216             }
  217         }
  218         else {
  219             $wanted = 1;
  220         }
  221     }
  222 
  223     return $wanted;
  224 }
  225 
  226 package MY;
  227 
  228 sub postamble {
  229     my $self = shift;
  230 
  231     my $string = $self->SUPER::postamble;
  232 
  233     $string .= <<'EOF';
  234 tag :
  235     svn copy https://svn.apache.org/repos/asf/perl/Apache-Reload/trunk https://svn.apache.org/repos/asf/perl/Apache-Reload/tags/$(VERSION_SYM)
  236     @echo update lib/Apache/Reload.pm VERSION now
  237 EOF
  238 
  239     return $string;
  240 }
  241 
  242 sub test {
  243     my $self = shift;
  244 
  245     eval { require Test::More } or return <<EOF;
  246 test::
  247 \t\@echo sorry, cannot run tests without Test::More
  248 EOF
  249 
  250     return $self->Apache::TestMM::test(@_) if $HAS_APACHE_TEST;
  251 
  252     return <<EOF
  253 test::
  254 \t\@echo
  255 \t\@echo sorry, cannot run tests without a properly
  256 \t\@echo configured Apache-Test environment, mininum
  257 \t\@echo Apache::Test version needed is $at_min_ver
  258 \t\@echo
  259 EOF
  260 }
  261 
  262 sub clean {
  263     my $self = shift;
  264 
  265     return $self->Apache::TestMM::clean(@_) if $HAS_APACHE_TEST;
  266 
  267     return $self->SUPER::clean(@_);
  268 }
  269 
  270 sub constants {
  271     my $self = shift;
  272 
  273     my $string = $self->MM::constants;
  274 
  275     # mp2 installs this into INSTALLSITEARCH, so in order to avoid
  276     # problems when users forget 'make install UNINST=1', trick MM into
  277     # installing pure perl modules to the sitearch location, when this is
  278     # not installed as a part of mp2 build
  279     if (!$ENV{MOD_PERL_2_BUILD}) {
  280         $string .= <<'EOI';
  281 
  282 # install into the same location as mod_perl 2.0
  283 INSTALLSITELIB = $(INSTALLSITEARCH)
  284 DESTINSTALLSITELIB = $(DESTINSTALLSITEARCH)
  285 EOI
  286     }
  287 
  288     $string;
  289 }